Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- open Printf
- type token =
- (* tutaj wklej listę tokenów wygenerowanych w _build/default/source/mod_student/parser.mli *)
- open Lexing
- }
- (* tutaj lekser *)
- {
- let main () =
- let lexbuf = Lexing.from_channel stdin in
- while true do
- match token lexbuf with
- (* tutaj sobie printujesz tokeny np. *)
- | STRING str -> printf "STRING(%s) " str
- | IDENTIFIER id -> printf "IDENTIFIER(%s) " id
- | CHAR c -> printf "CHAR(%c) " c
- | NUMBER v -> printf "NUMBER(%d) " v
- | WHILE -> printf "WHILE "
- | EOF -> printf "EOF\n"; exit 0
- done
- let _ = Printexc.print main ()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement