-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.y
More file actions
155 lines (136 loc) · 3.1 KB
/
Copy pathparser.y
File metadata and controls
155 lines (136 loc) · 3.1 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
%{
package ldapschemaparser
%}
%union{
genericSchema *GenericSchema
parameterizedKeyword *ParameterizedKeyword
text string
}
%token '(' ')' '{' '}'
%token SPACES
%token <text> NUMBER
%token <text> NUMERIC_OID
%token <text> KEYWORD X_KEYWORD NOIDS_ATTR_KEYWORD OIDLEN_ATTR_KEYWORD
%token <text> QSTRINGS_ATTR_KEYWORD QSTRING_ATTR_KEYWORD
%token <text> SQSTRING DQSTRING
%type <genericSchema> schema attributeDefinitions attributeDefinition
%type <parameterizedKeyword> noids dollarOIDs numberIDS
%type <parameterizedKeyword> qstrings spacedQuotedStrings
%type <text> oid
%type <text> quotedString
%type <text> oidWithLength
%start schema
%%
schema: '(' optionalSpace NUMERIC_OID SPACES attributeDefinitions optionalSpace ')' {
$$ = $5
$$.NumericOID = $3
yylex.(*schemaLexer).result = $$
}
| '(' optionalSpace NUMBER SPACES attributeDefinitions optionalSpace ')' {
$$ = $5
$$.NumericOID = $3
yylex.(*schemaLexer).result = $$
}
optionalSpace:
| SPACES
oid: NUMERIC_OID {
$$ = $1
}
| KEYWORD {
$$ = $1
}
| NOIDS_ATTR_KEYWORD {
$$ = $1
}
| OIDLEN_ATTR_KEYWORD {
$$ = $1
}
| QSTRINGS_ATTR_KEYWORD {
$$ = $1
}
| QSTRING_ATTR_KEYWORD {
$$ = $1
}
dollarOIDs: oid {
$$ = newParameterizedKeywordWithParameter($1, OIDsRule)
}
| dollarOIDs optionalSpace '$' optionalSpace oid {
$$ = $1
$$.addParameter($5)
}
numberIDS: NUMBER {
$$ = newParameterizedKeywordWithParameter($1, NumberIDsRule)
}
| numberIDS SPACES NUMBER {
$$ = $1
$$.addParameter($3)
}
noids: oid {
$$ = newParameterizedKeywordWithParameter($1, OIDsRule)
}
| '(' optionalSpace dollarOIDs optionalSpace ')' {
$$ = $3
}
| NUMBER {
$$ = newParameterizedKeywordWithParameter($1, NumberIDsRule)
}
| '(' optionalSpace numberIDS optionalSpace ')' {
$$ = $3
}
quotedString: SQSTRING {
$$ = $1
}
| DQSTRING {
$$ = $1
}
spacedQuotedStrings: quotedString {
$$ = newParameterizedKeywordWithParameter($1, QuotedStringsRule)
}
| spacedQuotedStrings SPACES quotedString {
$$ = $1
$$.addParameter($3)
}
qstrings: quotedString {
$$ = newParameterizedKeywordWithParameter($1, QuotedStringsRule)
}
| '(' optionalSpace spacedQuotedStrings optionalSpace ')' {
$$ = $3
}
oidWithLength: NUMERIC_OID {
$$ = $1
}
| NUMERIC_OID '{' NUMBER '}' {
$$ = $1 + "{" + $3 + "}"
}
attributeDefinition: KEYWORD {
$$ = newGenericSchema()
$$.addFlagKeywords($1)
}
| NOIDS_ATTR_KEYWORD optionalSpace noids {
$$ = newGenericSchema()
$$.addParameterizedKeyword($1, $3)
}
| OIDLEN_ATTR_KEYWORD optionalSpace oidWithLength {
$$ = newGenericSchema()
$$.addParameterizedKeyword($1, newParameterizedKeywordWithParameter($3, OIDWithLengthRule))
}
| QSTRINGS_ATTR_KEYWORD optionalSpace qstrings {
$$ = newGenericSchema()
$$.addParameterizedKeyword($1, $3)
}
| QSTRING_ATTR_KEYWORD optionalSpace quotedString {
$$ = newGenericSchema()
$$.addParameterizedKeyword($1, newParameterizedKeywordWithParameter($3, QuotedStringRule))
}
| X_KEYWORD optionalSpace qstrings {
$$ = newGenericSchema()
$$.addParameterizedKeyword($1, $3)
}
attributeDefinitions: attributeDefinition {
$$ = $1
}
| attributeDefinitions SPACES attributeDefinition {
$1.add($3)
$$ = $1
}
%%