snoeathurc.h

This commit is contained in:
NikolajDanger
2022-05-18 17:29:24 +02:00
parent f0fda0bcd7
commit 5f7c450809
20 changed files with 6298 additions and 2039 deletions

View File

@ -1,5 +1,5 @@
////////////////////////////////////////////////////////////////////
// TODO: project task 1
// TODO: project task 1
// implement lexer tokens for the new operators:
// multiplication (*), division (/), numerical negation (~),
// logical negation (not), logical and (&&), logical or (||),
@ -70,6 +70,16 @@ let keyword (s, pos) =
| "reduce" -> Parser.REDUCE pos
| "read" -> Parser.READ pos
| "write" -> Parser.WRITE pos
(* added: *)
| "not" -> Parser.NOT pos
| "true" -> Parser.BOOLVAL (true, pos)
| "false" -> Parser.BOOLVAL (false, pos)
| "replicate" -> Parser.REPLICATE pos
| "scan" -> Parser.SCAN pos
| "filter" -> Parser.FILTER pos
| _ -> Parser.ID (s, pos)
}
@ -114,5 +124,15 @@ rule Token = parse
| '{' { Parser.LCURLY (getPos lexbuf) }
| '}' { Parser.RCURLY (getPos lexbuf) }
| ',' { Parser.COMMA (getPos lexbuf) }
| '*' { Parser.TIMES (getPos lexbuf) }
| '/' { Parser.DIVIDE (getPos lexbuf) }
| '~' { Parser.NUMNEG (getPos lexbuf) }
| "||" { Parser.OR (getPos lexbuf) }
| "&&" { Parser.AND (getPos lexbuf) }
| ';' { Parser.SEMICOLON (getPos lexbuf) }
| eof { Parser.EOF (getPos lexbuf) }
| _ { lexerError lexbuf "Illegal symbol in input" }