@@ -54,30 +54,19 @@ const filePath = P.noneOf('[]#^|:?')
5454 . map ( x => x . join ( '' ) )
5555 . describe ( 'file path' ) ;
5656
57- const bracketMetadataPath : Parser < ParsingResultNode [ ] > = P . or ( P_UTILS . digits ( ) , createStr ( '"' ) )
58- . wrap ( P . string ( '[' ) , P . string ( ']' ) )
59- . mark ( )
60- . map ( x => markerToResultNode ( x ) )
61- . many ( ) ;
57+ const bracketMetadataPathPart : Parser < ParsingResultNode > = P . or ( P_UTILS . digits ( ) , createStr ( '"' ) ) . wrap ( P . string ( '[' ) , P . string ( ']' ) ) . node ( markerToResultNode ) ;
6258
63- const firstMetadataPathPart : Parser < ParsingResultNode [ ] > = P . sequenceMap (
64- ( ident , brackets ) => {
65- if ( ident === undefined ) {
66- return brackets ;
67- } else {
68- return [ markerToResultNode ( ident ) , ...brackets ] ;
69- }
70- } ,
71- ident . mark ( ) . optional ( ) ,
72- bracketMetadataPath
59+ const firstMetadataPathPart : Parser < ParsingResultNode [ ] > = P . or (
60+ bracketMetadataPathPart . atLeast ( 1 ) ,
61+ P . sequenceMap ( ( ident , brackets ) => [ ident , ...brackets ] , ident . node ( markerToResultNode ) , bracketMetadataPathPart . many ( ) )
7362) ;
7463
7564const metadataPathPart : Parser < ParsingResultNode [ ] > = P . sequenceMap (
7665 ( ident , brackets ) => {
77- return [ markerToResultNode ( ident ) , ...brackets ] ;
66+ return [ ident , ...brackets ] ;
7867 } ,
79- ident . mark ( ) ,
80- bracketMetadataPath
68+ ident . node ( markerToResultNode ) ,
69+ bracketMetadataPathPart . many ( )
8170) ;
8271
8372const metadataPath : Parser < ParsingResultNode [ ] > = P . sequenceMap (
@@ -97,28 +86,25 @@ export const BIND_TARGET: Parser<UnvalidatedBindTargetDeclaration> = P.sequenceM
9786 } ;
9887 } else {
9988 return {
100- file : markerToResultNode ( a [ 0 ] ) ,
89+ file : a [ 0 ] ,
10190 path : b ,
10291 } ;
10392 }
10493 } ,
105- P . sequence ( filePath . mark ( ) , P . string ( '#' ) ) . optional ( ) ,
94+ P . sequence ( filePath . node ( markerToResultNode ) , P . string ( '#' ) ) . optional ( ) ,
10695 metadataPath
10796) ;
10897
109- const inputFieldArgumentValue : Parser < ParsingResultNode [ ] > = P . separateBy (
110- value . mark ( ) . map ( x => markerToResultNode ( x ) ) ,
111- P . string ( ',' ) . trim ( P_UTILS . optionalWhitespace ( ) )
112- ) ;
98+ const inputFieldArgumentValue : Parser < ParsingResultNode [ ] > = P . separateBy ( value . node ( markerToResultNode ) , P . string ( ',' ) . trim ( P_UTILS . optionalWhitespace ( ) ) ) ;
11399
114100const inputFieldArgument : Parser < UnvalidatedInputFieldArgument > = P . sequenceMap (
115101 ( name , value ) : UnvalidatedInputFieldArgument => {
116102 return {
117- name : markerToResultNode ( name ) ,
103+ name : name ,
118104 value : value ,
119105 } ;
120106 } ,
121- ident . mark ( ) ,
107+ ident . node ( markerToResultNode ) ,
122108 inputFieldArgumentValue
123109 . trim ( P_UTILS . optionalWhitespace ( ) )
124110 . wrap ( P . string ( '(' ) , P . string ( ')' ) )
@@ -130,13 +116,14 @@ const inputFieldArguments: Parser<UnvalidatedInputFieldArgument[]> = P.separateB
130116export const INPUT_FIELD_DECLARATION : Parser < PartialUnvalidatedInputFieldDeclaration > = P . sequenceMap (
131117 ( type , args , b ) => {
132118 const bindTarget = b === undefined ? undefined : b [ 1 ] ;
119+ console . warn ( type , args , b ) ;
133120 return {
134- inputFieldType : markerToResultNode ( type ) ,
121+ inputFieldType : type ,
135122 arguments : args ,
136123 bindTarget : bindTarget ,
137124 } ;
138125 } ,
139- ident . mark ( ) . describe ( 'input field type' ) ,
126+ ident . node ( markerToResultNode ) . describe ( 'input field type' ) ,
140127 inputFieldArguments
141128 . trim ( P_UTILS . optionalWhitespace ( ) )
142129 . wrap ( P . string ( '(' ) , P . string ( ')' ) )
@@ -147,35 +134,39 @@ export const INPUT_FIELD_DECLARATION: Parser<PartialUnvalidatedInputFieldDeclara
147134export const INPUT_FIELD_FULL_DECLARATION : Parser < PartialUnvalidatedInputFieldDeclaration > = P . or (
148135 P . sequenceMap (
149136 ( _1 , templateName , _2 , declaration , _3 ) => {
137+ console . warn ( 'first' ) ;
150138 return declaration ;
151139 } ,
152140 P . string ( 'INPUT' ) ,
153- P . sequenceMap ( ( _1 , templateName , _2 ) => templateName , P . string ( '[' ) , spaceIdent , P . string ( ']' ) ) ,
141+ P . sequenceMap ( ( _1 , templateName , _2 ) => templateName , P . string ( '[' ) , spaceIdent . describe ( 'template name' ) , P . string ( ']' ) ) ,
154142 P . string ( '[' ) ,
155143 INPUT_FIELD_DECLARATION ,
156- P . string ( ']' )
144+ P . string ( ']' ) ,
145+ P_UTILS . eof ( )
157146 ) ,
158147 P . sequenceMap (
159148 ( _1 , _2 , declaration , _3 ) => {
149+ console . warn ( 'second' ) ;
160150 return declaration ;
161151 } ,
162152 P . string ( 'INPUT' ) ,
163153 P . string ( '[' ) ,
164154 INPUT_FIELD_DECLARATION ,
165- P . string ( ']' )
155+ P . string ( ']' ) ,
156+ P_UTILS . eof ( )
166157 )
167158) ;
168159
169160export const PARTIAL_INPUT_FIELD_DECLARATION : Parser < PartialUnvalidatedInputFieldDeclaration > = P . sequenceMap (
170161 ( type , args , b ) => {
171162 const bindTarget = b === undefined ? undefined : b [ 1 ] ;
172163 return {
173- inputFieldType : markerToResultNode ( type ) ,
164+ inputFieldType : type ,
174165 arguments : args ,
175166 bindTarget : bindTarget ,
176167 } ;
177168 } ,
178- ident . mark ( ) . describe ( 'input field type' ) ,
169+ ident . node ( markerToResultNode ) . describe ( 'input field type' ) ,
179170 inputFieldArguments
180171 . trim ( P_UTILS . optionalWhitespace ( ) )
181172 . wrap ( P . string ( '(' ) , P . string ( ')' ) )
@@ -190,7 +181,8 @@ export const TEMPLATE_INPUT_FIELD_FULL_DECLARATION: Parser<PartialUnvalidatedInp
190181 P . string ( 'INPUT' ) ,
191182 P . string ( '[' ) ,
192183 PARTIAL_INPUT_FIELD_DECLARATION ,
193- P . string ( ']' )
184+ P . string ( ']' ) ,
185+ P_UTILS . eof ( )
194186) ;
195187
196188const viewFieldMathJS = P . noneOf ( '{}[]' )
@@ -213,5 +205,6 @@ export const VIEW_FIELD_FULL_DECLARATION: Parser<(string | UnvalidatedBindTarget
213205 P . string ( 'VIEW' ) ,
214206 P . string ( '[' ) ,
215207 VIEW_FIELD_DECLARATION ,
216- P . string ( ']' )
208+ P . string ( ']' ) ,
209+ P_UTILS . eof ( )
217210) ;
0 commit comments