snoeathurc.h
This commit is contained in:
@ -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" }
|
||||
|
Reference in New Issue
Block a user