mirror of
https://github.com/AdaCore/langkit.git
synced 2026-02-12 12:28:12 -08:00
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).
60 lines
1.1 KiB
Plaintext
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"#(.?)+"
|
|
}
|
|
|
|
}
|