Add GNU bison input file jamexp.y and unit test program for generated jamexp.c
commit7fe25ce948b38a5512b8e82d38d090e88889d068
authorPeter Pöschl <pp+ujt2208@nest-ai.de>
Sat, 13 Aug 2022 13:13:50 +0000 (13 15:13 +0200)
committerGeert Stappers <stappers@stappers.nl>
Tue, 20 Sep 2022 16:38:21 +0000 (20 18:38 +0200)
treedb33e59ad77c141959e17923b5213cc42b8ef888
parent451fe65300b4ccf0353b45e162960edd2b002979
Add GNU bison input file jamexp.y and unit test program for generated jamexp.c

Note: jamexp.y uses GNU extensions of the YACC grammar as defined by GNU bison

Reverse-engineering steps and inputs:

* Write a unit test program (driver jamexp_gen.c) using a jamexp.c generated
  from jamexp.y with bison and the test functions in jamexp_shrd.c

** Copy old jamexp.c to jamexp.y, remove generated tables and replace with
   directives for the Bison parser generator.
** Use operator precedences from the Stapl specification [1] and the grammar
   of the C language [2] to derive the grammar for the Stapl expression parser.
** Fix grammar errors by comparing the parser debug outputs with corresponding
   outputs of the test driver for the non-generated jamexp.c
** Repeat until all tests succeed.

[1] http://www.jtagtest.com/pdf/jesd71_stapl.pdf
[2] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf

Integration hints:

* must be compiled as a 32-bit executable ('gcc -m32' was used)
* 'export URJ_JAM_YYDEBUG=1' before calling the test driver will
  generate parser debug information

* CPP options:

** -DURJ_JAM_YYDEBUG=1 # debug output from $(BISON_OUT_DIR)/jamexp.c
** --include config.h
** -Iinclude           # "urjtag/gettext.h"
** -Isrc/stapl
** -Itests/stapl
** -I.                 # "tests/tap/macros.h" in tests/tap/basic.c/basic.h
** -I($BISON_OUT_DIR)

* Bison options:

** --report=all --warnings=all --debug --defines=$(BISON_OUT_DIR)/jamytab.h

* Source files:

** tests/stapl/jamexp_gen.c     # defines main()
** src/stapl/jamarray.c
** src/stapl/jamcomp.c
** src/stapl/jamexec.c
** $(BISON_OUT_DIR)/jamexp.c
** src/stapl/jamheap.c
** src/stapl/jamjtag.c
** src/stapl/jamstack.c
** src/stapl/jamsym.c
** tests/stapl/jamexp_shrd.c
** tests/tap/basic.c

* Libraries:
** libm

Signed-off-by: Peter Pöschl <pp+ujt2208@nest-ai.de>
urjtag/src/stapl/jamexp.y [new file with mode: 0644]
urjtag/tests/stapl/jamexp_gen.c [new file with mode: 0644]