Skip to content

Commit

Permalink
added comprehensive syntax error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
osimon8 committed Mar 19, 2022
1 parent b4da2bf commit 25d2122
Show file tree
Hide file tree
Showing 8 changed files with 622 additions and 18 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ clean:
utop: main.exe
dune utop


generate-messages:
dune build @generate-parser-messages


update-messages:
dune build @update-parser-messages

run:
dune exec --context=default combc code.fpl

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ You can also use the coalesce operator `??`, where `<exp1> ?? <exp2>` is shortha
else
-1

This statement would return -1, since `A=10` and `B=1` and are therefore not numerically equal, even though they are logically equal. Essentially, when you want the value you are handling to be treated as a boolean, use logical equality and inequality.
This statement would return -1, since `A=10` and `B=1` and are therefore not numerically equal, even though they are logically equal. Essentially, when you want the value you are handling to be treated as a boolean, use logical equality and inequality.

### Circuit Bindings

Expand Down
2 changes: 1 addition & 1 deletion combc.opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "0.1.9"
version: "0.2.3"
synopsis: "C-style language that compiles to Factorio combinators"
maintainer: ["Owen Simon <osimon922@gmail.com>"]
authors: ["Owen Simon <osimon922@gmail.com>"]
Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(lang dune 3.0)
(using menhir 2.1)
(name combc)
(version 0.1.9)
(version 0.2.3)
(license "GPL-3.0")
(authors "Owen Simon <osimon922@gmail.com>")
(maintainers "Owen Simon <osimon922@gmail.com>")
Expand Down
54 changes: 43 additions & 11 deletions src/parser/dune
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
(flags -lg 1 -la 1 -lc 2)
)

(menhir
(modules unitActionsParser)
(flags --table --external-tokens Parser)
)

(rule
(action
(with-stdout-to unitActionsParser.mly
Expand All @@ -18,17 +23,44 @@
--only-preprocess-u
))))

(menhir
(modules unitActionsParser)
(flags --table --external-tokens Parser)
)
(rule
(with-stdout-to
parser.messages.new
(run
menhir
%{dep:parser.mly}
--base
parser
--list-errors)))

(rule
(with-stdout-to
parser_errors.ml
(run
menhir
%{dep:parser.mly}
--base
parser
--compile-errors
%{dep:parser.messages})))

(rule
(action (with-stdout-to errors.ml
(run menhir
%{dep:parser.mly}
--compile-errors %{dep:errors.messages}
)
))
)
(with-stdout-to
parser.messages.updated
(run
menhir
%{dep:parser.mly}
--base
parser
--update-errors
%{dep:parser.messages})))

(rule
(alias update-parser-messages)
(action
(diff parser.messages parser.messages.updated)))

(rule
(alias generate-parser-messages)
(action
(diff parser.messages parser.messages.new)))
3 changes: 0 additions & 3 deletions src/parser/errors.messages

This file was deleted.

2 changes: 1 addition & 1 deletion src/parser/parse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let fail text buffer (checkpoint : _ I.checkpoint) =
let err = (E.show (show text) buffer) in
let indication = sprintf "Syntax error %s.\n" err in
try
let message = Errors.message (state checkpoint) in
let message = Parser_errors.message (state checkpoint) in
let message = E.expand (get text checkpoint) message in
eprintf "%s%s%s" location indication message;
exit 1
Expand Down
Loading

0 comments on commit 25d2122

Please sign in to comment.