(ocamllex
  (modules lexer)
)

; Compile tokens.mly into a definition of the type [token].
(menhir
  (modules tokens)
  (flags --only-tokens)
)

; Compile reverse.mly into a parser.
(menhir
  (modules tokens reverse common)
  (merge_into reverse)
  (flags
     --external-tokens Tokens
     --unused-token LPAREN
     --unused-token RPAREN
  )
)

; Compile algebraic.mly into a parser.
(menhir
  (modules tokens algebraic common)
  (merge_into algebraic)
  (flags --external-tokens Tokens)
)

(executable
  (name calc)
)

(rule
  (with-stdout-to algebraic.out
  (with-stdin-from algebraic.in
    (run ./calc.exe --algebraic)
  ))
)

(rule
  (alias test)
  (action (diff algebraic.exp algebraic.out))
)

(rule
  (with-stdout-to reverse.out
  (with-stdin-from reverse.in
    (run ./calc.exe --reverse)
  ))
)

(rule
  (alias test)
  (action (diff reverse.exp reverse.out))
)
