Remove javascript boa constructors
parent
b338fc8fea
commit
79dfe2806a
|
@ -45,42 +45,6 @@ TUPLE: ast-try t e c f ;
|
||||||
TUPLE: ast-return e ;
|
TUPLE: ast-return e ;
|
||||||
TUPLE: ast-case c cs ;
|
TUPLE: ast-case c cs ;
|
||||||
TUPLE: ast-default cs ;
|
TUPLE: ast-default cs ;
|
||||||
C: <ast-name> ast-name
|
|
||||||
C: <ast-keyword> ast-keyword
|
|
||||||
C: <ast-number> ast-number
|
|
||||||
C: <ast-string> ast-string
|
|
||||||
C: <ast-cond-expr> ast-cond-expr
|
|
||||||
C: <ast-set> ast-set
|
|
||||||
C: <ast-get> ast-get
|
|
||||||
C: <ast-mset> ast-mset
|
|
||||||
C: <ast-binop> ast-binop
|
|
||||||
C: <ast-unop> ast-unop
|
|
||||||
C: <ast-preop> ast-preop
|
|
||||||
C: <ast-postop> ast-postop
|
|
||||||
C: <ast-getp> ast-getp
|
|
||||||
C: <ast-send> ast-send
|
|
||||||
C: <ast-call> ast-call
|
|
||||||
C: <ast-this> ast-this
|
|
||||||
C: <ast-new> ast-new
|
|
||||||
C: <ast-array> ast-array
|
|
||||||
C: <ast-json> ast-json
|
|
||||||
C: <ast-binding> ast-binding
|
|
||||||
C: <ast-func> ast-func
|
|
||||||
C: <ast-var> ast-var
|
|
||||||
C: <ast-begin> ast-begin
|
|
||||||
C: <ast-if> ast-if
|
|
||||||
C: <ast-while> ast-while
|
|
||||||
C: <ast-do-while> ast-do-while
|
|
||||||
C: <ast-for> ast-for
|
|
||||||
C: <ast-for-in> ast-for-in
|
|
||||||
C: <ast-switch> ast-switch
|
|
||||||
C: <ast-break> ast-break
|
|
||||||
C: <ast-continue> ast-continue
|
|
||||||
C: <ast-throw> ast-throw
|
|
||||||
C: <ast-try> ast-try
|
|
||||||
C: <ast-return> ast-return
|
|
||||||
C: <ast-case> ast-case
|
|
||||||
C: <ast-default> ast-default
|
|
||||||
|
|
||||||
EBNF: javascript
|
EBNF: javascript
|
||||||
Letter = [a-zA-Z]
|
Letter = [a-zA-Z]
|
||||||
|
@ -117,10 +81,10 @@ Keyword = ("break"
|
||||||
| "var"
|
| "var"
|
||||||
| "void"
|
| "void"
|
||||||
| "while"
|
| "while"
|
||||||
| "with") => [[ <ast-keyword> ]]
|
| "with") => [[ ast-keyword boa ]]
|
||||||
Name = !(Keyword) (iName):n => [[ drop n <ast-name> ]]
|
Name = !(Keyword) (iName):n => [[ drop n ast-name boa ]]
|
||||||
Number = Digits:ws '.' Digits:fs => [[ drop ws "." fs 3array concat >string string>number <ast-number> ]]
|
Number = Digits:ws '.' Digits:fs => [[ drop ws "." fs 3array concat >string string>number ast-number boa ]]
|
||||||
| Digits => [[ >string string>number <ast-number> ]]
|
| Digits => [[ >string string>number ast-number boa ]]
|
||||||
|
|
||||||
EscapeChar = "\\n" => [[ drop 10 ]]
|
EscapeChar = "\\n" => [[ drop 10 ]]
|
||||||
| "\\r" => [[ drop 13 ]]
|
| "\\r" => [[ drop 13 ]]
|
||||||
|
@ -128,9 +92,9 @@ EscapeChar = "\\n" => [[ drop 10 ]]
|
||||||
StringChars1 = (EscapeChar | !('"""') .)* => [[ >string ]]
|
StringChars1 = (EscapeChar | !('"""') .)* => [[ >string ]]
|
||||||
StringChars2 = (EscapeChar | !('"') .)* => [[ >string ]]
|
StringChars2 = (EscapeChar | !('"') .)* => [[ >string ]]
|
||||||
StringChars3 = (EscapeChar | !("'") .)* => [[ >string ]]
|
StringChars3 = (EscapeChar | !("'") .)* => [[ >string ]]
|
||||||
Str = '"""' StringChars1:cs '"""' => [[ drop cs <ast-string> ]]
|
Str = '"""' StringChars1:cs '"""' => [[ drop cs ast-string boa ]]
|
||||||
| '"' StringChars2:cs '"' => [[ drop cs <ast-string> ]]
|
| '"' StringChars2:cs '"' => [[ drop cs ast-string boa ]]
|
||||||
| "'" StringChars3:cs "'" => [[ drop cs <ast-string> ]]
|
| "'" StringChars3:cs "'" => [[ drop cs ast-string boa ]]
|
||||||
Special = "(" | ")" | "{" | "}" | "[" | "]" | "," | ";"
|
Special = "(" | ")" | "{" | "}" | "[" | "]" | "," | ";"
|
||||||
| "?" | ":" | "!==" | "~=" | "===" | "==" | "=" | ">="
|
| "?" | ":" | "!==" | "~=" | "===" | "==" | "=" | ">="
|
||||||
| ">" | "<=" | "<" | "++" | "+=" | "+" | "--" | "-="
|
| ">" | "<=" | "<" | "++" | "+=" | "+" | "--" | "-="
|
||||||
|
@ -140,108 +104,108 @@ Tok = Spaces (Name | Keyword | Number | Str | Special )
|
||||||
Toks = (Tok)* Spaces
|
Toks = (Tok)* Spaces
|
||||||
SpacesNoNl = (!("\n") Space)* => [[ drop ignore ]]
|
SpacesNoNl = (!("\n") Space)* => [[ drop ignore ]]
|
||||||
|
|
||||||
Expr = OrExpr:e "?" Expr:t ":" Expr:f => [[ drop e t f <ast-cond-expr> ]]
|
Expr = OrExpr:e "?" Expr:t ":" Expr:f => [[ drop e t f ast-cond-expr boa ]]
|
||||||
| OrExpr:e "=" Expr:rhs => [[ drop e rhs <ast-set> ]]
|
| OrExpr:e "=" Expr:rhs => [[ drop e rhs ast-set boa ]]
|
||||||
| OrExpr:e "+=" Expr:rhs => [[ drop e rhs "+" <ast-mset> ]]
|
| OrExpr:e "+=" Expr:rhs => [[ drop e rhs "+" ast-mset boa ]]
|
||||||
| OrExpr:e "-=" Expr:rhs => [[ drop e rhs "-" <ast-mset> ]]
|
| OrExpr:e "-=" Expr:rhs => [[ drop e rhs "-" ast-mset boa ]]
|
||||||
| OrExpr:e "*=" Expr:rhs => [[ drop e rhs "*" <ast-mset> ]]
|
| OrExpr:e "*=" Expr:rhs => [[ drop e rhs "*" ast-mset boa ]]
|
||||||
| OrExpr:e "/=" Expr:rhs => [[ drop e rhs "/" <ast-mset> ]]
|
| OrExpr:e "/=" Expr:rhs => [[ drop e rhs "/" ast-mset boa ]]
|
||||||
| OrExpr:e "%=" Expr:rhs => [[ drop e rhs "%" <ast-mset> ]]
|
| OrExpr:e "%=" Expr:rhs => [[ drop e rhs "%" ast-mset boa ]]
|
||||||
| OrExpr:e "&&=" Expr:rhs => [[ drop e rhs "&&" <ast-mset> ]]
|
| OrExpr:e "&&=" Expr:rhs => [[ drop e rhs "&&" ast-mset boa ]]
|
||||||
| OrExpr:e "||=" Expr:rhs => [[ drop e rhs "||" <ast-mset> ]]
|
| OrExpr:e "||=" Expr:rhs => [[ drop e rhs "||" ast-mset boa ]]
|
||||||
| OrExpr:e => [[ drop e ]]
|
| OrExpr:e => [[ drop e ]]
|
||||||
|
|
||||||
OrExpr = OrExpr:x "||" AndExpr:y => [[ drop x y "||" <ast-binop> ]]
|
OrExpr = OrExpr:x "||" AndExpr:y => [[ drop x y "||" ast-binop boa ]]
|
||||||
| AndExpr
|
| AndExpr
|
||||||
AndExpr = AndExpr:x "&&" EqExpr:y => [[ drop x y "&&" <ast-binop> ]]
|
AndExpr = AndExpr:x "&&" EqExpr:y => [[ drop x y "&&" ast-binop boa ]]
|
||||||
| EqExpr
|
| EqExpr
|
||||||
EqExpr = EqExpr:x "==" RelExpr:y => [[ drop x y "==" <ast-binop> ]]
|
EqExpr = EqExpr:x "==" RelExpr:y => [[ drop x y "==" ast-binop boa ]]
|
||||||
| EqExpr:x "!=" RelExpr:y => [[ drop x y "!=" <ast-binop> ]]
|
| EqExpr:x "!=" RelExpr:y => [[ drop x y "!=" ast-binop boa ]]
|
||||||
| EqExpr:x "===" RelExpr:y => [[ drop x y "===" <ast-binop> ]]
|
| EqExpr:x "===" RelExpr:y => [[ drop x y "===" ast-binop boa ]]
|
||||||
| EqExpr:x "!==" RelExpr:y => [[ drop x y "!==" <ast-binop> ]]
|
| EqExpr:x "!==" RelExpr:y => [[ drop x y "!==" ast-binop boa ]]
|
||||||
| RelExpr
|
| RelExpr
|
||||||
RelExpr = RelExpr:x ">" AddExpr:y => [[ drop x y ">" <ast-binop> ]]
|
RelExpr = RelExpr:x ">" AddExpr:y => [[ drop x y ">" ast-binop boa ]]
|
||||||
| RelExpr:x ">=" AddExpr:y => [[ drop x y ">=" <ast-binop> ]]
|
| RelExpr:x ">=" AddExpr:y => [[ drop x y ">=" ast-binop boa ]]
|
||||||
| RelExpr:x "<" AddExpr:y => [[ drop x y "<" <ast-binop> ]]
|
| RelExpr:x "<" AddExpr:y => [[ drop x y "<" ast-binop boa ]]
|
||||||
| RelExpr:x "<=" AddExpr:y => [[ drop x y "<=" <ast-binop> ]]
|
| RelExpr:x "<=" AddExpr:y => [[ drop x y "<=" ast-binop boa ]]
|
||||||
| RelExpr:x "instanceof" AddExpr:y => [[ drop x y "instanceof" <ast-binop> ]]
|
| RelExpr:x "instanceof" AddExpr:y => [[ drop x y "instanceof" ast-binop boa ]]
|
||||||
| AddExpr
|
| AddExpr
|
||||||
AddExpr = AddExpr:x "+" MulExpr:y => [[ drop x y "+" <ast-binop> ]]
|
AddExpr = AddExpr:x "+" MulExpr:y => [[ drop x y "+" ast-binop boa ]]
|
||||||
| AddExpr:x "-" MulExpr:y => [[ drop x y "-" <ast-binop> ]]
|
| AddExpr:x "-" MulExpr:y => [[ drop x y "-" ast-binop boa ]]
|
||||||
| MulExpr
|
| MulExpr
|
||||||
MulExpr = MulExpr:x "*" MulExpr:y => [[ drop x y "*" <ast-binop> ]]
|
MulExpr = MulExpr:x "*" MulExpr:y => [[ drop x y "*" ast-binop boa ]]
|
||||||
| MulExpr:x "/" MulExpr:y => [[ drop x y "/" <ast-binop> ]]
|
| MulExpr:x "/" MulExpr:y => [[ drop x y "/" ast-binop boa ]]
|
||||||
| MulExpr:x "%" MulExpr:y => [[ drop x y "%" <ast-binop> ]]
|
| MulExpr:x "%" MulExpr:y => [[ drop x y "%" ast-binop boa ]]
|
||||||
| Unary
|
| Unary
|
||||||
Unary = "-" Postfix:p => [[ drop p "-" <ast-unop> ]]
|
Unary = "-" Postfix:p => [[ drop p "-" ast-unop boa ]]
|
||||||
| "+" Postfix:p => [[ drop p ]]
|
| "+" Postfix:p => [[ drop p ]]
|
||||||
| "++" Postfix:p => [[ drop p "++" <ast-preop> ]]
|
| "++" Postfix:p => [[ drop p "++" ast-preop boa ]]
|
||||||
| "--" Postfix:p => [[ drop p "--" <ast-preop> ]]
|
| "--" Postfix:p => [[ drop p "--" ast-preop boa ]]
|
||||||
| "!" Postfix:p => [[ drop p "!" <ast-unop> ]]
|
| "!" Postfix:p => [[ drop p "!" ast-unop boa ]]
|
||||||
| Postfix
|
| Postfix
|
||||||
Postfix = PrimExpr:p SpacesNoNl "++" => [[ drop p "++" <ast-postop> ]]
|
Postfix = PrimExpr:p SpacesNoNl "++" => [[ drop p "++" ast-postop boa ]]
|
||||||
| PrimExpr:p SpacesNoNl "--" => [[ drop p "--" <ast-postop> ]]
|
| PrimExpr:p SpacesNoNl "--" => [[ drop p "--" ast-postop boa ]]
|
||||||
| PrimExpr
|
| PrimExpr
|
||||||
Args = Expr ("," Expr)* => [[ first2 swap prefix ]]
|
Args = Expr ("," Expr)* => [[ first2 swap prefix ]]
|
||||||
PrimExpr = PrimExpr:p "[" Expr:i "]" => [[ drop i p <ast-getp> ]]
|
PrimExpr = PrimExpr:p "[" Expr:i "]" => [[ drop i p ast-getp boa ]]
|
||||||
| PrimExpr:p "." Name:m "(" Args:as ")" => [[ drop m p as <ast-send> ]]
|
| PrimExpr:p "." Name:m "(" Args:as ")" => [[ drop m p as ast-send boa ]]
|
||||||
| PrimExpr:p "." Name:f => [[ drop f p <ast-getp> ]]
|
| PrimExpr:p "." Name:f => [[ drop f p ast-getp boa ]]
|
||||||
| PrimExpr:p "(" Args:as ")" => [[ drop p as <ast-call> ]]
|
| PrimExpr:p "(" Args:as ")" => [[ drop p as ast-call boa ]]
|
||||||
| PrimExprHd
|
| PrimExprHd
|
||||||
PrimExprHd = "(" Expr:e ")" => [[ drop e ]]
|
PrimExprHd = "(" Expr:e ")" => [[ drop e ]]
|
||||||
| "this" => [[ drop <ast-this> ]]
|
| "this" => [[ drop ast-this boa ]]
|
||||||
| Name => [[ <ast-get> ]]
|
| Name => [[ ast-get boa ]]
|
||||||
| Number => [[ <ast-number> ]]
|
| Number => [[ ast-number boa ]]
|
||||||
| Str => [[ <ast-string> ]]
|
| Str => [[ ast-string boa ]]
|
||||||
| "function" FuncRest:fr => [[ drop fr ]]
|
| "function" FuncRest:fr => [[ drop fr ]]
|
||||||
| "new" Name:n "(" Args:as ")" => [[ drop n as <ast-new> ]]
|
| "new" Name:n "(" Args:as ")" => [[ drop n as ast-new boa ]]
|
||||||
| "[" Args:es "]" => [[ drop es <ast-array> ]]
|
| "[" Args:es "]" => [[ drop es ast-array boa ]]
|
||||||
| Json
|
| Json
|
||||||
JsonBindings = JsonBinding ("," JsonBinding)* => [[ first2 swap prefix ]]
|
JsonBindings = JsonBinding ("," JsonBinding)* => [[ first2 swap prefix ]]
|
||||||
Json = "{" JsonBindings:bs "}" => [[ drop bs <ast-json> ]]
|
Json = "{" JsonBindings:bs "}" => [[ drop bs ast-json boa ]]
|
||||||
JsonBinding = JsonPropName:n ":" Expr:v => [[ drop n v <ast-binding> ]]
|
JsonBinding = JsonPropName:n ":" Expr:v => [[ drop n v ast-binding boa ]]
|
||||||
JsonPropName = Name | Number | Str
|
JsonPropName = Name | Number | Str
|
||||||
Formal = Spaces Name
|
Formal = Spaces Name
|
||||||
Formals = Formal ("," Formal)* => [[ first2 swap prefix ]]
|
Formals = Formal ("," Formal)* => [[ first2 swap prefix ]]
|
||||||
FuncRest = "(" Formals:fs ")" "{" SrcElems:body "}" => [[ drop fs body <ast-func> ]]
|
FuncRest = "(" Formals:fs ")" "{" SrcElems:body "}" => [[ drop fs body ast-func boa ]]
|
||||||
Sc = SpacesNoNl ("\n" | "}")| ";"
|
Sc = SpacesNoNl ("\n" | "}")| ";"
|
||||||
Binding = Name:n "=" Expr:v => [[ drop n v <ast-var> ]]
|
Binding = Name:n "=" Expr:v => [[ drop n v ast-var boa ]]
|
||||||
| Name:n => [[ drop n "undefined" <ast-get> <ast-var> ]]
|
| Name:n => [[ drop n "undefined" ast-get boa ast-var boa ]]
|
||||||
Block = "{" SrcElems:ss "}" => [[ drop ss ]]
|
Block = "{" SrcElems:ss "}" => [[ drop ss ]]
|
||||||
Bindings = Binding ("," Binding)* => [[ first2 swap prefix ]]
|
Bindings = Binding ("," Binding)* => [[ first2 swap prefix ]]
|
||||||
For1 = "var" Binding => [[ second ]]
|
For1 = "var" Binding => [[ second ]]
|
||||||
| Expr
|
| Expr
|
||||||
| Spaces => [[ "undefined" <ast-get> ]]
|
| Spaces => [[ "undefined" ast-get boa ]]
|
||||||
For2 = Expr
|
For2 = Expr
|
||||||
| Spaces => [[ "true" <ast-get> ]]
|
| Spaces => [[ "true" ast-get boa ]]
|
||||||
For3 = Expr
|
For3 = Expr
|
||||||
| Spaces => [[ "undefined" <ast-get> ]]
|
| Spaces => [[ "undefined" ast-get boa ]]
|
||||||
ForIn1 = "var" Name:n => [[ drop n "undefined" <ast-get> <ast-var> ]]
|
ForIn1 = "var" Name:n => [[ drop n "undefined" ast-get boa ast-var boa ]]
|
||||||
| Expr
|
| Expr
|
||||||
Switch1 = "case" Expr:c ":" SrcElems:cs => [[ drop c cs <ast-case> ]]
|
Switch1 = "case" Expr:c ":" SrcElems:cs => [[ drop c cs ast-case boa ]]
|
||||||
| "default" ":" SrcElems:cs => [[ drop cs <ast-default> ]]
|
| "default" ":" SrcElems:cs => [[ drop cs ast-default boa ]]
|
||||||
SwitchBody = (Switch1)*
|
SwitchBody = (Switch1)*
|
||||||
Finally = "finally" Block:b => [[ drop b ]]
|
Finally = "finally" Block:b => [[ drop b ]]
|
||||||
| Spaces => [[ drop "undefined" <ast-get> ]]
|
| Spaces => [[ drop "undefined" ast-get boa ]]
|
||||||
Stmt = Block
|
Stmt = Block
|
||||||
| "var" Bindings:bs Sc => [[ drop bs <ast-begin> ]]
|
| "var" Bindings:bs Sc => [[ drop bs ast-begin boa ]]
|
||||||
| "if" "(" Expr:c ")" Stmt:t "else" Stmt:f => [[ drop c t f <ast-if> ]]
|
| "if" "(" Expr:c ")" Stmt:t "else" Stmt:f => [[ drop c t f ast-if boa ]]
|
||||||
| "if" "(" Expr:c ")" Stmt:t => [[ drop c t "undefined" <ast-get> <ast-if> ]]
|
| "if" "(" Expr:c ")" Stmt:t => [[ drop c t "undefined" ast-get boa ast-if boa ]]
|
||||||
| "while" "(" Expr:c ")" Stmt:s => [[ drop c s <ast-while> ]]
|
| "while" "(" Expr:c ")" Stmt:s => [[ drop c s ast-while boa ]]
|
||||||
| "do" Stmt:s "while" "(" Expr:c ")" Sc => [[ drop s c <ast-do-while> ]]
|
| "do" Stmt:s "while" "(" Expr:c ")" Sc => [[ drop s c ast-do-while boa ]]
|
||||||
| "for" "(" For1:i ";" For2:c ";" For3:u ")" Stmt:s => [[ drop i c u s <ast-for> ]]
|
| "for" "(" For1:i ";" For2:c ";" For3:u ")" Stmt:s => [[ drop i c u s ast-for boa ]]
|
||||||
| "for" "(" ForIn1:v "in" Expr:e ")" Stmt:s => [[ drop v e s <ast-for-in> ]]
|
| "for" "(" ForIn1:v "in" Expr:e ")" Stmt:s => [[ drop v e s ast-for-in boa ]]
|
||||||
| "switch" "(" Expr:e ")" "{" SwitchBody:cs "}" => [[ drop e cs <ast-switch> ]]
|
| "switch" "(" Expr:e ")" "{" SwitchBody:cs "}" => [[ drop e cs ast-switch boa ]]
|
||||||
| "break" Sc => [[ drop <ast-break> ]]
|
| "break" Sc => [[ drop ast-break boa ]]
|
||||||
| "continue" Sc => [[ drop <ast-continue> ]]
|
| "continue" Sc => [[ drop ast-continue boa ]]
|
||||||
| "throw" SpacesNoNl Expr:e Sc => [[ drop e <ast-throw> ]]
|
| "throw" SpacesNoNl Expr:e Sc => [[ drop e ast-throw boa ]]
|
||||||
| "try" Block:t "catch" "(" Name:e ")" Block:c Finally:f => [[ drop t e c f <ast-try> ]]
|
| "try" Block:t "catch" "(" Name:e ")" Block:c Finally:f => [[ drop t e c f ast-try boa ]]
|
||||||
| "return" Expr:e Sc => [[ drop e <ast-return> ]]
|
| "return" Expr:e Sc => [[ drop e ast-return boa ]]
|
||||||
| "return" Sc => [[ drop "undefined" <ast-get> <ast-return> ]]
|
| "return" Sc => [[ drop "undefined" ast-get boa ast-return boa ]]
|
||||||
| Expr:e Sc => [[ drop e ]]
|
| Expr:e Sc => [[ drop e ]]
|
||||||
| ";" => [[ drop "undefined" <ast-get> ]]
|
| ";" => [[ drop "undefined" ast-get boa ]]
|
||||||
SrcElem = "function" Name:n FuncRest:f => [[ drop n f <ast-var> ]]
|
SrcElem = "function" Name:n FuncRest:f => [[ drop n f ast-var boa ]]
|
||||||
| Stmt
|
| Stmt
|
||||||
SrcElems = (SrcElem)* => [[ <ast-begin> ]]
|
SrcElems = (SrcElem)* => [[ ast-begin boa ]]
|
||||||
TopLevel = SrcElems Spaces
|
TopLevel = SrcElems Spaces
|
||||||
;EBNF
|
;EBNF
|
Loading…
Reference in New Issue