Skip to content

Commit

Permalink
Merge branch 'topic/lkql_rule_config' into 'master'
Browse files Browse the repository at this point in the history
Rework the LKQL rule config file feature

Closes #245 and #220

See merge request eng/libadalang/langkit-query-language!221
  • Loading branch information
HugoGGuerrier committed May 15, 2024
2 parents 333e784 + 101f389 commit bd356fe
Show file tree
Hide file tree
Showing 190 changed files with 4,021 additions and 1,575 deletions.
16 changes: 8 additions & 8 deletions lkql/build/railroad-diagrams/at_object_assoc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions lkql/build/railroad-diagrams/at_object_key.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions lkql/build/railroad-diagrams/object_assoc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions lkql/build/railroad-diagrams/object_key.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions lkql/build/railroad-diagrams/upper_id.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions lkql/build/railroad-diagrams/value_pattern.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions lkql/language/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Token(LexerToken):
Identifier = WithSymbol()
KindName = WithSymbol()
UpperIdentifier = WithSymbol()
String = WithText()
Integer = WithText()

Expand Down Expand Up @@ -136,7 +136,7 @@ class Token(LexerToken):
(Literal("null"), Token.Null),
(Pattern("[0-9]+"), Token.Integer),
(Pattern("[a-z][A-Za-z0-9_]*"), Token.Identifier),
(Pattern("[A-Z][A-Za-z_]*(.list)?"), Token.KindName),
(Pattern("[A-Za-z][A-Za-z0-9_]*"), Token.UpperIdentifier),
(Pattern(r'"(\\.|[^"])*"'), Token.String),
(Pattern(r"#(.?)+"), Token.Comment)
)
18 changes: 13 additions & 5 deletions lkql/language/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,12 +1074,12 @@ class Tuple(Expr):
ExtendedNodePattern(

Or(UniversalPattern("*"),
NodeKindPattern(G.kind_name),
NodeKindPattern(G.upper_id),
ParenPattern("(", G.or_pattern, ")")),

Pick("(", c(), List(G.pattern_arg, sep=","), ")")
),
NodeKindPattern(G.kind_name),
NodeKindPattern(G.upper_id),
UniversalPattern("*"),
NullPattern("null"),
G.regex_pattern,
Expand Down Expand Up @@ -1138,14 +1138,22 @@ class Tuple(Expr):
List(G.object_assoc, empty_valid=True, sep=","),
"}"
),
object_assoc=ObjectAssoc(G.id, ":", G.expr),
object_assoc=ObjectAssoc(G.object_key, ":", G.expr),

at_object_lit=AtObjectLiteral(
"@", "{",
List(G.at_object_assoc, empty_valid=True, sep=","),
"}"
),
at_object_assoc=AtObjectAssoc(G.id, Opt(":", G.expr)),
at_object_assoc=AtObjectAssoc(
G.object_key,
Opt(":", G.expr)
),

object_key=Or(
G.id,
G.upper_id
),

listcomp=ListComprehension(
"[",
Expand Down Expand Up @@ -1321,7 +1329,7 @@ class Tuple(Expr):
if_then_else=IfThenElse("if", G.expr, "then", G.expr, "else", G.expr),

id=Identifier(Token.Identifier),
kind_name=Identifier(Token.KindName),
upper_id=Identifier(Token.UpperIdentifier),
integer=IntegerLiteral(Token.Integer),

bool_literal=Or(BoolLiteral.alt_true("true"),
Expand Down
Loading

0 comments on commit bd356fe

Please sign in to comment.