Skip to content

Commit

Permalink
Merge branch 'topic/checks_quick_fixes' into 'master'
Browse files Browse the repository at this point in the history
Add auto-fix driver to the LKQL executable

Closes #208

See merge request eng/libadalang/langkit-query-language!161
  • Loading branch information
HugoGGuerrier committed Dec 16, 2024
2 parents e8e05bb + a1335ca commit ca66efd
Show file tree
Hide file tree
Showing 326 changed files with 4,332 additions and 860 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ doc: build_lkql_native_jit
cd user_manual && make clean html
cd lkql_checker/doc && make generate html-all

format:
$(MAVEN) -f lkql_jit spotless:apply

gnatcheck: lkql
gprbuild -P lkql_checker/gnatcheck.gpr -p $(GPR_ARGS) -XBUILD_MODE=$(BUILD_MODE)

Expand Down
45 changes: 45 additions & 0 deletions lkql/build/railroad-diagrams/constructor_call.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 30 additions & 25 deletions lkql/build/railroad-diagrams/value_expr.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions lkql/language/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Token(LexerToken):
Else = WithSymbol()
Not = WithSymbol()
Null = WithSymbol()
New = WithSymbol()
Import = WithSymbol()

Dot = WithText()
Expand Down Expand Up @@ -135,6 +136,7 @@ class Token(LexerToken):
(Literal("then"), Token.Then),
(Literal("not"), Token.Not),
(Literal("null"), Token.Null),
(Literal("new"), Token.New),
(Pattern("[0-9]+"), Token.Integer),
(Pattern("[a-z][A-Za-z0-9_]*"), Token.Identifier),
(Pattern("[A-Za-z][A-Za-z0-9_]*"), Token.UpperIdentifier),
Expand Down
31 changes: 31 additions & 0 deletions lkql/language/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,14 @@ class SafeAccess(DotAccess):
pass


class UpperDotAccess(Expr):
"""
Access to a node kind field using the dot notation.
"""
receiver = Field(type=Identifier)
member = Field(type=Identifier)


class InClause(Expr):
"""
Check that a list contains a given value using the ``in`` keyword
Expand Down Expand Up @@ -845,6 +853,22 @@ def min_depth_expr():
Self.depth_expr)


class ConstructorCall(Expr):
"""
Call of a constructor.
For instance::
new IntLiteral("50")
new BinOp(f_op=new OpPlus(),
f_left=new IntLiteral("40"),
f_right=new IntLiteral("2"))
"""

name = Field(type=Identifier)
arguments = Field(type=Arg.list)


class RecExpr(Expr):
"""
Expression that is only valid in a selector. Describes the next actions of
Expand Down Expand Up @@ -1253,13 +1277,15 @@ class Tuple(Expr):

DotAccess(G.value_expr, ".", c(), G.id),
SafeAccess(G.value_expr, "?.", c(), G.id),
UpperDotAccess(G.upper_id, ".", c(), G.id),
Indexing(G.value_expr, "[", c(), G.expr, "]"),
SafeIndexing(G.value_expr, "?[", c(), G.expr, "]"),
G.selector_expr,
FunCall(
G.value_expr, Safe("?"),
"(", c(), List(G.arg, empty_valid=True, sep=","), ")"
),
G.constructor_call,
G.term
),

Expand Down Expand Up @@ -1323,6 +1349,11 @@ class Tuple(Expr):
G.id, Safe("?"), "(", c(), G.arg_list, ")"
),

constructor_call=ConstructorCall(
"new", G.upper_id,
"(", c(), List(G.arg, empty_valid=True, sep=","), ")"
),

arg_list=List(G.arg, empty_valid=True, sep=","),

selector_decl=SelectorDecl(
Expand Down
Loading

0 comments on commit ca66efd

Please sign in to comment.