Files
langkit/testsuite/python_support/lexer_example.lkt
Pierre-Marie de Rodat 449d98a9a2 lexer_example: set "var" as alphanumerical
This is necessary so that unparsing inserts a space between "var" and
"foo" in "var foo". That problem was undetected so far in our only
rewriting API test because all variable declaration nodes were rewritten
from sources (they were not synthetized), so formatting (which includes
that space) was preserved.
2023-12-08 11:42:05 +00:00

49 lines
850 B
Plaintext

lexer foo_lexer {
@trivia()
whitespace <- p"[ \n\r\t]+"
family alphanumericals {
def <- "def"
var <- "var"
}
family alphanumericals {
error <- "error"
example <- "example"
null_tok <- "null"
}
family punctuation {
comma <- ","
dot <- "."
semicolon <- ";"
l_par <- "("
r_par <- ")"
l_brace <- "{"
r_brace <- "}"
equal <- "="
plus <- "+"
}
minus <- "-"
less_than <- "<"
@unparse_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 {
@unparse_newline_after
@trivia()
comment <- p"#(.?)+"
}
}