Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

Commit cf9daaf

Browse files
committed
grammar: flatten atoms to a single level
1 parent 5b59c48 commit cf9daaf

25 files changed

+759
-1048
lines changed

grammar.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const oneOf = (x) => choice.apply(null, x);
108108
module.exports = grammar({
109109
name: "erlang",
110110

111-
word: ($) => $.unquoted_atom,
111+
word: ($) => $._unquoted_atom,
112112

113113
extras: ($) => [/[\x00-\x20\x80-\xA0]/, $.comment],
114114

@@ -542,10 +542,10 @@ module.exports = grammar({
542542
list: ($) => list($.expression),
543543
tuple: ($) => tuple($.expression),
544544

545-
atom: ($) => field("value", choice($.unquoted_atom, $.quoted_atom)),
546-
unquoted_atom: ($) =>
545+
atom: ($) => field("value", choice($._unquoted_atom, $._quoted_atom)),
546+
_unquoted_atom: ($) =>
547547
/[a-z\xDF-\xF6\xF8-\xFF][_@a-zA-Z0-9\xC0-\xD6\xD8-\xDE\xDF-\xF6\xF8-\xFF]*/,
548-
quoted_atom: ($) => seq("'", repeat(choice(/[^'\\]+/, $._escape)), "'"),
548+
_quoted_atom: ($) => seq("'", repeat(choice(/[^'\\]+/, $._escape)), "'"),
549549

550550
integer: ($) =>
551551
choice(

src/grammar.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "erlang",
3-
"word": "unquoted_atom",
3+
"word": "_unquoted_atom",
44
"rules": {
55
"source_file": {
66
"type": "REPEAT",
@@ -3363,20 +3363,20 @@
33633363
"members": [
33643364
{
33653365
"type": "SYMBOL",
3366-
"name": "unquoted_atom"
3366+
"name": "_unquoted_atom"
33673367
},
33683368
{
33693369
"type": "SYMBOL",
3370-
"name": "quoted_atom"
3370+
"name": "_quoted_atom"
33713371
}
33723372
]
33733373
}
33743374
},
3375-
"unquoted_atom": {
3375+
"_unquoted_atom": {
33763376
"type": "PATTERN",
33773377
"value": "[a-z\\xDF-\\xF6\\xF8-\\xFF][_@a-zA-Z0-9\\xC0-\\xD6\\xD8-\\xDE\\xDF-\\xF6\\xF8-\\xFF]*"
33783378
},
3379-
"quoted_atom": {
3379+
"_quoted_atom": {
33803380
"type": "SEQ",
33813381
"members": [
33823382
{

src/node-types.json

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@
44
"named": true,
55
"fields": {
66
"value": {
7-
"multiple": false,
7+
"multiple": true,
88
"required": true,
99
"types": [
1010
{
11-
"type": "quoted_atom",
12-
"named": true
13-
},
14-
{
15-
"type": "unquoted_atom",
16-
"named": true
11+
"type": "'",
12+
"named": false
1713
}
1814
]
1915
}
@@ -1697,11 +1693,6 @@
16971693
}
16981694
}
16991695
},
1700-
{
1701-
"type": "quoted_atom",
1702-
"named": true,
1703-
"fields": {}
1704-
},
17051696
{
17061697
"type": "record",
17071698
"named": true,
@@ -2519,10 +2510,6 @@
25192510
"type": "type",
25202511
"named": false
25212512
},
2522-
{
2523-
"type": "unquoted_atom",
2524-
"named": true
2525-
},
25262513
{
25272514
"type": "unsigned",
25282515
"named": false

0 commit comments

Comments
 (0)