summary refs log tree commit diff
path: root/source/mod_student/lexer.mll
diff options
context:
space:
mode:
authorPaweł Dybiec <pdybiec@stud.cs.uni.wroc.pl>2018-11-04 13:21:36 +0100
committerPaweł Dybiec <pdybiec@stud.cs.uni.wroc.pl>2018-11-04 13:21:36 +0100
commit86d0833fb238bcb63968e677d645f896da74fbc5 (patch)
tree083ce1d6c43260250b92ca11938077de99578930 /source/mod_student/lexer.mll
parentAdd basic tokens + parse function name (diff)
parse function arguments
Diffstat (limited to 'source/mod_student/lexer.mll')
-rw-r--r--source/mod_student/lexer.mll83
1 files changed, 32 insertions, 51 deletions
diff --git a/source/mod_student/lexer.mll b/source/mod_student/lexer.mll
index a62b8ad..806cfb8 100644
--- a/source/mod_student/lexer.mll
+++ b/source/mod_student/lexer.mll
@@ -31,6 +31,7 @@
    *)
 
   let identifier    = ['a'-'z' '_' 'A' - 'Z']['_' 'A' - 'Z' 'a'-'z' '0'-'9']*
+  let integer       = ['0'-'9']*
   
   (* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      ----------------------------------------------------------------------------- *)
@@ -54,60 +55,40 @@
       (* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv 
        * Miejsce na twoje reguły
        *)
-      | "("
-      { LPAREN }
-      | ")"
-      { RPAREN }
-      | "{"
-      { LBRACKET }
-      | "{"
-      { RBRACKET }
-      | ":"
-      { COLON }
-      | "+"
-      { OP_PLUS }
-      | "-"
-      { OP_MINUS }
-      | "*"
-      { OP_MULT }
-      | "/"
-      { OP_DIV }
-      | "%"
-      { OP_REM }
-      | "&"
-      { OP_AND }
-      | "|"
-      { OP_OR }
-      | "=="
-      { OP_EQ }
-      | "!="
-      { OP_NEQ }
-      | "<="
-      { OP_LE }
-      | ">="
-      { OP_GE }
-      | "<"
-      { OP_LT }
-      | ">"
-      { OP_GT }
-      | "="
-      { ASSIGN }
-      | "if"
-      { IF }
-      | "else"
-      { ELSE }
-      | "while"
-      { WHILE }
-      | "return"
-      { RETURN }
-      | "length"
-      { LENGTH }
-      | identifier as id
-      { IDENTIFIER id }
+      | "("       { LPAREN }
+      | ")"       { RPAREN }
+      | "{"       { LBRACKET }
+      | "{"       { RBRACKET }
+      | "["       { LSBRACKET }
+      | "]"       { RSBRACKET }
+      | ":"       { COLON }
+      | "+"       { OP_PLUS }
+      | "-"       { OP_MINUS }
+      | "*"       { OP_MULT }
+      | "/"       { OP_DIV }
+      | "%"       { OP_REM }
+      | "&"       { OP_AND }
+      | "|"       { OP_OR }
+      | "=="      { OP_EQ }
+      | "!="      { OP_NEQ }
+      | "<="      { OP_LE }
+      | ">="      { OP_GE }
+      | "<"       { OP_LT }
+      | ">"       { OP_GT }
+      | "="       { ASSIGN }
+      | "if"      { IF }
+      | "else"    { ELSE }
+      | "while"   { WHILE }
+      | "return"  { RETURN }
+      | "length"  { LENGTH }
+      | "int"     { T_INT }
+      | "bool"    { T_BOOL }
+      | identifier as id  { IDENTIFIER id }
+      | integer as i      { INT (int_of_string i) }
 
       (* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          ----------------------------------------------------------------------------- *)
-  
+      | " " {token lexbuf}
       | _
       { handleError (Lexing.lexeme_start_p lexbuf) (Lexing.lexeme lexbuf) }