# HG changeset patch # User Michael Pavone # Date 1388357806 28800 # Node ID 6055f56d0e457c9226341f700b66c47d0dd75bd8 # Parent 262f5ae1bb1bdf70b615252788fa92a42568b3ec Implement all the binary operators except and/or/xor in grammar diff -r 262f5ae1bb1b -r 6055f56d0e45 modules/parser.tp --- a/modules/parser.tp Sun Dec 29 14:39:54 2013 -0800 +++ b/modules/parser.tp Sun Dec 29 14:56:46 2013 -0800 @@ -440,11 +440,27 @@ }) } + opexpr <- binaryOps: ["&&" "||"] withHigherPrec: compare + compare <- binaryOps: ["<=" ">=" "<" ">" "=" "!="] withHigherPrec: maybecons + maybecons <- matchOne: [ + consop + addsub + ] + consop <- match: Left . hws . "|" . Right where: { + Left <- match: addsub + Right <- match: maybecons + } yield: { + #{ + left <- Left + op <- "|" + right <- Right + } + } addsub <- binaryOps: ["+" "-" "."] withHigherPrec: muldiv muldiv <- binaryOps: ["*" "/" "%"] withHigherPrec: primlitsym //TODO: Implement operator expressions - opexpr <- match: addsub + _alpha <- charClass: "a-zA-Z" alpha <- zeroPlus: _alpha @@ -831,7 +847,7 @@ testmatchintlit: "0x20" :s {hexlit: s} testmatchintlit: "0x42u64" :s {hexlit: s} testmatchintlit: "0b10101" :s {binary: s} - code <- "#{ foo <- 123\n bar <- 0xABC + 0b1010101\n baz <- 0b1010 * 5\n qux <- fo: 38 shizzle: bam\n}" + code <- "#{ foo <- 123 > 0x42 && 42 < 104\n bar <- 0xABC + 0b1010101\n baz <- 0b1010 * 5\n qux <- fo: 38 shizzle: bam\n}" codem <- expr: code if: (codem matched?) { print: code . "\nmatched with yield:\n" . (codem yield) . "\n"