-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.ebnf
37 lines (25 loc) · 1.41 KB
/
grammar.ebnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
; This is an attempt at a formal definition for the grammar of the
; liblouis context rules. It is derived mostly from the liblouis
; documentation[1] and parser implementation based on nom[2]
; [1] http://liblouis.io/documentation/liblouis.html#The-Context-and-Multipass-Opcodes
; [2] https://github.com/liblouis/louis-rs/blob/main/src/parser.rs#L1679
; [3] https://bottlecaps.de/rr/ui
context_rule ::= "context" tests action
test ::= "!"? (string | dots | attributes | class | grouping_left | grouping_right | replacement | lookback | variable)
tests ::= "`"? test+ "~"?
string ::= '"' [^"] '"'
dot ::= [:xdigit:]+ ; at most 15 hex digits and unique
dots ::= '@' dot ("-" dot)+
quantifier ::= (number | number "-" number | ".")
attributes ::= "$" ("a" | "d" | "D" | "l" | "m" | "p" | "S" | "s" | "U" | "u" | "w" | "x" | "y" | "z")+ quantifier?
class_name ::= [1-7] | [:alpha:]+
class ::= "%" class_name quantifier?
grouping_left ::= "{" [:alpha:]+
grouping_right ::= "}" [:alpha:]+
lookback ::= "_" number?
replacement ::= "[" test "]"
variable_name ::= [:digit:]+ ; the real range is 0-49 (according to the docs for whatever reason)
variable_test ::= "#" variable_name ("=" | ">" | ">=" | "<" | "<=") number
variable_assignment ::= "#" variable_name "=" number
variable_change ::= "#" variable_name ("-" | "+")
number ::= [1-9] [:digit:]*