55 body is defined as anything that matches with the part 0 or more times
66---------------------------------------------------------------------------------------------------------------------------------------*/
77body
8- = p :part * { return [" body" ].concat (p) }
8+ = p :part * { return [" body" ].concat (p). concat ([[ ' line ' , line], [ ' col ' , column]]) }
99
1010/*-------------------------------------------------------------------------------------------------------------------------------------
1111 part is defined as anything that matches with comment or section or partial or special or reference or buffer
1919---------------------------------------------------------------------------------------------------------------------------------------*/
2020section "section"
2121 = t :sec_tag_start ws * rd b :body e :bodies n :end_tag ? & {if ( (! n) || (t[1 ].text !== n .text ) ) { throw new Error (" Expected end tag for " + t[1 ].text + " but it was not found. At line : " + line+ " , column : " + column)} return true ;}
22- { e .push ([" param" , [" literal" , " block" ], b]); t .push (e); return t }
22+ { e .push ([" param" , [" literal" , " block" ], b]); t .push (e); return t . concat ([[ ' line ' , line], [ ' col ' , column]]) }
2323 / t :sec_tag_start ws * "/" rd
24- { t .push ([" bodies" ]); return t }
24+ { t .push ([" bodies" ]); return t . concat ([[ ' line ' , line], [ ' col ' , column]]) }
2525
2626/*-------------------------------------------------------------------------------------------------------------------------------------
2727 sec_tag_start is defined as matching an opening brace followed by one of #?^<+@% plus identifier plus context plus param
@@ -65,15 +65,15 @@ bodies "bodies"
6565---------------------------------------------------------------------------------------------------------------------------------------*/
6666reference "reference"
6767 = ld n :identifier f :filters rd
68- { return [" reference" , n, f] }
68+ { return [" reference" , n, f]. concat ([[ ' line ' , line], [ ' col ' , column]]) }
6969
7070/*-------------------------------------------------------------------------------------------------------------------------------------
7171 partial is defined as matching a opening brace followed by a > plus anything that matches with key or inline plus
7272 context followed by slash and closing brace
7373---------------------------------------------------------------------------------------------------------------------------------------*/
7474partial "partial"
7575 = ld s :(">" / "+" ) ws * n :(k :key {return [" literal" , k]} / inline ) c :context p :params ws * "/" rd
76- { var key = (s === " >" )? " partial" : s; return [key, n, c, p] }
76+ { var key = (s === " >" )? " partial" : s; return [key, n, c, p]. concat ([[ ' line ' , line], [ ' col ' , column]]) }
7777
7878/*-------------------------------------------------------------------------------------------------------------------------------------
7979 filters is defined as matching a pipe character followed by anything that matches the key
@@ -87,7 +87,7 @@ filters "filters"
8787---------------------------------------------------------------------------------------------------------------------------------------*/
8888special "special"
8989 = ld "~" k :key rd
90- { return [" special" , k] }
90+ { return [" special" , k]. concat ([[ ' line ' , line], [ ' col ' , column]]) }
9191
9292/*-------------------------------------------------------------------------------------------------------------------------------------
9393 identifier is defined as matching a path or key
@@ -110,18 +110,18 @@ integer "integer"
110110---------------------------------------------------------------------------------------------------------------------------------------*/
111111path "path"
112112 = k :key ? d :(array_part / array )+ {
113- d = d[0 ];
113+ d = d[0 ];
114114 if (k && d) {
115115 d .unshift (k);
116- return [false , d];
116+ return [false , d]. concat ([[ ' line ' , line], [ ' col ' , column]]) ;
117117 }
118- return [true , d];
118+ return [true , d]. concat ([[ ' line ' , line], [ ' col ' , column]]) ;
119119 }
120120 / "." d :(array_part / array )* {
121121 if (d .length > 0 ) {
122- return [true , d[0 ]];
122+ return [true , d[0 ]]. concat ([[ ' line ' , line], [ ' col ' , column]]) ;
123123 }
124- return [true , []]
124+ return [true , []]. concat ([[ ' line ' , line], [ ' col ' , column]]);
125125 }
126126
127127/*-------------------------------------------------------------------------------------------------------------------------------------
@@ -142,9 +142,9 @@ array_part "array_part"
142142 double quotes plus inline_part followed by the closing double quotes
143143---------------------------------------------------------------------------------------------------------------------------------------*/
144144inline "inline"
145- = '"' '"' { return [" literal" , " " ] }
146- / '"' l :literal '"' { return [" literal" , l] }
147- / '"' p :inline_part + '"' { return [" body" ].concat (p) }
145+ = '"' '"' { return [" literal" , " " ]. concat ([[ ' line ' , line], [ ' col ' , column]]) }
146+ / '"' l :literal '"' { return [" literal" , l]. concat ([[ ' line ' , line], [ ' col ' , column]]) }
147+ / '"' p :inline_part + '"' { return [" body" ].concat (p). concat ([[ ' line ' , line], [ ' col ' , column]]) }
148148
149149/*-------------------------------------------------------------------------------------------------------------------------------------
150150 inline_part is defined as matching a special or reference or literal
@@ -154,9 +154,9 @@ inline_part
154154
155155buffer "buffer"
156156 = e :eol w :ws *
157- { return [" format" , e, w .join (' ' )] }
157+ { return [" format" , e, w .join (' ' )]. concat ([[ ' line ' , line], [ ' col ' , column]]) }
158158 / b :(! tag ! comment ! eol c :. {return c})+
159- { return [" buffer" , b .join (' ' )] }
159+ { return [" buffer" , b .join (' ' )]. concat ([[ ' line ' , line], [ ' col ' , column]]) }
160160
161161/*-------------------------------------------------------------------------------------------------------------------------------------
162162 literal is defined as matching esc or any character except the double quotes and it cannot be a tag
170170
171171comment "comment"
172172 = "{!" c :(! "!}" c :. {return c})* "!}"
173- { return [" comment" , c .join (' ' )] }
173+ { return [" comment" , c .join (' ' )]. concat ([[ ' line ' , line], [ ' col ' , column]]) }
174174
175175/*-------------------------------------------------------------------------------------------------------------------------------------
176176 tag is defined as matching an opening brace plus any of #?^><+%:@/~% plus 0 or more whitespaces plus any character or characters that
0 commit comments