yet another LALR parser-generator interface
This is an interface to Mark Johnson's LALR parser generator.
The installer can download and install (1) lalrparser.lisp, (2) a suitable Common Lisp if desired, and (3) set itself up to be used from any directory.
Just clone this repo and do ./install
.
Some features of yalalr
:
- returns unknown tokens
x
with type ID, as(ID x)
, so the lexicon is open-ended. - provides a standard workflow for writing syntax-directed LR translation and code generation, using
(make-lalrparser)
- uses
lalrparser.lisp
as is. It is not part of this repo.
To use:
- In your current directory, you need a lexical analyzer called
lexer
and syntax-directed code generator calledsdd.lisp
. These are automatically loaded when begun. Do: -
yalalr
from the command line. Once you are in and everthing is ok: -
(target-code "x")
to generate code for source filex
. Alternatively you can callic-gen
for IC generation. They call the lexer to obtainx.tokens
, then generate code.Use
(target-code-mips "x")
if you want to generate MIPS code inexpr-mips
. This one clears the symbol hash table before callingtarget-code
.
You will get a warning in the beginning if the lexer
or the sdd.lisp
files do not exist.
You get the same warning if lexer is not an executable. You can set them manually as follows:
a. set the *lexer*
Lisp variable to your lexer binary. Make sure it follows the same i/o convention of
reading the characters from a file fn
and writing the tokens to fn.tokens
wrapped in (..).
b. set the grammar, lexicon, lexforms
variables of lalrparser.lisp
as you see fit.
c. do (make-lalrparser)
. Now LALR tables are set. You are at step 2 above.
enjoy. -cem bozsahin