This patch set adds some pieces that were missing in the unified
parser and then replaces the DIY parser in compiler.c
The new parser accepts all the old patches, with all their
syntactical quirks. No rule without exception: "Balk Acid (DMX
madness)" had the same typo as the original "Balk Acid", which
needs to be fixed before the parser will use it.
With the unified parser, the compiler is currently about 20%
slower than the old one, but there's still more cleanup to do
that will improve the speed.
What the unified parser already offers is much better error
checking and reporting. Once can also compile the parser for
the host and use it for quick syntax checking:
cd src/compiler
make
ptest/ptest -q <patchfile.fnp
-q selects quiet mode, in which only errors get reported. ptest
normally dumps the parse tree on standard output, which is used
in the regression tests.
There are currently the following small language differences:
- /* ... */ comments are supported in addition to // coments
- per_frame= and per_vertex= switch to the respective segment
for all the assignments that follow, unless overridden by
another per_frame or per_vertex. This means that the following
construct wouldn't work as expected:
per_frame=foo=1 // per-frame
bar=2 // still per-frame, not global
Fortunately, none of the patches do something like this.
- semicolons are optional also when there are multiple
assignments within the same line. E.g., this works:
sx=1 sy=2
- newlines can be anywhere where whitespace is allowed, so long
equations can be broken down into several lines
- whitespace around image file name is removed
The patches still look pretty much as they always did, but it
would be surprising if I hadn't introduced any bugs with this
large change.
Items still left to do:
- improve the syntax (nicer "if", relational operators, etc.)
- optimize
- assorted cleanup
- make either sure we can print " with MTK or reliably remove
all double quotes from messages
- look for memory leaks (there should be many)
- Werner
Werner Almesberger (17):
compiler: don't feed TOK_ERROR to the parser
compiler: report the line number and the context of an error
compiler: remove trailing whitespace
compiler: return error string from fpvm_parse
compiler: fix multiple /* ... */ comments
compiler: bring out errors encountered by things called from parser
compiler: moved prologue and epilogue to almost regular .fnp files
compiler: ignore [preset]
compiler: infrastructure for supporting fragment selection prefixes
compiler: support parsing imagefileN as well
compiler: dirty hacks to work around syntax problems in patches
compiler: make regression tester support per_frame and per_vertex as
well
patches: fix syntax error in Balk Acid (DMX madness)
compiler: don't regularly use " in error messages; nicer format
compiler: replace the DIY parser in compiler.c
compiler: remove fpvm_assign
compiler: parse all patches in the regression test
...astar & Idiot24-7 - Balk Acid (DMX madness).fnp | 2 +-
src/Makefile | 9 +-
src/compiler/compiler.c | 309 ++++++--------------
src/compiler/compiler.h | 6 +-
src/compiler/file2h | 9 +
src/compiler/finish-pfv.fnp | 19 ++
src/compiler/finish-pvv.fnp | 57 ++++
src/compiler/fpvm.c | 42 ++-
src/compiler/fpvm.h | 3 -
src/compiler/init-pvv.fnp | 22 ++
src/compiler/parser.y | 71 ++++-
src/compiler/parser_helper.c | 80 +++++-
src/compiler/parser_helper.h | 23 ++-
src/compiler/parser_itf.h | 7 +-
src/compiler/ptest/Makefile | 2 +-
src/compiler/ptest/ptest.c | 76 +++++-
src/compiler/scanner.h | 11 +
src/compiler/scanner.re | 150 +++++++---
src/compiler/test/comment | 27 ++-
src/compiler/test/error | 15 +-
src/compiler/test/image | 69 +++++
src/compiler/test/location | 158 ++++++++++
src/compiler/test/number | 3 +-
src/compiler/test/patches | 78 +++++
src/compiler/test/prefix | 33 ++
src/compiler/test/wrap | 4 +-
26 files changed, 947 insertions(+), 338 deletions(-)
create mode 100755 src/compiler/file2h
create mode 100644 src/compiler/finish-pfv.fnp
create mode 100644 src/compiler/finish-pvv.fnp
create mode 100644 src/compiler/init-pvv.fnp
create mode 100755 src/compiler/test/image
create mode 100755 src/compiler/test/location
create mode 100755 src/compiler/test/patches
create mode 100755 src/compiler/test/prefix
_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode