]> ruin.nu Git - proglang.git/commitdiff
more or less done with the syntx
authorMichael Andreen <harv@ruin.nu>
Fri, 24 Feb 2006 08:02:00 +0000 (08:02 +0000)
committerMichael Andreen <harv@ruin.nu>
Fri, 24 Feb 2006 08:02:00 +0000 (08:02 +0000)
documentation
syntax.cf

index 2d3fcac33546a4e9ed73608a54d47478f0c34ac7..c77568b12f0b8d6434f10e1ef99c82d6a6d751f9 100644 (file)
@@ -1,7 +1,7 @@
 ####### DOCUMENTATIATOIAITAT ION ########
 
 
 ####### DOCUMENTATIATOIAITAT ION ########
 
 
-a simple c-like language with support for if/else-statements, while-loops and the standard arithmetic (+, -, /, *) and comparison expressions (<, >, <=, >=, ==, !=). also, increase/decrease expressions (++, --) are supported.
+a simple c-like language with support for if/else-statements, while-loops and the standard arithmetic (+, -, /, *) and comparison expressions (<, >, <=, >=, ==, !=). also, post increase/decrease expressions (++, --) are supported.
 
 data types:
 integers and booleans.
 
 data types:
 integers and booleans.
@@ -9,20 +9,22 @@ integers and booleans.
 comments:
 // and /* */ comments are allowed.
 
 comments:
 // and /* */ comments are allowed.
 
+(For compilation to work the Bool type in Abssyntax has to be removed so the internal haskell type is used)
+
 shift/reduce conflicts:
 
 shift/reduce conflicts:
 
-30 conflicts in total.
+18 conflicts in total.
 
 1) Exp1 followed by (<,<=,>,>=,==,!=,+,-) 8 conflicts:
 In these cases the Exp1 could've been reduced to Exp, but happy does the correct thing and shifts the operator token onto the stack, since Exp followed by these operators doesn't match any rules.
 
 
 1) Exp1 followed by (<,<=,>,>=,==,!=,+,-) 8 conflicts:
 In these cases the Exp1 could've been reduced to Exp, but happy does the correct thing and shifts the operator token onto the stack, since Exp followed by these operators doesn't match any rules.
 
-2) Exp2 followed by (*,/) 6 conflicts:
+2) Exp2 followed by (*,/) 4 conflicts:
 In two cases the Exp2 expression could be reduced to Exp1, but this wouldn't match the rules for these operators, so shifting is the correct action.
 
 In two cases the Exp2 expression could be reduced to Exp1, but this wouldn't match the rules for these operators, so shifting is the correct action.
 
-In four other cases the Exp2 in front of these operators can be reduced to addition and subtraction expressions, which would destroy operator priority, so shifting is correct here.
+In two other cases the Exp2 in front of these operators can be reduced to addition and subtraction expressions, which would destroy operator priority, so shifting is correct here.
 
 
-3) Exp1 followed by (+,-) 12 conflicts:
-In all these cases Exp1 could be reduced together with another Exp1 and a comparative operator to an Exp, but just as in the above case this would be very bad for operator priority, so shifting is right here.
+3) Exp1 followed by (+,-) 2 conflicts:
+In both these cases Exp1 could be reduced together with another Exp1 and a comparative operator to an Exp, but just as in the above case this would be very bad for operator priority, so shifting is right here.
 
 4) if with else: 1 conflict
 An if statement before the else could be reduced to an if statement lacking the else, but the correct thing is to shift it onto the stack.
 
 4) if with else: 1 conflict
 An if statement before the else could be reduced to an if statement lacking the else, but the correct thing is to shift it onto the stack.
index 28e93f9a4f1afb152c4ecb6997953411bc7d9b56..fae1234c287f73180e784eb039d7a68169a81bb8 100644 (file)
--- a/syntax.cf
+++ b/syntax.cf
@@ -16,16 +16,15 @@ SWhile.   Stm      ::= "while" "(" Exp ")" Stm ;
 -- SFor.     Stm      ::= "for" "(" Stm Exp ";" Exp ")" Stm ;
 SPrint.   Stm      ::= "print" Exp ";" ;
 
 -- SFor.     Stm      ::= "for" "(" Stm Exp ";" Exp ")" Stm ;
 SPrint.   Stm      ::= "print" Exp ";" ;
 
--- VVar.     Var      ::= Ident ;
--- VAss.     Var      ::= Ident "=" Exp;
-
 BExp.     Exp     ::= Exp1 BOp Exp1 ;
 op1.      Exp1    ::= Exp1 Op1 Exp2 ;
 define op1 e1 o e2 = OpExp e1 o e2 ;
 op2.      Exp2    ::= Exp2 Op2 Exp3 ;
 define op2 e1 o e2 = OpExp e1 o e2 ;
 BExp.     Exp     ::= Exp1 BOp Exp1 ;
 op1.      Exp1    ::= Exp1 Op1 Exp2 ;
 define op1 e1 o e2 = OpExp e1 o e2 ;
 op2.      Exp2    ::= Exp2 Op2 Exp3 ;
 define op2 e1 o e2 = OpExp e1 o e2 ;
-EIncr.    Exp3    ::= Ident "++" ;
-EDecr.    Exp3    ::= Ident "--" ;
+postIncr.    Exp3    ::= Ident "++" ;
+define postIncr i = EPost i Plus ;
+postDecr.    Exp3    ::= Ident "--" ;
+define postDecr i = EPost i Minus ;
 EVar.     Exp3    ::= Ident ;
 EAss.     Exp3    ::= Ident "=" Exp;
 EInt.     Exp3    ::= Integer ;
 EVar.     Exp3    ::= Ident ;
 EAss.     Exp3    ::= Ident "=" Exp;
 EInt.     Exp3    ::= Integer ;
@@ -71,6 +70,7 @@ internal SNoop. Stm ::= ;
 internal EDefault. Exp ::= ;
 internal OpExp. Exp ::= Exp Op Exp ;
 internal NoType. Type ::= ;
 internal EDefault. Exp ::= ;
 internal OpExp. Exp ::= Exp Op Exp ;
 internal NoType. Type ::= ;
+internal EPost. Exp ::= Ident Op1 ;
 
 comment "/*" "*/" ;
 comment "//" ;
 
 comment "/*" "*/" ;
 comment "//" ;