aboutsummaryrefslogtreecommitdiff
path: root/src/nbc/substitution.grm
blob: 58505b5de7b878e6670afa0dffdc7fd3d9635094 (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
%%
%name SubstitutionGrm
%pos int
%arg (lookup): string -> string
%term
	DOLLAR
	| TEXT of string
	| LEFT_PARENTHESIS
	| LEFT_BRACE
	| RIGHT_PARENTHESIS
	| RIGHT_BRACE
	| EOF
%nonterm
	STRING of string
	| LIST of string list
	| PORTION of string
	| VARIABLE of string
	| PARENTHESIZED of string list
	| INSIDE_PARENTHESES of string list
	| BRACED of string list
	| INSIDE_BRACES of string list
%eop EOF
%noshift EOF
%start STRING
%%
STRING: LIST (concat LIST)
LIST:
	(nil)
	| PORTION LIST (PORTION :: LIST)
PORTION:
	TEXT (TEXT)
	| VARIABLE (lookup VARIABLE)
VARIABLE:
	DOLLAR TEXT (TEXT)
	| PARENTHESIZED (concat PARENTHESIZED)
	| BRACED (concat BRACED)
PARENTHESIZED:
	LEFT_PARENTHESIS INSIDE_PARENTHESES RIGHT_PARENTHESIS (INSIDE_PARENTHESES)
INSIDE_PARENTHESES:
	(nil)
	| TEXT INSIDE_PARENTHESES (TEXT :: INSIDE_PARENTHESES)
	| LEFT_PARENTHESIS INSIDE_PARENTHESES RIGHT_PARENTHESIS INSIDE_PARENTHESES
		("(" :: INSIDE_PARENTHESES1 @ ")" :: INSIDE_PARENTHESES2)
BRACED:
	LEFT_BRACE INSIDE_BRACES RIGHT_BRACE (INSIDE_BRACES)
INSIDE_BRACES:
	(nil)
	| TEXT INSIDE_BRACES (TEXT :: INSIDE_BRACES)
	| LEFT_BRACE INSIDE_BRACES RIGHT_BRACE INSIDE_BRACES
		("{" :: INSIDE_BRACES1 @ "}" :: INSIDE_BRACES2)