Advertisement
Guest User

Untitled

a guest
Nov 9th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.65 KB | None | 0 0
  1. {
  2.   open Printf
  3.  
  4.   type token =
  5.     (* tutaj wklej listę tokenów wygenerowanych w _build/default/source/mod_student/parser.mli *)
  6.  
  7.   open Lexing
  8. }
  9.  
  10. (* tutaj lekser *)
  11.  
  12. {
  13.   let main () =
  14.     let lexbuf = Lexing.from_channel stdin in
  15.     while true do
  16.       match token lexbuf with
  17.         (* tutaj sobie printujesz tokeny np. *)
  18.         | STRING str -> printf "STRING(%s) " str
  19.         | IDENTIFIER id -> printf "IDENTIFIER(%s) " id
  20.         | CHAR c -> printf "CHAR(%c) " c
  21.         | NUMBER v -> printf "NUMBER(%d) " v
  22.         | WHILE -> printf "WHILE "
  23.         | EOF -> printf "EOF\n"; exit 0
  24.     done
  25.  
  26.   let _ = Printexc.print main ()
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement