Skip to content

Commit

Permalink
Fixing QIDENT (#5)
Browse files Browse the repository at this point in the history
* Fixing quoted identifiers.
  • Loading branch information
AnHeuermann authored Apr 15, 2024
1 parent 1f33f2b commit 45c23aa
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 11 deletions.
11 changes: 0 additions & 11 deletions rules/lexicalConventions.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
// https://specification.modelica.org/master/modelica-concrete-syntax.html

module.exports = {
// TODO: Remove or use this one
/*
IDENT: $ => token(
choice(
// NON-DIGIT { DIGIT | NON-DIGIT }
Expand Down Expand Up @@ -72,15 +70,6 @@ module.exports = {
)
)
),
*/

IDENT: $ => token(choice(
seq(/[_a-zA-Z]/, repeat(choice(/[0-9]/, /[_a-zA-Z]/))),
seq("’", repeat(choice(
/[_a-zA-Z]/, /[0-9]/, "!", "#", "$", "%", "&", "(", ")",
"*", "+", ",", "-", ".", "/", ":", ";", "<", ">", "=",
"?", "@", "[", "]", "^", "{", "}", "|", "~", " ", "\"",
seq("\\", choice("’", "'", "\"", "?", "\\", "a", "b", "f", "n", "r", "t", "v")))), "’"))),

STRING: $ => token(
seq(
Expand Down
52 changes: 52 additions & 0 deletions test/corpus/lexical_conventions_funkyIdent.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
================
FunkyIdentifiers
================

model FunkyIdentifiers
Real x;
Real 'x';
Real 'x"y z';
Real 'x\'y //z';
end FunkyIdentifiers;

---

(stored_definition
(class_definition
(class_type
(MODEL))
(class_specifier
(identifier
(IDENT))
(composition
(element
(component_clause
(type_specifier
(T_REAL))
(component_declaration
(declaration
(IDENT)))))
(element
(component_clause
(type_specifier
(T_REAL))
(component_declaration
(declaration
(IDENT)))))
(element
(component_clause
(type_specifier
(T_REAL))
(component_declaration
(declaration
(IDENT)))))
(element
(component_clause
(type_specifier
(T_REAL))
(component_declaration
(declaration
(IDENT))))))
(T_END)
(identifier
(IDENT)))))

0 comments on commit 45c23aa

Please sign in to comment.