Permalink
Browse files

Fixed precedence issue in the operator table

The operator table was in reverse order. The groups of operations in an
operator table should be ordered by descending precedence.
  • Loading branch information...
1 parent 717fc53 commit 01a604dbdabfda7935d4cafc1efdd58538e9fd3e @seliopou committed Jan 25, 2010
Showing with 38 additions and 16 deletions.
  1. +1 −1 WebBits.cabal
  2. +37 −15 src/BrownPLT/JavaScript/Parser.hs
View
2 WebBits.cabal
@@ -1,5 +1,5 @@
Name: WebBits
-Version: 2.0
+Version: 2.1
Cabal-Version: >= 1.2.3
Copyright: Copyright (c) 2007-2009 Arjun Guha and Spiridon Eliopoulos
License: BSD3
View
52 src/BrownPLT/JavaScript/Parser.hs
@@ -542,23 +542,45 @@ parsePrefixedExpr = do
exprTable:: [[Operator Char st ParsedExpression]]
exprTable =
- [
- [makeInfixExpr "*" OpMul, makeInfixExpr "/" OpDiv, makeInfixExpr "%" OpMod],
- [makeInfixExpr "+" OpAdd, makeInfixExpr "-" OpSub],
- [makeInfixExpr "<<" OpLShift, makeInfixExpr ">>" OpSpRShift,
- makeInfixExpr ">>>" OpZfRShift],
- [makeInfixExpr "<" OpLT, makeInfixExpr "<=" OpLEq, makeInfixExpr ">" OpGT,
- makeInfixExpr ">=" OpGEq,
- makeInfixExpr "instanceof" OpInstanceof, makeInfixExpr "in" OpIn],
- [makeInfixExpr "&" OpBAnd],
- [makeInfixExpr "^" OpBXor],
- [makeInfixExpr "|" OpBOr],
- [makeInfixExpr "&&" OpLAnd],
- [makeInfixExpr "||" OpLOr],
- [makeInfixExpr "==" OpEq, makeInfixExpr "!=" OpNEq,
- makeInfixExpr "===" OpStrictEq, makeInfixExpr "!==" OpStrictNEq]
+ [ [ makeInfixExpr "==" OpEq
+ , makeInfixExpr "!=" OpNEq
+ , makeInfixExpr "===" OpStrictEq
+ , makeInfixExpr "!==" OpStrictNEq
]
+ , [ makeInfixExpr "||" OpLOr ]
+
+ , [ makeInfixExpr "&&" OpLAnd ]
+
+ , [ makeInfixExpr "|" OpBOr ]
+
+ , [ makeInfixExpr "^" OpBXor ]
+
+ , [ makeInfixExpr "&" OpBAnd ]
+
+ , [ makeInfixExpr "<" OpLT
+ , makeInfixExpr "<=" OpLEq
+ , makeInfixExpr ">" OpGT
+ , makeInfixExpr ">=" OpGEq
+ , makeInfixExpr "instanceof" OpInstanceof
+ , makeInfixExpr "in" OpIn
+ ]
+
+ , [ makeInfixExpr "<<" OpLShift
+ , makeInfixExpr ">>" OpSpRShift
+ , makeInfixExpr ">>>" OpZfRShift
+ ]
+
+ , [ makeInfixExpr "+" OpAdd
+ , makeInfixExpr "-" OpSub
+ ]
+
+ , [ makeInfixExpr "*" OpMul
+ , makeInfixExpr "/" OpDiv
+ , makeInfixExpr "%" OpMod
+ ]
+ ]
+
parseExpression' =
buildExpressionParser exprTable parsePrefixedExpr <?> "simple expression"

0 comments on commit 01a604d

Please sign in to comment.