My favorites | Sign in
Project Home
Checkout   Browse   Changes  
Changes to /trunk/src/erlydtl/erlydtl_parser.yrl
r135 vs. r168 Compare: vs.  Format:
Revision r168
Go to: 
Project members, sign in to write a code review
/trunk/src/erlydtl/erlydtl_parser.yrl   r135 /trunk/src/erlydtl/erlydtl_parser.yrl   r168
1 %%%------------------------------------------------------------------- 1 %%%-------------------------------------------------------------------
2 %%% File: erlydtl_parser.erl 2 %%% File: erlydtl_parser.erl
3 %%% @author Roberto Saccon <rsaccon@gmail.com> [http://rsaccon.com] 3 %%% @author Roberto Saccon <rsaccon@gmail.com> [http://rsaccon.com]
4 %%% @author Evan Miller <emmiller@gmail.com> 4 %%% @author Evan Miller <emmiller@gmail.com>
5 %%% @copyright 2008 Roberto Saccon, Evan Miller 5 %%% @copyright 2008 Roberto Saccon, Evan Miller
6 %%% @doc Template language grammar 6 %%% @doc Template language grammar
7 %%% @reference See <a href="http://erlydtl.googlecode.com" target="_top">http://erlydtl.googlecode.com</a> for more information 7 %%% @reference See <a href="http://erlydtl.googlecode.com" target="_top">http://erlydtl.googlecode.com</a> for more information
8 %%% @end 8 %%% @end
9 %%% 9 %%%
10 %%% The MIT License 10 %%% The MIT License
11 %%% 11 %%%
12 %%% Copyright (c) 2007 Roberto Saccon, Evan Miller 12 %%% Copyright (c) 2007 Roberto Saccon, Evan Miller
13 %%% 13 %%%
14 %%% Permission is hereby granted, free of charge, to any person obtaining a copy 14 %%% Permission is hereby granted, free of charge, to any person obtaining a copy
15 %%% of this software and associated documentation files (the "Software"), to deal 15 %%% of this software and associated documentation files (the "Software"), to deal
16 %%% in the Software without restriction, including without limitation the rights 16 %%% in the Software without restriction, including without limitation the rights
17 %%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 %%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 %%% copies of the Software, and to permit persons to whom the Software is 18 %%% copies of the Software, and to permit persons to whom the Software is
19 %%% furnished to do so, subject to the following conditions: 19 %%% furnished to do so, subject to the following conditions:
20 %%% 20 %%%
21 %%% The above copyright notice and this permission notice shall be included in 21 %%% The above copyright notice and this permission notice shall be included in
22 %%% all copies or substantial portions of the Software. 22 %%% all copies or substantial portions of the Software.
23 %%% 23 %%%
24 %%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 %%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 %%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 %%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 %%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 %%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 %%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 %%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 %%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 %%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 %%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 %%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 %%% THE SOFTWARE. 30 %%% THE SOFTWARE.
31 %%% 31 %%%
32 %%% @since 2007-11-11 by Roberto Saccon, Evan Miller 32 %%% @since 2007-11-11 by Roberto Saccon, Evan Miller
33 %%%------------------------------------------------------------------- 33 %%%-------------------------------------------------------------------
34 34
35 Nonterminals 35 Nonterminals
36 Elements 36 Elements
37 Literal 37 Literal
38 38
39 ValueBraced 39 ValueBraced
40 40
41 ExtendsTag 41 ExtendsTag
42 IncludeTag 42 IncludeTag
43 NowTag 43 NowTag
44 44
45 BlockBlock 45 BlockBlock
46 BlockBraced 46 BlockBraced
47 EndBlockBraced 47 EndBlockBraced
48 48
49 CommentBlock 49 CommentBlock
50 CommentBraced 50 CommentBraced
51 EndCommentBraced 51 EndCommentBraced
52 52
53 CycleTag 53 CycleTag
54 CycleNames 54 CycleNames
55 CycleNamesCompat 55 CycleNamesCompat
56 56
57 ForBlock 57 ForBlock
58 ForBraced 58 ForBraced
59 EndForBraced 59 EndForBraced
60 ForExpression 60 ForExpression
61 ForGroup 61 ForGroup
62 62
63 IfBlock 63 IfBlock
64 IfBraced 64 IfBraced
65 IfExpression 65 IfExpression
66 ElseBraced 66 ElseBraced
67 EndIfBraced 67 EndIfBraced
68 68
69 IfEqualBlock 69 IfEqualBlock
70 IfEqualBraced 70 IfEqualBraced
71 IfEqualExpression 71 IfEqualExpression
72 EndIfEqualBraced 72 EndIfEqualBraced
73 73
74 IfNotEqualBlock 74 IfNotEqualBlock
75 IfNotEqualBraced 75 IfNotEqualBraced
76 IfNotEqualExpression 76 IfNotEqualExpression
77 EndIfNotEqualBraced 77 EndIfNotEqualBraced
78 78
79 AutoEscapeBlock 79 AutoEscapeBlock
80 AutoEscapeBraced 80 AutoEscapeBraced
81 EndAutoEscapeBraced 81 EndAutoEscapeBraced
82 82
83 Value 83 Value
84 Variable 84 Variable
85 Filter 85 Filter
86 86
87 LoadTag 87 LoadTag
88 LoadNames 88 LoadNames
89 89
90 CustomTag 90 CustomTag
91 Args 91 Args
92 92
93 CallTag 93 CallTag
94 CallWithTag. 94 CallWithTag.
95 95
96 Terminals 96 Terminals
97 autoescape_keyword 97 autoescape_keyword
98 block_keyword 98 block_keyword
99 call_keyword 99 call_keyword
100 close_tag 100 close_tag
101 close_var 101 close_var
102 comment_keyword 102 comment_keyword
103 colon 103 colon
104 comma 104 comma
105 cycle_keyword 105 cycle_keyword
106 dot 106 dot
107 else_keyword 107 else_keyword
108 endautoescape_keyword 108 endautoescape_keyword
109 endblock_keyword 109 endblock_keyword
110 endcomment_keyword 110 endcomment_keyword
111 endfor_keyword 111 endfor_keyword
112 endif_keyword 112 endif_keyword
113 endifequal_keyword 113 endifequal_keyword
114 endifnotequal_keyword 114 endifnotequal_keyword
115 equal 115 equal
116 extends_keyword 116 extends_keyword
117 for_keyword 117 for_keyword
118 identifier 118 identifier
119 if_keyword 119 if_keyword
120 ifequal_keyword 120 ifequal_keyword
121 ifnotequal_keyword 121 ifnotequal_keyword
122 in_keyword 122 in_keyword
123 include_keyword 123 include_keyword
124 load_keyword 124 load_keyword
125 not_keyword 125 not_keyword
126 now_keyword 126 now_keyword
127 number_literal 127 number_literal
128 open_tag 128 open_tag
129 open_var 129 open_var
130 pipe 130 pipe
131 string_literal 131 string_literal
132 text 132 text
133 with_keyword. 133 with_keyword.
134 134
135 Rootsymbol 135 Rootsymbol
136 Elements. 136 Elements.
137 137
138 Elements -> '$empty' : []. 138 Elements -> '$empty' : [].
139 Elements -> Elements text : '$1' ++ ['$2']. 139 Elements -> Elements text : '$1' ++ ['$2'].
140 Elements -> Elements ValueBraced : '$1' ++ ['$2']. 140 Elements -> Elements ValueBraced : '$1' ++ ['$2'].
141 Elements -> Elements ExtendsTag : '$1' ++ ['$2']. 141 Elements -> Elements ExtendsTag : '$1' ++ ['$2'].
142 Elements -> Elements IncludeTag : '$1' ++ ['$2']. 142 Elements -> Elements IncludeTag : '$1' ++ ['$2'].
143 Elements -> Elements NowTag : '$1' ++ ['$2']. 143 Elements -> Elements NowTag : '$1' ++ ['$2'].
144 Elements -> Elements LoadTag : '$1' ++ ['$2']. 144 Elements -> Elements LoadTag : '$1' ++ ['$2'].
145 Elements -> Elements CycleTag : '$1' ++ ['$2']. 145 Elements -> Elements CycleTag : '$1' ++ ['$2'].
146 Elements -> Elements BlockBlock : '$1' ++ ['$2']. 146 Elements -> Elements BlockBlock : '$1' ++ ['$2'].
147 Elements -> Elements ForBlock : '$1' ++ ['$2']. 147 Elements -> Elements ForBlock : '$1' ++ ['$2'].
148 Elements -> Elements IfBlock : '$1' ++ ['$2']. 148 Elements -> Elements IfBlock : '$1' ++ ['$2'].
149 Elements -> Elements IfEqualBlock : '$1' ++ ['$2']. 149 Elements -> Elements IfEqualBlock : '$1' ++ ['$2'].
150 Elements -> Elements IfNotEqualBlock : '$1' ++ ['$2']. 150 Elements -> Elements IfNotEqualBlock : '$1' ++ ['$2'].
151 Elements -> Elements AutoEscapeBlock : '$1' ++ ['$2']. 151 Elements -> Elements AutoEscapeBlock : '$1' ++ ['$2'].
152 Elements -> Elements CommentBlock : '$1' ++ ['$2']. 152 Elements -> Elements CommentBlock : '$1' ++ ['$2'].
153 Elements -> Elements CustomTag : '$1' ++ ['$2']. 153 Elements -> Elements CustomTag : '$1' ++ ['$2'].
154 Elements -> Elements CallTag : '$1' ++ ['$2']. 154 Elements -> Elements CallTag : '$1' ++ ['$2'].
155 Elements -> Elements CallWithTag : '$1' ++ ['$2']. 155 Elements -> Elements CallWithTag : '$1' ++ ['$2'].
156 156
157 ValueBraced -> open_var Value close_var : '$2'. 157 ValueBraced -> open_var Value close_var : '$2'.
158 158
159 Value -> Value pipe Filter : {apply_filter, '$1', '$3'}. 159 Value -> Value pipe Filter : {apply_filter, '$1', '$3'}.
160 Value -> Variable : '$1'. 160 Value -> Variable : '$1'.
161 Value -> Literal : '$1'. 161 Value -> Literal : '$1'.
162 162
163 Variable -> identifier : {variable, '$1'}. 163 Variable -> identifier : {variable, '$1'}.
164 Variable -> Value dot identifier : {attribute, {'$3', '$1'}}. 164 Variable -> Value dot identifier : {attribute, {'$3', '$1'}}.
165 165
166 ExtendsTag -> open_tag extends_keyword string_literal close_tag : {extends, '$3'}. 166 ExtendsTag -> open_tag extends_keyword string_literal close_tag : {extends, '$3'}.
167 IncludeTag -> open_tag include_keyword string_literal close_tag : {include, '$3'}. 167 IncludeTag -> open_tag include_keyword string_literal close_tag : {include, '$3'}.
168 NowTag -> open_tag now_keyword string_literal close_tag : {date, now, '$3'}. 168 NowTag -> open_tag now_keyword string_literal close_tag : {date, now, '$3'}.
169 169
170 LoadTag -> open_tag load_keyword LoadNames close_tag : {load, '$3'}. 170 LoadTag -> open_tag load_keyword LoadNames close_tag : {load, '$3'}.
171 LoadNames -> identifier : ['$1']. 171 LoadNames -> identifier : ['$1'].
172 LoadNames -> LoadNames identifier : '$1' ++ ['$2']. 172 LoadNames -> LoadNames identifier : '$1' ++ ['$2'].
173 173
174 BlockBlock -> BlockBraced Elements EndBlockBraced : {block, '$1', '$2'}. 174 BlockBlock -> BlockBraced Elements EndBlockBraced : {block, '$1', '$2'}.
175 BlockBraced -> open_tag block_keyword identifier close_tag : '$3'. 175 BlockBraced -> open_tag block_keyword identifier close_tag : '$3'.
176 EndBlockBraced -> open_tag endblock_keyword close_tag. 176 EndBlockBraced -> open_tag endblock_keyword close_tag.
177 177
178 CommentBlock -> CommentBraced Elements EndCommentBraced : {comment, '$2'}. 178 CommentBlock -> CommentBraced Elements EndCommentBraced : {comment, '$2'}.
179 CommentBraced -> open_tag comment_keyword close_tag. 179 CommentBraced -> open_tag comment_keyword close_tag.
180 EndCommentBraced -> open_tag endcomment_keyword close_tag. 180 EndCommentBraced -> open_tag endcomment_keyword close_tag.
181 181
182 CycleTag -> open_tag cycle_keyword CycleNamesCompat close_tag : {cycle_compat, '$3'}. 182 CycleTag -> open_tag cycle_keyword CycleNamesCompat close_tag : {cycle_compat, '$3'}.
183 CycleTag -> open_tag cycle_keyword CycleNames close_tag : {cycle, '$3'}. 183 CycleTag -> open_tag cycle_keyword CycleNames close_tag : {cycle, '$3'}.
184 184
185 CycleNames -> Value : ['$1']. 185 CycleNames -> Value : ['$1'].
186 CycleNames -> CycleNames Value : '$1' ++ ['$2']. 186 CycleNames -> CycleNames Value : '$1' ++ ['$2'].
187 187
188 CycleNamesCompat -> identifier comma : ['$1']. 188 CycleNamesCompat -> identifier comma : ['$1'].
189 CycleNamesCompat -> CycleNamesCompat identifier comma : '$1' ++ ['$2']. 189 CycleNamesCompat -> CycleNamesCompat identifier comma : '$1' ++ ['$2'].
190 CycleNamesCompat -> CycleNamesCompat identifier : '$1' ++ ['$2']. 190 CycleNamesCompat -> CycleNamesCompat identifier : '$1' ++ ['$2'].
191 191
192 ForBlock -> ForBraced Elements EndForBraced : {for, '$1', '$2'}. 192 ForBlock -> ForBraced Elements EndForBraced : {for, '$1', '$2'}.
193 ForBraced -> open_tag for_keyword ForExpression close_tag : '$3'. 193 ForBraced -> open_tag for_keyword ForExpression close_tag : '$3'.
194 EndForBraced -> open_tag endfor_keyword close_tag. 194 EndForBraced -> open_tag endfor_keyword close_tag.
195 ForExpression -> ForGroup in_keyword Variable : {'in', '$1', '$3'}. 195 ForExpression -> ForGroup in_keyword Variable : {'in', '$1', '$3'}.
196 ForGroup -> identifier : ['$1']. 196 ForGroup -> identifier : ['$1'].
197 ForGroup -> ForGroup comma identifier : '$1' ++ ['$3']. 197 ForGroup -> ForGroup comma identifier : '$1' ++ ['$3'].
198 198
199 IfBlock -> IfBraced Elements ElseBraced Elements EndIfBraced : {ifelse, '$1', '$2', '$4'}. 199 IfBlock -> IfBraced Elements ElseBraced Elements EndIfBraced : {ifelse, '$1', '$2', '$4'}.
200 IfBlock -> IfBraced Elements EndIfBraced : {'if', '$1', '$2'}. 200 IfBlock -> IfBraced Elements EndIfBraced : {'if', '$1', '$2'}.
201 IfBraced -> open_tag if_keyword IfExpression close_tag : '$3'. 201 IfBraced -> open_tag if_keyword IfExpression close_tag : '$3'.
202 IfExpression -> not_keyword IfExpression : {'not', '$2'}. 202 IfExpression -> not_keyword Value : {'not', '$2'}.
203 IfExpression -> Value in_keyword Value : {'in', '$1', '$3'}.
204 IfExpression -> Value not_keyword in_keyword Value : {'not', {'in', '$1', '$4'}}.
203 IfExpression -> Value : '$1'. 205 IfExpression -> Value : '$1'.
204 206
205 ElseBraced -> open_tag else_keyword close_tag. 207 ElseBraced -> open_tag else_keyword close_tag.
206 EndIfBraced -> open_tag endif_keyword close_tag. 208 EndIfBraced -> open_tag endif_keyword close_tag.
207 209
208 IfEqualBlock -> IfEqualBraced Elements ElseBraced Elements EndIfEqualBraced : {ifequalelse, '$1', '$2', '$4'}. 210 IfEqualBlock -> IfEqualBraced Elements ElseBraced Elements EndIfEqualBraced : {ifequalelse, '$1', '$2', '$4'}.
209 IfEqualBlock -> IfEqualBraced Elements EndIfEqualBraced : {ifequal, '$1', '$2'}. 211 IfEqualBlock -> IfEqualBraced Elements EndIfEqualBraced : {ifequal, '$1', '$2'}.
210 IfEqualBraced -> open_tag ifequal_keyword IfEqualExpression Value close_tag : ['$3', '$4']. 212 IfEqualBraced -> open_tag ifequal_keyword IfEqualExpression Value close_tag : ['$3', '$4'].
211 IfEqualExpression -> Value : '$1'. 213 IfEqualExpression -> Value : '$1'.
212 EndIfEqualBraced -> open_tag endifequal_keyword close_tag. 214 EndIfEqualBraced -> open_tag endifequal_keyword close_tag.
213 215
214 IfNotEqualBlock -> IfNotEqualBraced Elements ElseBraced Elements EndIfNotEqualBraced : {ifnotequalelse, '$1', '$2', '$4'}. 216 IfNotEqualBlock -> IfNotEqualBraced Elements ElseBraced Elements EndIfNotEqualBraced : {ifnotequalelse, '$1', '$2', '$4'}.
215 IfNotEqualBlock -> IfNotEqualBraced Elements EndIfNotEqualBraced : {ifnotequal, '$1', '$2'}. 217 IfNotEqualBlock -> IfNotEqualBraced Elements EndIfNotEqualBraced : {ifnotequal, '$1', '$2'}.
216 IfNotEqualBraced -> open_tag ifnotequal_keyword IfNotEqualExpression Value close_tag : ['$3', '$4']. 218 IfNotEqualBraced -> open_tag ifnotequal_keyword IfNotEqualExpression Value close_tag : ['$3', '$4'].
217 IfNotEqualExpression -> Value : '$1'. 219 IfNotEqualExpression -> Value : '$1'.
218 EndIfNotEqualBraced -> open_tag endifnotequal_keyword close_tag. 220 EndIfNotEqualBraced -> open_tag endifnotequal_keyword close_tag.
219 221
220 AutoEscapeBlock -> AutoEscapeBraced Elements EndAutoEscapeBraced : {autoescape, '$1', '$2'}. 222 AutoEscapeBlock -> AutoEscapeBraced Elements EndAutoEscapeBraced : {autoescape, '$1', '$2'}.
221 AutoEscapeBraced -> open_tag autoescape_keyword identifier close_tag : '$3'. 223 AutoEscapeBraced -> open_tag autoescape_keyword identifier close_tag : '$3'.
222 EndAutoEscapeBraced -> open_tag endautoescape_keyword close_tag. 224 EndAutoEscapeBraced -> open_tag endautoescape_keyword close_tag.
223 225
224 Filter -> identifier : ['$1']. 226 Filter -> identifier : ['$1'].
225 Filter -> identifier colon Literal : ['$1', '$3']. 227 Filter -> identifier colon Literal : ['$1', '$3'].
226 228
227 Literal -> string_literal : '$1'. 229 Literal -> string_literal : '$1'.
228 Literal -> number_literal : '$1'. 230 Literal -> number_literal : '$1'.
229 231
230 CustomTag -> open_tag identifier Args close_tag : {tag, '$2', '$3'}. 232 CustomTag -> open_tag identifier Args close_tag : {tag, '$2', '$3'}.
231 233
232 Args -> '$empty' : []. 234 Args -> '$empty' : [].
233 Args -> Args identifier equal Value : '$1' ++ [{'$2', '$4'}]. 235 Args -> Args identifier equal Value : '$1' ++ [{'$2', '$4'}].
234 236
235 CallTag -> open_tag call_keyword identifier close_tag : {call, '$3'}. 237 CallTag -> open_tag call_keyword identifier close_tag : {call, '$3'}.
236 CallWithTag -> open_tag call_keyword identifier with_keyword Value close_tag : {call, '$3', '$5'}. 238 CallWithTag -> open_tag call_keyword identifier with_keyword Value close_tag : {call, '$3', '$5'}.
Powered by Google Project Hosting