Common Lisp Package: NAIVE-PARSER-GENERATOR

README:

FUNCTION

Public

* (&REST NUMBERS)

Return the product of its arguments. With no args, returns 1.

+ (&REST NUMBERS)

Return the sum of its arguments. With no args, returns 0.

GENERATE-GRAMMAR (&OPTIONAL (EQUAL-P #'STRING-EQUAL))

Return a GRAMMAR structure suitable for the PARSE function, using the current rules. EQUAL-P, if present, is a function to be used to match the input tokens; it defaults to STRING-EQUAL.

GRAMMAR-KEYWORD-P (KEYWORD GRAMMAR)

Check if KEYWORD is part of this grammar.

PARSE (GRAMMAR START TOKENIZER)

Match a GRAMMAR against the list of input tokens coming from TOKENIZER. Return the reduced values according to the nonterminal actions. Raise an error on failure.

RESET-GRAMMAR

Empty the current grammar from any existing rule.

TOKEN-POSITION (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

TOKEN-TYPE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

TOKEN-VALUE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

Undocumented

MAKE-TOKEN (&KEY ((TYPE DUM118) NIL) ((VALUE DUM119) NIL) ((POSITION DUM120) NIL))

SETFTOKEN-POSITION (NEW-VALUE INSTANCE)

SETFTOKEN-TYPE (NEW-VALUE INSTANCE)

SETFTOKEN-VALUE (NEW-VALUE INSTANCE)

Private

CREATE-RULE (NAME PRODUCTION-DESCRIPTIONS)

Return a new rule object together with a list of keywords making up the production definitions.

DEFINE-RULE (NAME PRODUCTIONS)

Accept a rule in EBNF-like syntax, translate it into a sexp and a call to INSERT-RULE-IN-CURRENT-GRAMMAR.

EBNF-TO-SEBNF (TOKENS)

Take a production as a list of TOKENS and expand it. This turns a EBNF syntax into a sexp-based EBNF syntax or SEBNF.

EXPAND-PRODUCTION-TOKEN (TOK)

Translate token of the type NAME? or NAME* or NAME+ into (? NAME) or (* NAME) or (+ NAME). This is used by the DEFRULE macro.

GRAMMAR-EQUAL-P (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

GRAMMAR-KEYWORDS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

GRAMMAR-RULES (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

INSERT-RULE-IN-CURRENT-GRAMMAR (NAME PRODUCTIONS)

Add rule to the current grammar and its keywords to the keywords hash table. You don't want to use this directly. See DEFRULE macro instead.

MAKE-ACTION-ARGUMENTS (TOKENS)

Given a list of tokens making up a production, return three values: the list of variables for the function reducing this production, those that are non static and their unambiguous user-friendly names.

MAKE-ACTION-FUNCTION (NAME TOKENS ACTION)

Create a function with name NAME, arguments derived from TOKENS and body ACTION. Return it's definition.

MAKE-ALTERNATIVE-RULE (TOKENS)

Make a rule for a list of alternatives ("or" syntax) and return it.

MAKE-DEFAULT-ACTION-FUNCTION (NAME TOKENS)

Create a sexp to be used as default action in case one is not supplied in the production. This is usually a quite sensible one. That is, only the non-constant tokens are returned in a list and in case only a variable token is available that one is returned (not included in a list). If all the tokens are constant, then all of them are returned in a list.

MAKE-LIST-RULE (TOKEN &OPTIONAL SEPARATOR)

Make a rule for a possibly empty list (* syntax) return it.

MAKE-NONEMPTY-LIST-RULE (TOKEN &OPTIONAL SEPARATOR)

Make a rule for a non-empty list (+ syntax) and return it.

MAKE-OPTIONAL-RULE (TOKEN)

Make a rule for a possibly missing (non)terminal (? syntax) and return it.

MAKE-PRODUCTION-FROM-DESCR (NAME PRODUCTION-DESCRIPTION)

Take a production NAME and its description in the form of a sexp and return a production structure object together with a list of used keywords.

MAKE-RULE-PRODUCTIONS (RULE-NAME PRODUCTION-DESCRIPTIONS)

Return a production object that belongs to RULE-NAME made according to PRODUCTION-DESCRIPTIONS. See also MAKE-PRODUCTION-FROM-DESCR.

PROD-ACTION (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

PROD-TOKENS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

PROD-TOKENS-LENGTH (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

REDUCE-PRODUCTION (PRODUCTION ARGUMENTS)

Apply PRODUCTION's action on ARGUMENTS. This has the effect of "reducing" the production.

REMOVE-IMMEDIATE-LEFT-RECURSIVITY (RULE)

Turn left recursive rules of the type A -> A x | y into A -> y A2 A2 -> x A2 | E where E is the empty production.

RESOLVE-NONTERMINALS (TOKENS RULES)

Given a list of production tokens, try to expand the nonterminal ones with their respective rule from the the RULES pool.

RULE-NAME (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

RULE-PRODUCTIONS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SEBNF-TO-BNF (TOKENS)

Take a production in SEBNF (Symbolic Extended BNF) syntax and turn it into BNF. The production is simplified but the current grammar is populated with additional rules.

Undocumented

ADD-GRAMMAR (NAME GRAMMAR)

ADD-KEYWORD (KEYWORD KEYWORDS)

ADD-RULE (RULE-NAME RULE RULES)

CONST-TERMINAL-P (OBJECT)

COPY-GRAMMAR (INSTANCE)

COPY-PRODUCTION (INSTANCE)

COPY-RULE (INSTANCE)

COPY-TOKEN (INSTANCE)

DELETE-GRAMMAR (NAME)

FIND-GRAMMAR (NAME)

FIND-KEYWORD (KEYWORD-NAME KEYWORDS)

FIND-RULE (RULE-NAME RULES)

SETFGRAMMAR-EQUAL-P (NEW-VALUE INSTANCE)

SETFGRAMMAR-KEYWORDS (NEW-VALUE INSTANCE)

GRAMMAR-P (OBJECT)

SETFGRAMMAR-RULES (NEW-VALUE INSTANCE)

MAKE-GRAMMAR (&KEY ((RULES DUM0) NIL) ((KEYWORDS DUM1) NIL) ((EQUAL-P DUM2) NIL))

MAKE-KEYWORDS-TABLE

MAKE-PRODUCTION (&KEY ((TOKENS DUM78) NIL) ((TOKENS-LENGTH DUM79) 0) ((ACTION DUM80) NIL))

MAKE-RULE (&KEY ((NAME DUM40) NIL) ((PRODUCTIONS DUM41) NIL))

MAKE-RULES-TABLE

SETFPROD-ACTION (NEW-VALUE INSTANCE)

SETFPROD-TOKENS (NEW-VALUE INSTANCE)

SETFPROD-TOKENS-LENGTH (NEW-VALUE INSTANCE)

PRODUCTION-P (OBJECT)

REMOVE-LEFT-RECURSIVITY-FROM-RULES (RULES)

RESOLVE-ALL-NONTERMINALS (RULES)

SETFRULE-NAME (NEW-VALUE INSTANCE)

RULE-P (OBJECT)

SETFRULE-PRODUCTIONS (NEW-VALUE INSTANCE)

TOKEN-P (OBJECT)

MACRO

Public

DEFRULE (NAME &REST PRODUCTIONS)

Wrapper macro for DEFINE-RULE.

Undocumented

OR (&REST FORMS)

GENERIC-FUNCTION

Public

LATER-POSITION (POS1 POS2)

Compare two file postions and return true if POS1 is later than POS2 in the input stream.

Private

TERMINALS-IN-GRAMMAR (GRAMMAR-OR-HASHTABLE)

Find non constant terminal symbols in GRAMMAR.

VARIABLE

Public

* (&REST NUMBERS)

the value of the most recent top level EVAL

+ (&REST NUMBERS)

the value of the most recent top level READ

Private

*DEBUG*

Either nil or a stream where to write the debug informations.

*SMART-DEFAULT-REDUCTION*

If true the default reductions take only the non-static tokens - those that are not declared as strings in the grammar.

Undocumented

*GRAMMARS*

*KEYWORDS*

*RULES*

CLASS

Public

Undocumented

GRAMMAR

Private

Undocumented

PRODUCTION

RULE

TOKEN