Now that a full-fledged lexer and parser for our TOY language grammar are defined, it's time to run it on example TOY language.
To do this, you should have understanding of TOY language grammar and all the previous recipes of this chapter.
Run and test the Lexer and Parser on TOY Language, as shown in the following:
First step is to compile the
toy.cpp
program into an executable:$ clang++ toy.cpp -O3 -o toy
The
toy
executable is our TOY compiler frontend. Thetoy
language to be parsed is in a file calledexample
:$ cat example def foo(x , y) x + y * 16
This file is passed as argument to be processed by the
toy
compiler:$ ./toy example