mirror of
https://github.com/hanzoai/ast.git
synced 2026-11-02 19:28:21 +00:00
These tests are easier to write and maintain if the grammars are just JS, like grammars normally are. It doesn't slow the tests down significantly to shell out to `node` for each of these grammars.
16 lines
378 B
JavaScript
16 lines
378 B
JavaScript
// This grammar shows that `ALIAS` rules can be applied directly to `TOKEN` and `IMMEDIATE_TOKEN`
|
|
// rules.
|
|
|
|
module.exports = grammar({
|
|
name: 'aliased_token_rules',
|
|
|
|
extras: $ => [/\s/],
|
|
|
|
rules: {
|
|
expression: $ => seq(
|
|
'a',
|
|
alias(token(seq('b', 'c')), $.X),
|
|
alias(token.immediate(seq('d', 'e')), $.Y),
|
|
),
|
|
}
|
|
}); |