]> ruin.nu Git - proglang.git/blobdiff - documentation
more or less done with the syntx
[proglang.git] / documentation
index cb693df417c88f4430589c5ac0de2ce533360c91..c77568b12f0b8d6434f10e1ef99c82d6a6d751f9 100644 (file)
@@ -1,9 +1,7 @@
 ####### 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.
@@ -11,67 +9,25 @@ integers and booleans.
 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:
 
+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.
 
+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 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 (+,-) 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.
 
-
-
-
-
-examples:
-
-fib
----
-int n1 = 0;
-int n2 = 1;
-int n = readInt;
-
-while(n-- > 0){
-  int temp = n1+n2;
-  n1 = n2;
-  n2 = temp;
-}
-print n2;
-
-
-tests while, decr and assignment.
-
-
-
-if
---
-if (readBool) {
-  if (readInt < 0)
-    print true;
-  else
-    print false;
-}
-
-
-tests if and if/else.
-
-
-
-sum
----
-int n;
-int sum = 0;
-while ((n = readInt) != -1) sum = sum + n;
-print sum;
-
-
-
-
-var
----
-int a = 3;
-int b = a - 5;
-int c = a + b*7;
-bool d = a == b;
-
-tests simple variable operations.
\ No newline at end of file
+5) if/ifelse/while followed by (;): 3 conflicts
+Here we have redundant semicolons, these could all be reduced to individual statements without the ';'. Such a reduction wouldn't cause any harm, but neither does the shifting, it's an ok choice.