2017-10-28 22:54:15 +02:00
|
|
|
wschar:alias = " " | "\t" | "\n" | "\b" | "\f" | "\r" | "\v";
|
2017-10-29 15:55:12 +01:00
|
|
|
wsc:ws = wschar | comment;
|
2017-06-25 17:51:08 +02:00
|
|
|
|
2017-10-29 15:55:12 +01:00
|
|
|
block-comment:alias:nows = "/*" ("*" [^/] | [^*])* "*/";
|
|
|
|
line-comment:alias:nows = "//" [^\n]*;
|
|
|
|
comment-segment:alias:nows = line-comment | block-comment;
|
|
|
|
ws-no-nl:alias:nows = " " | "\t" | "\b" | "\f" | "\r" | "\v";
|
|
|
|
comment:nows = comment-segment (ws-no-nl* "\n"? ws-no-nl* comment-segment)*;
|
2017-06-25 17:51:08 +02:00
|
|
|
|
|
|
|
any-char = "."; // equivalent to [^]
|
|
|
|
|
|
|
|
// caution: newline is accepted
|
2017-10-29 15:55:12 +01:00
|
|
|
class-not = "^";
|
|
|
|
class-char:nows = [^\\\[\]\^\-] | "\\" .;
|
|
|
|
char-range:nows = class-char "-" class-char;
|
|
|
|
char-class:nows = "[" class-not? (class-char | char-range)* "]";
|
2017-06-25 17:51:08 +02:00
|
|
|
|
2017-06-26 02:20:23 +02:00
|
|
|
// newline is accepted
|
2017-10-29 15:55:12 +01:00
|
|
|
sequence-char:nows = [^\\"] | "\\" .;
|
|
|
|
char-sequence:nows = "\"" sequence-char* "\"";
|
2017-06-25 17:51:08 +02:00
|
|
|
|
|
|
|
terminal:alias = any-char | char-class | char-sequence;
|
|
|
|
|
2017-10-29 15:55:12 +01:00
|
|
|
symbol:nows = [^\\ \n\t\b\f\r\v/.\[\]\"{}\^+*?|():=;]+;
|
2017-06-25 17:51:08 +02:00
|
|
|
|
2017-10-29 15:55:12 +01:00
|
|
|
group:alias = "(" expression ")";
|
2017-06-25 17:51:08 +02:00
|
|
|
|
2017-10-29 15:55:12 +01:00
|
|
|
number:alias:nows = [0-9]+;
|
|
|
|
count = number;
|
|
|
|
count-quantifier = "{" count "}";
|
|
|
|
range-from = number;
|
|
|
|
range-to = number;
|
|
|
|
range-quantifier = "{" range-from? "," range-to? "}";
|
|
|
|
one-or-more = "+";
|
|
|
|
zero-or-more = "*";
|
|
|
|
zero-or-one = "?";
|
|
|
|
quantity:alias = count-quantifier
|
|
|
|
| range-quantifier
|
|
|
|
| one-or-more
|
|
|
|
| zero-or-more
|
|
|
|
| zero-or-one;
|
2017-06-25 17:51:08 +02:00
|
|
|
|
2017-10-29 15:55:12 +01:00
|
|
|
item:nows = (terminal | symbol | group) quantity?;
|
|
|
|
sequence = item+;
|
2017-06-25 17:51:08 +02:00
|
|
|
|
2017-11-02 22:19:03 +01:00
|
|
|
option:alias = terminal | symbol | group | sequence;
|
2017-06-25 17:51:08 +02:00
|
|
|
|
2017-06-26 02:20:23 +02:00
|
|
|
// DOC: how the order matters
|
2017-11-02 22:19:03 +01:00
|
|
|
choice = option ("|" option)+;
|
2017-06-25 17:51:08 +02:00
|
|
|
|
|
|
|
// DOC: not having 'not' needs some tricks sometimes
|
|
|
|
|
|
|
|
expression:alias = terminal
|
|
|
|
| symbol
|
|
|
|
| group
|
|
|
|
| sequence
|
|
|
|
| choice;
|
|
|
|
|
2017-10-29 15:55:12 +01:00
|
|
|
alias = "alias";
|
|
|
|
ws = "ws";
|
|
|
|
nows = "nows";
|
|
|
|
doc = "doc";
|
|
|
|
root = "root";
|
|
|
|
flag:alias = alias | ws | nows | doc | root;
|
|
|
|
definition-name:alias:nows = symbol (":" flag)*;
|
|
|
|
definition = definition-name "=" expression;
|
2017-06-25 17:51:08 +02:00
|
|
|
|
2017-10-29 15:55:12 +01:00
|
|
|
definitions:alias = definition (";"+ definition)*;
|
|
|
|
syntax:root = ";"* definitions? ";"*;
|