@@ -2,7 +2,7 @@ import { P } from '@lemons_dev/parsinom/lib/ParsiNOM';
22import { P_UTILS } from '@lemons_dev/parsinom/lib/ParserUtils' ;
33import { Parser } from '@lemons_dev/parsinom/lib/Parser' ;
44import {
5- markerToResultNode ,
5+ createResultNode ,
66 ParsingResultNode ,
77 PartialUnvalidatedInputFieldDeclaration ,
88 UnvalidatedBindTargetDeclaration ,
@@ -54,18 +54,18 @@ const filePath = P.noneOf('[]#^|:?')
5454 . map ( x => x . join ( '' ) )
5555 . describe ( 'file path' ) ;
5656
57- const bracketMetadataPathPart : Parser < ParsingResultNode > = P . or ( P_UTILS . digits ( ) , createStr ( '"' ) ) . wrap ( P . string ( '[' ) , P . string ( ']' ) ) . node ( markerToResultNode ) ;
57+ const bracketMetadataPathPart : Parser < ParsingResultNode > = P . or ( P_UTILS . digits ( ) , createStr ( '"' ) ) . wrap ( P . string ( '[' ) , P . string ( ']' ) ) . node ( createResultNode ) ;
5858
5959const firstMetadataPathPart : Parser < ParsingResultNode [ ] > = P . or (
6060 bracketMetadataPathPart . atLeast ( 1 ) ,
61- P . sequenceMap ( ( ident , brackets ) => [ ident , ...brackets ] , ident . node ( markerToResultNode ) , bracketMetadataPathPart . many ( ) )
61+ P . sequenceMap ( ( ident , brackets ) => [ ident , ...brackets ] , ident . node ( createResultNode ) , bracketMetadataPathPart . many ( ) )
6262) ;
6363
6464const metadataPathPart : Parser < ParsingResultNode [ ] > = P . sequenceMap (
6565 ( ident , brackets ) => {
6666 return [ ident , ...brackets ] ;
6767 } ,
68- ident . node ( markerToResultNode ) ,
68+ ident . node ( createResultNode ) ,
6969 bracketMetadataPathPart . many ( )
7070) ;
7171
@@ -91,11 +91,11 @@ export const BIND_TARGET: Parser<UnvalidatedBindTargetDeclaration> = P.sequenceM
9191 } ;
9292 }
9393 } ,
94- P . sequence ( filePath . node ( markerToResultNode ) , P . string ( '#' ) ) . optional ( ) ,
94+ P . sequence ( filePath . node ( createResultNode ) , P . string ( '#' ) ) . optional ( ) ,
9595 metadataPath
9696) ;
9797
98- const inputFieldArgumentValue : Parser < ParsingResultNode [ ] > = P . separateBy ( value . node ( markerToResultNode ) , P . string ( ',' ) . trim ( P_UTILS . optionalWhitespace ( ) ) ) ;
98+ const inputFieldArgumentValue : Parser < ParsingResultNode [ ] > = P . separateBy ( value . node ( createResultNode ) , P . string ( ',' ) . trim ( P_UTILS . optionalWhitespace ( ) ) ) ;
9999
100100const inputFieldArgument : Parser < UnvalidatedInputFieldArgument > = P . sequenceMap (
101101 ( name , value ) : UnvalidatedInputFieldArgument => {
@@ -104,7 +104,7 @@ const inputFieldArgument: Parser<UnvalidatedInputFieldArgument> = P.sequenceMap(
104104 value : value ,
105105 } ;
106106 } ,
107- ident . node ( markerToResultNode ) ,
107+ ident . node ( createResultNode ) ,
108108 inputFieldArgumentValue
109109 . trim ( P_UTILS . optionalWhitespace ( ) )
110110 . wrap ( P . string ( '(' ) , P . string ( ')' ) )
@@ -116,14 +116,30 @@ const inputFieldArguments: Parser<UnvalidatedInputFieldArgument[]> = P.separateB
116116export const INPUT_FIELD_DECLARATION : Parser < PartialUnvalidatedInputFieldDeclaration > = P . sequenceMap (
117117 ( type , args , b ) => {
118118 const bindTarget = b === undefined ? undefined : b [ 1 ] ;
119- console . warn ( type , args , b ) ;
120119 return {
121120 inputFieldType : type ,
122121 arguments : args ,
123122 bindTarget : bindTarget ,
124123 } ;
125124 } ,
126- ident . node ( markerToResultNode ) . describe ( 'input field type' ) ,
125+ ident . node ( createResultNode ) . describe ( 'input field type' ) ,
126+ inputFieldArguments
127+ . trim ( P_UTILS . optionalWhitespace ( ) )
128+ . wrap ( P . string ( '(' ) , P . string ( ')' ) )
129+ . optional ( [ ] as UnvalidatedInputFieldArgument [ ] ) ,
130+ P . sequence ( P . string ( ':' ) , BIND_TARGET ) . optional ( )
131+ ) ;
132+
133+ export const PARTIAL_INPUT_FIELD_DECLARATION : Parser < PartialUnvalidatedInputFieldDeclaration > = P . sequenceMap (
134+ ( type , args , b ) => {
135+ const bindTarget = b === undefined ? undefined : b [ 1 ] ;
136+ return {
137+ inputFieldType : type ,
138+ arguments : args ,
139+ bindTarget : bindTarget ,
140+ } ;
141+ } ,
142+ ident . node ( createResultNode ) . optional ( ) . describe ( 'input field type' ) ,
127143 inputFieldArguments
128144 . trim ( P_UTILS . optionalWhitespace ( ) )
129145 . wrap ( P . string ( '(' ) , P . string ( ')' ) )
@@ -134,13 +150,13 @@ export const INPUT_FIELD_DECLARATION: Parser<PartialUnvalidatedInputFieldDeclara
134150export const INPUT_FIELD_FULL_DECLARATION : Parser < PartialUnvalidatedInputFieldDeclaration > = P . or (
135151 P . sequenceMap (
136152 ( _1 , templateName , _2 , declaration , _3 ) => {
137- console . warn ( 'first' ) ;
153+ declaration . templateName = templateName ;
138154 return declaration ;
139155 } ,
140156 P . string ( 'INPUT' ) ,
141- P . sequenceMap ( ( _1 , templateName , _2 ) => templateName , P . string ( '[' ) , spaceIdent . describe ( 'template name' ) , P . string ( ']' ) ) ,
157+ P . sequenceMap ( ( _1 , templateName , _2 ) => templateName , P . string ( '[' ) , spaceIdent . node ( createResultNode ) . describe ( 'template name' ) , P . string ( ']' ) ) ,
142158 P . string ( '[' ) ,
143- INPUT_FIELD_DECLARATION ,
159+ PARTIAL_INPUT_FIELD_DECLARATION ,
144160 P . string ( ']' ) ,
145161 P_UTILS . eof ( )
146162 ) ,
@@ -157,23 +173,6 @@ export const INPUT_FIELD_FULL_DECLARATION: Parser<PartialUnvalidatedInputFieldDe
157173 )
158174) ;
159175
160- export const PARTIAL_INPUT_FIELD_DECLARATION : Parser < PartialUnvalidatedInputFieldDeclaration > = P . sequenceMap (
161- ( type , args , b ) => {
162- const bindTarget = b === undefined ? undefined : b [ 1 ] ;
163- return {
164- inputFieldType : type ,
165- arguments : args ,
166- bindTarget : bindTarget ,
167- } ;
168- } ,
169- ident . node ( markerToResultNode ) . describe ( 'input field type' ) ,
170- inputFieldArguments
171- . trim ( P_UTILS . optionalWhitespace ( ) )
172- . wrap ( P . string ( '(' ) , P . string ( ')' ) )
173- . optional ( [ ] as UnvalidatedInputFieldArgument [ ] ) ,
174- P . sequence ( P . string ( ':' ) , BIND_TARGET ) . optional ( )
175- ) ;
176-
177176export const TEMPLATE_INPUT_FIELD_FULL_DECLARATION : Parser < PartialUnvalidatedInputFieldDeclaration > = P . sequenceMap (
178177 ( _1 , _2 , declaration , _3 ) => {
179178 return declaration ;
0 commit comments