Disable keyword extraction

For now bare keywords are errors, since we have not included them as
valid expressions.
This commit is contained in:
Bruno BELANYI 2022-06-01 17:36:39 +02:00
parent 50c8e3c0e6
commit 0bc7e59fc7
4 changed files with 522 additions and 367 deletions

View file

@ -17,6 +17,9 @@ const PREC = {
module.exports = grammar({
name: "tiger",
// Ensure we don't extract keywords from tokens
word: ($) => $.identifier,
rules: {
source_file: ($) => choice(
$._expr,
@ -40,6 +43,9 @@ module.exports = grammar({
'"',
),
// NOTE: includes reserved identifiers
identifier: (_) => /[_a-zA-Z0-9]+/,
escape_sequence: (_) => token.immediate(
seq(
"\\",

View file

@ -1,5 +1,6 @@
{
"name": "tiger",
"word": "identifier",
"rules": {
"source_file": {
"type": "CHOICE",
@ -72,6 +73,10 @@
}
]
},
"identifier": {
"type": "PATTERN",
"value": "[_a-zA-Z0-9]+"
},
"escape_sequence": {
"type": "IMMEDIATE_TOKEN",
"content": {

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,21 @@
================================================================================
_main identifier
================================================================================
_main
--------------------------------------------------------------------------------
(ERROR
(identifier))
================================================================================
Normal identifier
================================================================================
my_1st_variable
--------------------------------------------------------------------------------
(ERROR
(identifier))