Files
langkit/testsuite/python_support/lexer_example.lkt
Pierre-Marie de Rodat ec4872e418 Lkt: change naming convention for token names for lower to camel
This makes the convention consistent with the DSL, and avoids
workarounds for conflicts with Lkt keywords: in Libadalang, the Null
token can stay Null, instead of null_tok (no API breakage needed).
2024-06-28 08:41:26 +00:00

60 lines
1.1 KiB
Plaintext

lexer foo_lexer {
@trivia()
Whitespace <- p"[ \n\r\t]+"
family alphanumericals {
Def <- "def"
Var <- "var"
}
family alphanumericals {
Error <- "error"
Example <- "example"
Null <- "null"
KwA <- "kwA"
KwB <- "kwB"
KwC <- "kwC"
KwD <- "kwD"
KwE <- "kwE"
KwF <- "kwF"
}
family punctuation {
Comma <- ","
Dot <- "."
Semicolon <- ";"
Colon <- ":"
LPar <- "("
RPar <- ")"
LBrace <- "{"
RBrace <- "}"
Equal <- or("=" | ":=")
Plus <- "+"
}
Minus <- "-"
LessThan <- "<"
LessThanOrEqual <- "<="
GreaterThan <- ">"
GreaterThanOrEqual <- ">="
@unparsing_spacing(with=alphanumericals)
family alphanumericals {
Number <- p"[0-9]+|0x[0-9a-f]+"
@symbol()
Identifier <- p"[a-zA-Z_][a-zA-Z0-9_]*"
}
String <- p"\"[^\"]*\""
family comments {
@with_unparsing_newline
@trivia(comment=true)
Comment <- p"#(.?)+"
}
}