Permalink
Browse files

op precedence pseudo-bnf

  • Loading branch information...
1 parent 5940ac9 commit 9667c21e8be74652fe9accd1f4b997edac09eca8 @samsonjs committed Feb 15, 2010
Showing with 25 additions and 0 deletions.
  1. +25 −0 op-precedence.txt
View
25 op-precedence.txt
@@ -0,0 +1,25 @@
+keyword := 'if' | 'while' | 'until' | 'repeat' | 'for' | 'do' | 'break' |
+ 'print' | 'else' | 'end'
+identifier := /[a-zA-Z][[:alnum:]]+/
+number := /\d+/
+boolean-literal := 'true' | 'false'
+
+factor := '(' boolean-expression ')' | identifier | number
+signed-factor := '-' factor | '+' factor | factor
+term := signed-factor (/[*/]/ signed-factor)*
+arithmetic-expression := term (/[-+]/ term)*
+
+bit-op := '|' | '&' | '^'
+bit-expression := arithmetic-expression (bit-op arithmetic-expression)*
+
+rel-op := '==' | '!=' | '>' | '>=' | '<' | '<='
+relation := bit-expression (rel-op bit-expression)*
+
+boolean-factor := boolean-literal | relation
+not-factor := '!' boolean-factor | boolean-factor
+boolean-term := not-factor ('&&' not-factor)*
+boolean-expression := boolean-term ('||' boolean-term)*
+
+assignment := identifier '=' boolean-expression
+
+expression := assignment | boolean-expression

0 comments on commit 9667c21

Please sign in to comment.