cobol-interpreter-lab/lab-4
Josh 866432d9c9 Merge branch 'main' of gitlab.cs.wallawalla.edu:lustje/language-interpreter-lab into josh_11_7 2024-11-10 16:03:30 -08:00
..
samples variables now parse 2024-11-05 15:59:58 -08:00
Makefile Lab 4 2024-10-23 20:34:04 -07:00
README.md move stuff 2024-10-30 20:27:03 -07:00
main.c Lab 4 2024-10-23 20:34:04 -07:00
main_test.c lab4 tests 2024-11-07 11:47:26 -08:00
parser.bison parse quadratic 2024-11-07 18:18:21 -08:00
scanner.flex Merge branch 'josh_bison' of gitlab.cs.wallawalla.edu:lustje/language-interpreter-lab into josh_bison 2024-11-07 11:06:50 -08:00
token.h fix params? 2024-11-07 10:51:51 -08:00
utest.h Lab 4 2024-10-23 20:34:04 -07:00

README.md

Bison Parser With Tests

Create a scanner for your sample programs with tests. The tests should include basic statements and the sample files for your language. See the example lab for Python.

Build Process

To build the scanner.c run the following flex command.

flex -o scanner.c scanner.flex

The parser is built using bison. Note this command also builds the token.h.

bison --defines=token.h --output=parser.c -v parser.bison

THe -v flag will create a parser.output which represents the grammar in text form.

Running the Parser

Then build the main.c, parcer.c and scanner.c using gcc. Note that you may get a few warnings that can be ignored.

gcc main.c scanner.c  parser.c -o parser.out

Then execute the test suite using ./parser.out and pass in the input from your sample program. For example here is a command for samples/program.c

./parser.out < samples/program.c

Testing the Parser

Then build the main_test.c, parcer.c and scanner.c using gcc. Note that you may get a few warnings that can be ignored.

gcc main_test.c scanner.c  parser.c -o parser_test.out

Then execute the test suite using ./parser_test.out.

./parser_test.out

Using Make

Alternatively you can use the supplied make file.

  • Build main program - make
  • Build test program - make test
  • Clean up build files - make clean

Tests

  • Write test for various statements in your language
    • assignment - Riley
    • print - Josh (write test)
    • mathmatical expressions - Jenessy
    • boolean expressions - Jenessy
    • branching - Josh
    • looping - Riley
  • Write a test for each sample test file.
    • Hello World! - Josh (already done)
    • Quadratic - Jenessy
    • Sorting - Riley

Grading Rubric

The grading will be over the following categories.

Points Description


60 points Ability to parse — Six different language statements 10 points Ability to parse — Hello world 10 points Ability to parse — Quadratic equation 10 points Ability to parse — Integer sorting 10 points Report formatting and readability

Turn In

Please submit the URL of your gitlab project to D2L's Brightspace with your report. On gitlab update the lab-4 folder to have your report and code snippets before the due date.