Disable keyword extraction
For now bare keywords are errors, since we have not included them as valid expressions.
This commit is contained in:
parent
50c8e3c0e6
commit
0bc7e59fc7
|
@ -17,6 +17,9 @@ const PREC = {
|
||||||
module.exports = grammar({
|
module.exports = grammar({
|
||||||
name: "tiger",
|
name: "tiger",
|
||||||
|
|
||||||
|
// Ensure we don't extract keywords from tokens
|
||||||
|
word: ($) => $.identifier,
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
source_file: ($) => choice(
|
source_file: ($) => choice(
|
||||||
$._expr,
|
$._expr,
|
||||||
|
@ -40,6 +43,9 @@ module.exports = grammar({
|
||||||
'"',
|
'"',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// NOTE: includes reserved identifiers
|
||||||
|
identifier: (_) => /[_a-zA-Z0-9]+/,
|
||||||
|
|
||||||
escape_sequence: (_) => token.immediate(
|
escape_sequence: (_) => token.immediate(
|
||||||
seq(
|
seq(
|
||||||
"\\",
|
"\\",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "tiger",
|
"name": "tiger",
|
||||||
|
"word": "identifier",
|
||||||
"rules": {
|
"rules": {
|
||||||
"source_file": {
|
"source_file": {
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
|
@ -72,6 +73,10 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"identifier": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[_a-zA-Z0-9]+"
|
||||||
|
},
|
||||||
"escape_sequence": {
|
"escape_sequence": {
|
||||||
"type": "IMMEDIATE_TOKEN",
|
"type": "IMMEDIATE_TOKEN",
|
||||||
"content": {
|
"content": {
|
||||||
|
|
857
src/parser.c
857
src/parser.c
File diff suppressed because it is too large
Load diff
21
test/corpus/identifiers.txt
Normal file
21
test/corpus/identifiers.txt
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
================================================================================
|
||||||
|
_main identifier
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
_main
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(ERROR
|
||||||
|
(identifier))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Normal identifier
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
my_1st_variable
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(ERROR
|
||||||
|
(identifier))
|
Loading…
Reference in a new issue