summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--source/mod_student/lexer.mll4
-rw-r--r--source/mod_student/parser.mly3
2 files changed, 4 insertions, 3 deletions
diff --git a/source/mod_student/lexer.mll b/source/mod_student/lexer.mll
index 1d5f9f2..1803de5 100644
--- a/source/mod_student/lexer.mll
+++ b/source/mod_student/lexer.mll
@@ -119,13 +119,15 @@ let implode l =
       | "length"  { LENGTH }
       | "int"     { T_INT }
       | "bool"    { T_BOOL }
+      | "true"    { BOOL true }
+      | "false"   { BOOL false }
       | "_"       { UNDERSCORE }
       | identifier as id  { IDENTIFIER id }
       | integer as i      { INT (int_of_string i) }
 
       (* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          ----------------------------------------------------------------------------- *)
-      | " " {token lexbuf}
+      | " "|"\t" {token lexbuf}
       | _
       { handleError (Lexing.lexeme_start_p lexbuf) (Lexing.lexeme lexbuf) }
 
diff --git a/source/mod_student/parser.mly b/source/mod_student/parser.mly
index c79181e..2665861 100644
--- a/source/mod_student/parser.mly
+++ b/source/mod_student/parser.mly
@@ -195,7 +195,7 @@ statement:
         {STMT_VarDecl { var=var;init=init } }
     | WHILE cond=expression body=statement 
         { STMT_While {loc=mkLocation $startpos;cond=cond;body=body } }
-    | IF cond=expression then_branch=statement else_branch=option(preceded(ELSE,statement))
+    | IF cond=expression then_branch=statement else_branch=option(preceded(ELSE,statement)) (*Menhir attempts to mimic ocamlyacc’s specification, that is, to resolve shift/reduce conflicts in favor of shifting*)
         { STMT_If {loc=mkLocation $startpos;cond=cond;then_branch=then_branch;
           else_branch=else_branch } }
     | head=option_var_decl COMMA tail=separated_nonempty_list(COMMA, option_var_decl) ASSIGN call=call
@@ -207,7 +207,6 @@ call:
     | callee=identifier LPAREN arguments=separated_list(COMMA,expression) RPAREN
       { Call { tag=mkTag (); loc=mkLocation $startpos;
                callee=callee; arguments=arguments } }
-    (* TODO Add other statements *)
 lvalue:
     | id=identifier {LVALUE_Id {loc=mkLocation $startpos;id=id} }
     | sub=lvalue_index LSBRACKET index=expression RSBRACKET