(ocamllex lustreLexer)

(menhir
 (infer false)
 (flags --explain --table)
 (modules lustreParser))

;; The following rule generates "lustreParserErrors.ml" based on the source file
;; "lustreParser.messages". It requires the completeness check to have been
;; performed first.

(rule
  (deps lustreParser.check only-errors.sh)
  (action (with-stdout-to lustreParserErrors.ml
    (run sh ./only-errors.sh menhir
      %{dep:lustreParser.mly}
      --compile-errors %{dep:lustreParser.messages}
    )
  ))
)

;; This rule generates a file "lustreParser.auto.messages" that contains a
;; list of all error states. It is used by the completeness check.

(rule
  (with-stdout-to lustreParser.auto.messages
    (run menhir
       %{dep:lustreParser.mly}
       --list-errors
    )
  )
)

;; This rule implements the completeness check. It checks that every error
;; state listed in the auto-generated file "lustreParser.auto.messages"
;; is also listed in the file "lustreParser.messages".
;; If this rule fails to execute, run [make complete] in this directory to
;; add missing sentences and remove obsolete ones.

(rule
  (deps only-errors.sh)
  (action (with-stdout-to lustreParser.check
    (run sh ./only-errors.sh menhir
      %{dep:lustreParser.mly}
      --compare-errors %{dep:lustreParser.auto.messages}
      --compare-errors %{dep:lustreParser.messages}
    )
  ))
)
