Table of Contents

Module: DumbLispGen Zope-2.2.1-src/lib/python/Products/ZGadflyDA/gadfly/DumbLispGen.py

Imported modules   
import string
Functions   
AddToList
BindRules
DeclareTerminals
DoSetq
EchoValue
GrammarBuild
LoadLispG
MakeList
NilTail
VarValue
echo
intInterp
stripQuotes
  AddToList 
AddToList ( list,  Context )

For a full tail, add the new element to the front of the list

Parser delivers list of form [Value, TailValue]

  BindRules 
BindRules ( Grammar )

This function Binds the named rules of the Grammar string to their interpretation functions in a Grammar.

  DeclareTerminals 
DeclareTerminals ( Grammar )

This function declares the nonterminals both in the "grammar generation phase" and in loading the compiled grammar after generation

  DoSetq 
DoSetq ( list,  Context )

For a setq, declare a new variable in the Context dictionary

Parser delivers list of form # ["(", "setq", varName, Value, ")"]

Exceptions   
TypeError
  EchoValue 
EchoValue ( list,  Context )

EchoValue() serves for Intrule and Strrule, since we just want to echo the value returned by the respective terminal interpretation functions.

Parser delivers list of form [ interpreted_value ]

Exceptions   
TypeError
  GrammarBuild 
GrammarBuild ()

This function generates the grammar and dumps it to a file. Since it will be used only once (after debugging), it probably should be put in another file save memory/load-time.

the result returned is a Grammar Object that can be used for testing/debugging purposes.

(maybe this should be made into a generic function?)

  LoadLispG 
LoadLispG ()

this function initializes the compiled grammar from generated file.

  MakeList 
MakeList ( list,  Context )

For a list, simply return the list determined by the tail

Parser delivers list of form ["(", TailValue ]

Exceptions   
TypeError
  NilTail 
NilTail ( list,  Context )

for an empty tail, return the empty list

Parser delivers list of form [")"]

  VarValue 
VarValue ( list,  Context )

for Varrule interpreter must try to look up the value in the Context dictionary

Parser delivers list of form [ var_name ]

Exceptions   
NameError
TypeError
  echo 
echo ( string )

interpretation function for vars just returns the recognized string

  intInterp 
intInterp ( str )

int interpretation function: translates string to int: Could use string.atoi without the extra level of indirection but for demo purposes here it is.

  stripQuotes 
stripQuotes ( str )

interpretation function for strings strips off the surrounding quotes.


Table of Contents

This document was automatically generated on Mon Sep 4 07:33:06 2000 by HappyDoc version r0_6