The SDF parser (SGLR) reads a file that contains the parse table. The format for this file and its implementation is a part of the SDF bundle. This part is called ptable-support. You will find a definition of the files format in the source code of the package.

The format is versioned for checking compatibility between the tables generated by the parse table generator and tools that read the tables, such as SGLR.

Version 4 Parse Table Format

The version 4 (now outdated) parse table format is explained here. The newer formats are very similar, but some details are different. For now, please refer to the source code for details.

parse-table(<term>,<term>,<term>,states([<list>]),priorities(<term>))
* The first <term> is a version number, currently 4. * The second <term> is the number of the initial state, normally 0. * The third <term> is a list of labels of the form label(<term>,<int>), where <term> represents a production rule and <int> the label number. The production rule is represented as an ATerm and has, e.g., the form: prod([sort("<START>"),char-class([256])],sort("<Start>"),no-attrs) * The states have the form: state-rec(<int>,[<list>],[<list>]) where <int> represents the state number, the first list the list of gotos, and the second list the list of actions. * A goto item looks like goto([<list>],<int>), this list is a list of single characters, character ranges, and/or label numbers. The <int> is the state number to which the parser has to jump. * A action item looks like action([<list>],[<list>]), where the first list is a list of single characters and/or character ranges. The second list are the actions that have to be performed: * reduce(<int>,<int>,<int>): first <int> represents the number of members in of the production rule with label given as second <int>, and the last <int> represent that "status" of a production rule, prefer, avoid, reject, or normal. * reduce(<int>,<int>,<int>,<term>): the <term> represents a lookahead set greater than one. Lookaheads of more than one character are performed dynamically. * shift(<int>): the <int> represent the new state after shifting the current character. * accept * The priorities is a list of relations between 2 production rules: * left-prio(<int>,<int>) * right-prio(<int>,<int>) * non-assoc-prio(<int>,<int>) * gtr-prio(<int>,<int>) where the <int>s are the labels of the production rules involved. left, right, and non-assoc are associativity attributes used within the Tools.SDF definition. gtr is the priority relation.

Revision: r1.8 - 30 Jun 2008 - 18:36 - Main.karltk
Sdf > SDFII? > SglrParseTableFormat
Copyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback