Skip to content
Closed
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
13 changes: 10 additions & 3 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const PREC = {
WILDCARD_NODE: 1,
};

// Identifiers cannot start with `.`
const IDENTIFIER = /[a-zA-Z0-9\-_\$][a-zA-Z0-9.\-_\$]*/;
// Identifiers cannot start with `.`, `?`, or `!`
const IDENTIFIER = /[a-zA-Z0-9\-_][a-zA-Z0-9.\-_?!]*/;

module.exports = grammar({
name: "query",
Expand All @@ -25,6 +25,13 @@ module.exports = grammar({
$.definition,
],

externals: $ => [
// A regular identifier which will NOT consume the final `?` or `!` that it
// sees, in order to capture it as a separate (predicate_type) node
$._predicate_name,
$._error_sentinel,
],

rules: {
program: $ => repeat($.definition),

Expand Down Expand Up @@ -126,7 +133,7 @@ module.exports = grammar({
predicate: $ =>
seq(
"(",
field("name", seq(choice("#", "."), $._immediate_identifier, field("type", $.predicate_type))),
field("name", seq(choice("#", "."), alias($._predicate_name, $.identifier), field("type", $.predicate_type))),
field("parameters", $.parameters),
")"
),
Expand Down
24 changes: 19 additions & 5 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading