bozsahin / yalalr

yet another LALR parser generator interface

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

yalalr

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:

  1. returns unknown tokens x with type ID, as (ID x), so the lexicon is open-ended.
  2. provides a standard workflow for writing syntax-directed LR translation and code generation, using (make-lalrparser)
  3. uses lalrparser.lisp as is. It is not part of this repo.

To use:

  1. In your current directory, you need a lexical analyzer called lexer and syntax-directed code generator called sdd.lisp. These are automatically loaded when begun. Do:
  2. yalalr from the command line. Once you are in and everthing is ok:
  3. (target-code "x") to generate code for source file x. Alternatively you can call ic-gen for IC generation. They call the lexer to obtain x.tokens, then generate code.

    Use (target-code-mips "x") if you want to generate MIPS code in expr-mips. This one clears the symbol hash table before calling target-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

About

yet another LALR parser generator interface

License:Other


Languages

Language:Common Lisp 51.3%Language:Shell 48.7%