Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev 2.3 #203

Open
wants to merge 96 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
c39a14c
IR: fix counter for guards.
cristianoc Sep 28, 2023
b483d6a
IR: support default values in python functions.
cristianoc Sep 28, 2023
b9e46d1
Index (#204)
cristianoc Sep 30, 2023
0711177
Add lean tree sitter (#205)
cristianoc Sep 30, 2023
08f41c1
Clean up agents code (#208)
cristianoc Oct 1, 2023
9a7a0ec
Agents cleanup: move messages to abstract state.
cristianoc Oct 1, 2023
34ca16b
Add metalanguage.
cristianoc Sep 8, 2023
4be154e
Update metalanguage.py
cristianoc Oct 1, 2023
2d349f8
IR: rearrange symbol kinds. Get a sorted list on top.
cristianoc Oct 2, 2023
42d3db6
IR: document symbol kinds
cristianoc Oct 2, 2023
d0dca39
IR: document symbol
cristianoc Oct 2, 2023
d985e09
IR: add file symbol as parent of toplevel symbols.
cristianoc Oct 2, 2023
940f79f
IR File: remove statements
cristianoc Oct 2, 2023
64b2766
IR: no need to return from parse statement and block.
cristianoc Oct 2, 2023
e220789
IR: introduce Unknown symbol in pace of statement with no sybol
cristianoc Oct 2, 2023
56c848e
IR: remove concept of Item and make Block a list of symbols.
cristianoc Oct 2, 2023
e8fa1dd
IR: clean up statements.
cristianoc Oct 2, 2023
fc7a6a3
IR: remove parse_statement
cristianoc Oct 2, 2023
7e8607c
Index: refactor embedding.
cristianoc Oct 2, 2023
79533b0
Index: support searching function, file, class.
cristianoc Oct 2, 2023
3a4d6f1
Index API: use Query class.
cristianoc Oct 3, 2023
c3a6306
Index: test boolean queries.
cristianoc Oct 3, 2023
61a7860
IR: File() constructor takes a code argument now.
cristianoc Oct 3, 2023
61a4ebf
sort imports
cristianoc Oct 3, 2023
3033ba6
Delete index.rci
cristianoc Oct 3, 2023
be74f18
Index: move similarity to "Node".
cristianoc Oct 3, 2023
5ebf0c6
Index: refactor Node to use subclassing.
cristianoc Oct 3, 2023
41c7a49
Index: move out Node class.
cristianoc Oct 3, 2023
70d0f3e
Index: add function node to query
cristianoc Oct 3, 2023
4f1723e
Index: rename
cristianoc Oct 3, 2023
09037bd
Index: refactor logical connectives.
cristianoc Oct 4, 2023
92122ba
Index: fix similarity for aggregate symbols
cristianoc Oct 4, 2023
28ce9bc
Index: simplify API so defaults cover the typical use.
cristianoc Oct 5, 2023
a7132e8
Break up large symbols and use aggregate indexing (#217)
cristianoc Oct 8, 2023
703f971
Fix add symbol do aider.
cristianoc Oct 9, 2023
ad18916
IR: use relative imports
cristianoc Oct 11, 2023
ff3fdcf
Index moved to its own repo.
cristianoc Oct 11, 2023
65e9f27
IR: fix infinite loop in tree-sitter-rescript lexer.
cristianoc Oct 11, 2023
068ff23
IR: parse for loop
cristianoc Oct 15, 2023
d2138d7
IR: support async
cristianoc Oct 15, 2023
1fec96f
IR: handle await expressions
cristianoc Oct 15, 2023
c210775
IR: parse TS conditionals.
cristianoc Oct 16, 2023
895a033
IR: handle `{` and `}` in block.
cristianoc Oct 16, 2023
2ff4ebd
IR: handle expression statements in TS.
cristianoc Oct 16, 2023
44df0ef
IR tests variation
cristianoc Oct 16, 2023
632e8a4
IR: support conditionals, switch statements, blocks, and calls for Re…
cristianoc Oct 16, 2023
d526b13
IR: add "symbol" field to symbol_kind.
cristianoc Oct 16, 2023
7bf0ab7
IR: in Symbol rename "name" to "id"
cristianoc Oct 16, 2023
e82967c
IR: in Symbol, rename `kind()` to `name()`.
cristianoc Oct 16, 2023
28d2584
IR: rename field `symbol_kind` to `kind`
cristianoc Oct 16, 2023
f84a2d5
IR: make `substring` a computed property.
cristianoc Oct 16, 2023
756a040
IR: make `substring_without_body` a computed property.
cristianoc Oct 16, 2023
4ee9e64
IR: make `qualified_id` a computed property.
cristianoc Oct 16, 2023
4fc715b
IR: add computed property `file_path`
cristianoc Oct 16, 2023
1f9a9dc
IR: make `name` a computed property of Symbol.
cristianoc Oct 16, 2023
d501b6c
IR: make `name` a computed property of `SymbolKind`.
cristianoc Oct 16, 2023
77ffd8a
IR: add computed property `parent` to SymbolKind.
cristianoc Oct 16, 2023
f4d83fe
IR: support ReScript function with a single parenthesis-less parameter.
cristianoc Oct 16, 2023
f8579ca
Update metalanguage.py
cristianoc Oct 16, 2023
155266a
IR: rename type "name" to "id".
cristianoc Oct 17, 2023
425fe3d
IR: rename "name" to "id" in Field.
cristianoc Oct 17, 2023
6659f98
Update metalanguage tests
cristianoc Oct 17, 2023
5b4be56
Update linter_agent.py
cristianoc Oct 17, 2023
415e6b7
IR: add file path to fields in metalanguage
cristianoc Oct 17, 2023
f9bf1d1
Update linter_agent.py
cristianoc Oct 17, 2023
fe98fbf
IR: format
cristianoc Oct 17, 2023
6cfa9e0
IR: add computed property `id` to symbol kind.
cristianoc Oct 17, 2023
a602567
Update linter_agent.py
cristianoc Oct 17, 2023
f1f5f43
IR: rename kind to symbol_kind
cristianoc Oct 17, 2023
cb03b62
IR: rename property "name" to "kind" in symbol and symbol kind
cristianoc Oct 17, 2023
9bd914e
Update metalanguage.py
cristianoc Oct 17, 2023
c028be6
Update linter_agent.py
cristianoc Oct 17, 2023
822820a
Update missing_types.txt
cristianoc Oct 18, 2023
ecbf745
IR: add parent symbol to types.
cristianoc Oct 18, 2023
960c96f
IR: add parent symbol to parameter.
cristianoc Oct 18, 2023
d203623
IR: add parent to Field.
cristianoc Oct 18, 2023
3ae00ba
IR metalanguage: get file path directly from the parent symbol.
cristianoc Oct 18, 2023
64bcafe
IR: selectively update custom parsers when testing metalanguage.
cristianoc Oct 18, 2023
9096490
Split out OCaml parser.
cristianoc Oct 18, 2023
9e0b2fc
IR: split out ReScript parser
cristianoc Oct 18, 2023
90cc437
IR: split out lean parser
cristianoc Oct 18, 2023
9feacc9
IR: add support for ReScript array.
cristianoc Oct 19, 2023
58f199c
IR: fix parsing of "," in call arguments.
cristianoc Oct 19, 2023
3849629
IR: add support for ReScript tuples.
cristianoc Oct 19, 2023
7293504
IR: towards checking the second argument of useEffect.
cristianoc Oct 19, 2023
4495759
IR: expressions can be literals of symbols
cristianoc Oct 19, 2023
0002ad7
IR: more metalanguage tests.
cristianoc Oct 19, 2023
be36e67
IR: correct indentation in the metalanguage
cristianoc Oct 19, 2023
fe4d192
IR: don't parse files larger than 5MB.
cristianoc Oct 19, 2023
a21f8c5
typo
cristianoc Oct 19, 2023
793deca
IR: fix language of "File" symbol.
cristianoc Oct 20, 2023
e7c7f56
IR: use local imports for "ir".
cristianoc Oct 20, 2023
314dec9
Remove unused import
cristianoc Oct 23, 2023
452afe4
IS: add accessors for files, and symbols in a file.
cristianoc Oct 23, 2023
b3433f4
black and isort settings
cristianoc Oct 23, 2023
b50887c
Update linter examples for demo.
cristianoc Nov 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
IR: add support for ReScript array.
  • Loading branch information
cristianoc committed Oct 19, 2023
commit 9feacc9196ea2410115c871d51a3f574108318a8
21 changes: 21 additions & 0 deletions rift-engine/rift/ir/IR.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def __str__(self) -> str:


SymbolKindName = Literal[
"Array",
"Body",
"Call",
"Class",
Expand Down Expand Up @@ -278,6 +279,26 @@ class MetaSymbolKind(SymbolKind):
pass


@dataclass
class ArrayKind(MetaSymbolKind):
"""A symbol kind representing an array expression."""

elements: List[Expression]

@property
def kind(self) -> SymbolKindName:
return "Array"

def dump(self, lines: List[str]) -> None:
lines.append(f" elements: {self.elements}")

def __str__(self) -> str:
return f"[{', '.join(self.elements)}]"

def __repr__(self) -> str:
return self.__str__()


@dataclass
class BodyKind(MetaSymbolKind):
"""Represents the body of a branch in the intermediate representation (IR).
Expand Down
8 changes: 1 addition & 7 deletions rift-engine/rift/ir/parser_lean.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import logging
from typing import List


from rift.ir.parser_core import Counter, SymbolParser

from .IR import (
DefKind,
StructureKind,
Symbol,
TheoremKind,
)
from .IR import DefKind, StructureKind, Symbol, TheoremKind

logger = logging.getLogger(__name__)

Expand Down
9 changes: 1 addition & 8 deletions rift-engine/rift/ir/parser_ocaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@

from rift.ir.parser_core import Counter, SymbolParser

from .IR import (
FunctionKind,
ModuleKind,
Parameter,
Symbol,
Type,
ValueKind,
)
from .IR import FunctionKind, ModuleKind, Parameter, Symbol, Type, ValueKind


class OCamlParser(SymbolParser):
Expand Down
29 changes: 28 additions & 1 deletion rift-engine/rift/ir/parser_rescript.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import logging
import os
from typing import List, Optional

from tree_sitter import Node

from rift.ir.parser_core import Counter, SymbolParser

from .IR import (
ArrayKind,
Case,
Expression,
Field,
FunctionKind,
IfKind,
Expand Down Expand Up @@ -345,12 +348,36 @@ def parse_metasymbol(self, counter: Counter) -> Optional[Symbol]:
self.file.add_symbol(switch_symbol)
return switch_symbol

elif node.type == "array":
symbol = self.mk_dummy_metasymbol(counter, "array")
elements: List[Expression] = []
symbol_kind = ArrayKind(symbol, elements)
for child in self.node.children:
if child.type in ["[", "]", ","]:
continue
scope = self.scope
exp = self.recurse(child, scope, parent=symbol).parse_expression(counter)
elements.append(exp)
self.update_dummy_symbol(symbol, symbol_kind)
self.file.add_symbol(symbol)
return symbol

return super().parse_metasymbol(counter)

def walk_expression(self, counter: Counter) -> None:
if self.node.type in ["if_expression", "switch_expression"]:
if self.node.type in ["if_expression", "switch_expression", "array"]:
self.parse_symbols(counter)
elif self.node.type == "block":
self.parse_block()

super().walk_expression(counter)


def test():
from . import custom_parsers, parser

project_root = os.path.join(os.path.dirname(__file__), "tests")
custom_parsers.activate()
project = parser.parse_files_in_paths([project_root], metasymbols=True)
map = project.dump_map(indent=0)
print(f"\nMAP:\n{map}")
2 changes: 1 addition & 1 deletion rift-engine/rift/ir/tests/record.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ let useInConditional = x => {
}

let useAtToplevel = x => {
useState()
useState([1,2,[3,4]])
}