]> gitweb.factorcode.org Git - factor.git/commitdiff
Parse more valid JavaScript
authorChris Double <chris@bethia.(none)>
Mon, 30 Jun 2008 07:05:18 +0000 (19:05 +1200)
committerChris Double <chris@bethia.(none)>
Thu, 10 Jul 2008 01:56:06 +0000 (13:56 +1200)
extra/peg/javascript/parser/parser.factor
extra/peg/javascript/tokenizer/tokenizer.factor

index 2736496cc7b6d19afeb7733bdc98778f5d078c44..45da7c3bb45c320bbd8685e933d7206eeeceb739 100644 (file)
@@ -40,6 +40,12 @@ Expr               =   OrExpr:e "?" Expr:t ":" Expr:f   => [[ e t f ast-cond-exp
                      | OrExpr:e "%=" Expr:rhs           => [[ e rhs "%" ast-mset boa ]]
                      | OrExpr:e "&&=" Expr:rhs          => [[ e rhs "&&" ast-mset boa ]]
                      | OrExpr:e "||=" Expr:rhs          => [[ e rhs "||" ast-mset boa ]]
+                     | OrExpr:e "^=" Expr:rhs           => [[ e rhs "^" ast-mset boa ]]
+                     | OrExpr:e "&=" Expr:rhs           => [[ e rhs "&" ast-mset boa ]]
+                     | OrExpr:e "|=" Expr:rhs           => [[ e rhs "|" ast-mset boa ]]
+                     | OrExpr:e "<<=" Expr:rhs          => [[ e rhs "<<" ast-mset boa ]]
+                     | OrExpr:e ">>=" Expr:rhs          => [[ e rhs ">>" ast-mset boa ]]
+                     | OrExpr:e ">>>=" Expr:rhs         => [[ e rhs ">>>" ast-mset boa ]]
                      | OrExpr:e                         => [[ e ]]
 
 ExprNoIn           =   OrExprNoIn:e "?" ExprNoIn:t ":" ExprNoIn:f => [[ e t f ast-cond-expr boa ]]
@@ -51,15 +57,33 @@ ExprNoIn           =   OrExprNoIn:e "?" ExprNoIn:t ":" ExprNoIn:f => [[ e t f as
                      | OrExprNoIn:e "%=" ExprNoIn:rhs             => [[ e rhs "%" ast-mset boa ]]
                      | OrExprNoIn:e "&&=" ExprNoIn:rhs            => [[ e rhs "&&" ast-mset boa ]]
                      | OrExprNoIn:e "||=" ExprNoIn:rhs            => [[ e rhs "||" ast-mset boa ]]
+                     | OrExprNoIn:e "^=" ExprNoIn:rhs             => [[ e rhs "^" ast-mset boa ]]
+                     | OrExprNoIn:e "&=" ExprNoIn:rhs             => [[ e rhs "&" ast-mset boa ]]
+                     | OrExprNoIn:e "|=" ExprNoIn:rhs             => [[ e rhs "|" ast-mset boa ]]
+                     | OrExprNoIn:e "<<=" ExprNoIn:rhs            => [[ e rhs "<<" ast-mset boa ]]
+                     | OrExprNoIn:e ">>=" ExprNoIn:rhs            => [[ e rhs ">>" ast-mset boa ]]
+                     | OrExprNoIn:e ">>>=" ExprNoIn:rhs           => [[ e rhs ">>>" ast-mset boa ]]
                      | OrExprNoIn:e                               => [[ e ]]
 
 OrExpr             =   OrExpr:x "||" AndExpr:y          => [[ x y "||" ast-binop boa ]]
                      | AndExpr
 OrExprNoIn         =   OrExprNoIn:x "||" AndExprNoIn:y  => [[ x y "||" ast-binop boa ]]
                      | AndExprNoIn
-AndExpr            =   AndExpr:x "&&" EqExpr:y          => [[ x y "&&" ast-binop boa ]]
+AndExpr            =   AndExpr:x "&&" BitOrExpr:y       => [[ x y "&&" ast-binop boa ]]
+                     | BitOrExpr
+AndExprNoIn        =   AndExprNoIn:x "&&" BitOrExprNoIn:y => [[ x y "&&" ast-binop boa ]]
+                     | BitOrExprNoIn
+BitOrExpr          =   BitOrExpr:x "|" BitXORExpr:y     => [[ x y "|" ast-binop boa ]]
+                     | BitXORExpr
+BitOrExprNoIn      =   BitOrExprNoIn:x "|" BitXORExprNoIn:y => [[ x y "|" ast-binop boa ]]
+                     | BitXORExprNoIn
+BitXORExpr         =   BitXORExpr:x "^" BitANDExpr:y    => [[ x y "^" ast-binop boa ]]
+                     | BitANDExpr
+BitXORExprNoIn     =   BitXORExprNoIn:x "^" BitANDExprNoIn:y => [[ x y "^" ast-binop boa ]]
+                     | BitANDExprNoIn
+BitANDExpr         =   BitANDExpr:x "&" EqExpr:y        => [[ x y "&" ast-binop boa ]]
                      | EqExpr
-AndExprNoIn        =   AndExprNoIn:x "&&" EqExprNoIn:y  => [[ x y "&&" ast-binop boa ]]
+BitANDExprNoIn     =   BitANDExprNoIn:x "&" EqExprNoIn:y => [[ x y "&" ast-binop boa ]]
                      | EqExprNoIn
 EqExpr             =   EqExpr:x "==" RelExpr:y          => [[ x y "==" ast-binop boa ]]
                      | EqExpr:x "!=" RelExpr:y          => [[ x y "!=" ast-binop boa ]]
index 0698c8427e268cd300c5960d1f3861f89f3178b9..30a3b5e7a5006336fd27e6ef3c40af13950bd4c2 100644 (file)
@@ -67,11 +67,13 @@ RegExpChar         =   !("\\" | "/") NonTerminator
 RegExpChars        = RegExpChar*
 RegExpBody         = RegExpFirstChar RegExpChars => [[ first2 swap prefix >string ]]
 RegExp             = "/" RegExpBody:b "/" RegExpFlags:fl => [[ b fl ast-regexp boa ]]
-Special            =   "("   | ")"   | "{"   | "}"   | "["   | "]"   | ","   | ";"
-                     | "?"   | ":"   | "!==" | "!="  | "===" | "=="  | "="   | ">="
-                     | ">>>" | ">>"  | ">"   | "<="  | "<<"  | "<"   | "++"  | "+="
-                     | "+"   | "--"  | "-="  | "-"   | "*="  | "*"   | "/="  | "/"
-                     | "%="  | "%"   | "&&=" | "&&"  | "||=" | "||"  | "."   | "!"
+Special            =   "("    | ")"   | "{"   | "}"   | "["   | "]"   | ","   | ";"
+                     | "?"    | ":"   | "!==" | "!="  | "===" | "=="  | "="   | ">="
+                     | ">>>=" | ">>>" | ">>=" | ">>"  | ">"   | "<="  | "<<=" | "<<"
+                     | "<"    | "++"  | "+="  | "+"   | "--"  | "-="  | "-"   | "*="
+                     | "*"    | "/="  | "/"   | "%="  | "%"   | "&&=" | "&&"  | "||="
+                     | "||"   | "."   | "!"   | "&="  | "&"   | "|="  | "|"   | "^="
+                     | "^"
 Tok                = Spaces (Name | Keyword | Number | Str | RegExp | Special )
 Toks               = Tok* Spaces 
 ;EBNF