Avoid direct references to sexpr in statements
This allows us to avoid creating unnecessary AST nodes and avoids things like isHelper. Side effect of these changes is that @data functions can now have data parameters passed to them.
This commit is contained in:
+18
-19
@@ -30,7 +30,7 @@ rawBlock
|
||||
;
|
||||
|
||||
openRawBlock
|
||||
: OPEN_RAW_BLOCK sexpr CLOSE_RAW_BLOCK -> { sexpr: $2 }
|
||||
: OPEN_RAW_BLOCK helperName param* hash? CLOSE_RAW_BLOCK -> { path: $2, params: $3, hash: $4 }
|
||||
;
|
||||
|
||||
block
|
||||
@@ -39,15 +39,15 @@ block
|
||||
;
|
||||
|
||||
openBlock
|
||||
: OPEN_BLOCK sexpr blockParams? CLOSE -> { sexpr: $2, blockParams: $3, strip: yy.stripFlags($1, $4) }
|
||||
: OPEN_BLOCK helperName param* hash? blockParams? CLOSE -> { path: $2, params: $3, hash: $4, blockParams: $5, strip: yy.stripFlags($1, $6) }
|
||||
;
|
||||
|
||||
openInverse
|
||||
: OPEN_INVERSE sexpr blockParams? CLOSE -> { sexpr: $2, blockParams: $3, strip: yy.stripFlags($1, $4) }
|
||||
: OPEN_INVERSE helperName param* hash? blockParams? CLOSE -> { path: $2, params: $3, hash: $4, blockParams: $5, strip: yy.stripFlags($1, $6) }
|
||||
;
|
||||
|
||||
openInverseChain
|
||||
: OPEN_INVERSE_CHAIN sexpr blockParams? CLOSE -> { sexpr: $2, blockParams: $3, strip: yy.stripFlags($1, $4) }
|
||||
: OPEN_INVERSE_CHAIN helperName param* hash? blockParams? CLOSE -> { path: $2, params: $3, hash: $4, blockParams: $5, strip: yy.stripFlags($1, $6) }
|
||||
;
|
||||
|
||||
inverseAndProgram
|
||||
@@ -72,23 +72,12 @@ closeBlock
|
||||
mustache
|
||||
// Parsing out the '&' escape token at AST level saves ~500 bytes after min due to the removal of one parser node.
|
||||
// This also allows for handler unification as all mustache node instances can utilize the same handler
|
||||
: OPEN sexpr CLOSE -> yy.prepareMustache($2, $1, yy.stripFlags($1, $3), @$)
|
||||
| OPEN_UNESCAPED sexpr CLOSE_UNESCAPED -> yy.prepareMustache($2, $1, yy.stripFlags($1, $3), @$)
|
||||
: OPEN helperName param* hash? CLOSE -> yy.prepareMustache($2, $3, $4, $1, yy.stripFlags($1, $5), @$)
|
||||
| OPEN_UNESCAPED helperName param* hash? CLOSE_UNESCAPED -> yy.prepareMustache($2, $3, $4, $1, yy.stripFlags($1, $5), @$)
|
||||
;
|
||||
|
||||
partial
|
||||
: OPEN_PARTIAL partial_expr CLOSE -> new yy.PartialStatement($2, yy.stripFlags($1, $3), yy.locInfo(@$))
|
||||
;
|
||||
|
||||
partial_expr
|
||||
: helperName param* hash? -> new yy.PartialExpression($1, $2, $3, yy.locInfo(@$))
|
||||
| dataName -> new yy.PartialExpression($1, null, null, yy.locInfo(@$))
|
||||
| OPEN_SEXPR sexpr CLOSE_SEXPR param* hash? -> new yy.PartialExpression($2, $4, $5, yy.locInfo(@$))
|
||||
;
|
||||
|
||||
sexpr
|
||||
: helperName param* hash? -> new yy.SubExpression($1, $2, $3, yy.locInfo(@$))
|
||||
| dataName -> new yy.SubExpression($1, null, null, yy.locInfo(@$))
|
||||
: OPEN_PARTIAL partialName param* hash? CLOSE -> new yy.PartialStatement($2, $3, $4, yy.stripFlags($1, $5), yy.locInfo(@$))
|
||||
;
|
||||
|
||||
param
|
||||
@@ -97,7 +86,11 @@ param
|
||||
| NUMBER -> new yy.NumberLiteral($1, yy.locInfo(@$))
|
||||
| BOOLEAN -> new yy.BooleanLiteral($1, yy.locInfo(@$))
|
||||
| dataName -> $1
|
||||
| OPEN_SEXPR sexpr CLOSE_SEXPR -> $2
|
||||
| sexpr -> $1
|
||||
;
|
||||
|
||||
sexpr
|
||||
: OPEN_SEXPR helperName param* hash? CLOSE_SEXPR -> new yy.SubExpression($2, $3, $4, yy.locInfo(@$))
|
||||
;
|
||||
|
||||
hash
|
||||
@@ -114,10 +107,16 @@ blockParams
|
||||
|
||||
helperName
|
||||
: path -> $1
|
||||
| dataName -> $1
|
||||
| STRING -> new yy.StringLiteral($1, yy.locInfo(@$)), yy.locInfo(@$)
|
||||
| NUMBER -> new yy.NumberLiteral($1, yy.locInfo(@$))
|
||||
;
|
||||
|
||||
partialName
|
||||
: helperName -> $1
|
||||
| sexpr -> $1
|
||||
;
|
||||
|
||||
dataName
|
||||
: DATA pathSegments -> yy.preparePath(true, $2, @$)
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user