Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions rust/parser/test/autogenerated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,20 @@ impl GrammarTree {
"ASCII_ALPHA".into(),
Expansion::Alternatives(('a'..='z').map(|digit| Expansion::Literal(digit.to_string())).collect()),
);
tree.rules.insert(
"XID_START".into(),
Expansion::Alternatives(('a'..='z').map(|char| Expansion::Literal(char.to_string())).collect()),
);
tree.rules.insert(
"XID_CONTINUE".into(),
Expansion::Alternatives(
('a'..='z')
.chain('0'..='9')
.chain(['-', '_'])
.map(|char| Expansion::Literal(char.to_string()))
.collect(),
),
);
tree.rules.insert(
"ANY".into(),
Expansion::Alternatives(
Expand Down
31 changes: 7 additions & 24 deletions rust/parser/typeql.pest
Original file line number Diff line number Diff line change
Expand Up @@ -588,31 +588,14 @@ ARROW = _{ "->" }

// FRAGMENTS OF KEYWORDS =======================================================

IDENTIFIER_CHAR = @{ ASCII_ALPHA
| '\u{00C0}'..'\u{00D6}'
| '\u{00D8}'..'\u{00F6}'
| '\u{00F8}'..'\u{02FF}'
| '\u{0370}'..'\u{037D}'
| '\u{037F}'..'\u{1FFF}'
| '\u{200C}'..'\u{200D}'
| '\u{2070}'..'\u{218F}'
| '\u{2C00}'..'\u{2FEF}'
| '\u{3001}'..'\u{D7FF}'
| '\u{F900}'..'\u{FDCF}'
| '\u{FDF0}'..'\u{FFFD}'
}
IDENTIFIER_CONNECTOR = @{ "_"
| "-"
| "\u{00B7}"
| '\u{0300}'..'\u{036F}'
| '\u{203F}'..'\u{2040}'
}
IDENTIFIER_START = @{ XID_START }
IDENTIFIER_CONTINUE = @{ "-" | XID_CONTINUE }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- is not in XID_CONTINUE, but a valid continuation character in TypeQL identifiers.


IDENTIFIER_LABEL_H = @{ IDENTIFIER_CHAR }
IDENTIFIER_LABEL_T = @{ IDENTIFIER_LABEL_H | ASCII_DIGIT | IDENTIFIER_CONNECTOR }
IDENTIFIER_LABEL_H = @{ IDENTIFIER_START }
IDENTIFIER_LABEL_T = @{ IDENTIFIER_CONTINUE }

IDENTIFIER_VAR_H = @{ IDENTIFIER_CHAR | ASCII_DIGIT }
IDENTIFIER_VAR_T = @{ IDENTIFIER_VAR_H | IDENTIFIER_CONNECTOR }
IDENTIFIER_VAR_H = @{ IDENTIFIER_START | ASCII_DIGIT }
IDENTIFIER_VAR_T = @{ IDENTIFIER_CONTINUE }

date_fragment = ${ year ~ "-" ~ month ~ "-" ~ day }
month = @{ "0" ~ ( '1'..'9' ) | "10" | "11" | "12" }
Expand Down Expand Up @@ -648,7 +631,7 @@ duration_seconds = ${ numeric_literal ~ "S" }

escape_seq = @{ "\\" ~ ANY }

WB = _{ &( !IDENTIFIER_CONNECTOR ~ PUNCTUATION | WHITESPACE | COMMENT | EOI ) } // Word boundary
WB = _{ !IDENTIFIER_CONTINUE } // Word boundary

COMMENT = _{ "#" ~ ( !NEWLINE ~ ANY )* ~ ( NEWLINE | EOI ) }
WHITESPACE = _{ " " | "\t" | "\r" | "\n" }