C Syntax Tree Format

Input

<input> ::= parseError
 | [<compilation unit>]

Compilation Units

<compilation unit> ::= <phrase>
 | <directive>
 | fDeclare(<phrase> <phrase> <coord>)

<directive> ::= dirSwitch([<switch>])
 | dirPushSwitches
 | dirPopSwitches
 | dirLocalSwitches

<switch> ::= on(<switch name> <coord>)
 | off(<switch name> <coord>)

<switch name> ::= <atom>

C.1 The Base Language

Phrases

At the syntactical level, statements can in general not be distinguished from expressions. Both are subsumed by <phrase>.

<phrase> ::= fStepPoint(<phrase> <atom> <coord>)
 | fAnd(<phrase> <phrase>)
 | fEq(<phrase> <phrase> <coord>)
 | fAssign(<phrase> <phrase> <coord>)
 | fOrElse(<phrase> <phrase> <coord>)
 | fAndThen(<phrase> <phrase> <coord>)
 | fOpApply(<atom> [<phrase><coord>)
 | fOpApplyStatement(<atom> [<phrase>]
                  <coord>)
 | fObjApply(<phrase> <phrase> <coord>)
 | fAt(<phrase> <coord>)
 | <atom literal>
 | <variable>
 | <wildcard>
 | fSelf(<coord>)
 | fDollar(<coord>)
 | <int literal>
 | fFloat(<float> <coord>)
 | fRecord(<label> [<record argument>])
 | fOpenRecord(<label> [<record argument>])
 | fApply(<phrase> [<phrase><coord>)
 | fProc(<phrase> [<phrase><phrase>
      [<proc flag><coord>)
 | fFun(<phrase> [<phrase><phrase>
      [<proc flag><coord>)
 | fFunctor(<phrase> [<functor descriptor><coord>)
 | fClass(<phrase> [<class descriptor>]
       [<meth><coord>)
 | fLocal(<phrase> <phrase> <coord>)
 | fBoolCase(<phrase> <phrase> <opt else> <coord>)
 | fCase(<phrase> [<case clause>]
      <opt else> <coord>)
 | fLockThen(<phrase> <phrase> <coord>)
 | fLock(<phrase> <coord>)
 | fThread(<phrase> <coord>)
 | fTry(<phrase> <catch> <finally> <coord>)
 | fRaise(<phrase> <coord>)
 | fSkip(<coord>)

<label> ::= <atom literal>
 | <naked variable>

<atom literal> ::= fAtom(<literal> <coord>)

<naked variable> ::= fVar(<atom> <coord>)

<variable> ::= <naked variable>
 | fEscape(<naked variable> <coord>)

<wildcard> ::= fWildcard(<coord>)

<int literal> ::= fInt(<int> <coord>)

<record argument> ::= <phrase>
 | fColon(<feature> <phrase>)

For the moment, the only recognized flags are instantiate, lazy, dynamic, and native.

<proc flag> ::= <atom>

Functors

<functor descriptor> ::= fRequire([<import decl><coord>)
 | fPrepare(<phrase> <phrase> <coord>)
 | fImport([<import decl><coord>)
 | fExport([<export decl><coord>)
 | fDefine(<phrase> <phrase> <coord>)

<import decl> ::= fImportItem(<naked variable> [<aliased feature>]
            <opt import at>)

<aliased feature> ::= <feature no var>
 | <naked variable>#<feature no var>

<opt import at> ::= fNoImportAt
 | fImportAt(<atom literal>)

<export decl> ::= fExportItem(<export item>)

<export item> ::= <naked variable>
 | fColon(<feature no var> <naked variable>)

Classes

<class descriptor> ::= fFrom([<phrase><coord>)
 | fProp([<phrase><coord>)
 | fAttr([<attr or feat><coord>)
 | fFeat([<attr or feat><coord>)

<attr or feat> ::= <escaped feature>
 | <escaped feature>#<phrase>

<meth> ::= fMeth(<meth head> <phrase> <coord>)

<meth head> ::= <meth head 1>
 | fEq(<meth head 1> <naked variable> <coord>)

<meth head 1> ::= 
    <atom literal>
 | <variable>
 | fRecord(<meth head label> [<meth argument>])
 | fOpenRecord(<meth head label> [<meth argument>])

<meth head label> ::= <atom literal>
 | <variable>

<meth argument> ::= 
    fMethArg(<meth arg term> <default>)
 | fMethColonArg(<feature> <meth arg term> <default>)

<meth arg term> ::= <naked variable>
 | <wildcard>
 | fDollar(<coord>)

<default> ::= fNoDefault
 | fDefault(<phrase> <coord>)

Features

<feature no var> ::= <atom literal>
 | <int literal>

<feature> ::= <feature no var>
 | <naked variable>

<escaped feature> ::= <feature no var>
 | <variable>

Other

<case clause> ::= fCaseClause(<pattern> <phrase>)

<pattern> ::= <phrase>
 | fSideCondition(<phrase> <phrase> <phrase> <coord>)

<catch> ::= fNoCatch
 | fCatch([<case clause><coord>)

<finally> ::= fNoFinally
 | <phrase>

<opt else> ::= fNoElse(<coord>)
 | <phrase>

Coordinates

Each triple consisting of an <atom> and two <int>s denotes a file name ('' if none known), a line number (starting at 1; required) and a column number (starting at 0; ~1 if none known). If two triples are given, then they denote the starting and ending coordinates of a construct. A pos may be turned into a fineStep or a coarseStep, denoting a step point for debugging. unit is an unknown coordinate.

<coord> ::= pos(<atom> <int> <int>)
 | pos(<atom> <int> <int> <atom> <int> <int>)
 | fineStep(<atom> <int> <int>)
 | fineStep(<atom> <int> <int> <atom> <int> <int>)
 | coarseStep(<atom> <int> <int>)
 | coarseStep(<atom> <int> <int> <atom> <int> <int>)
 | unit

C.2 Finite Domain Extensions and Combinators

<phrase> += <fd expression>
 | fFail(<coord>)
 | fNot(<phrase> <coord>)
 | fCond([<clause><opt else> <coord>)
 | fOr([<clause opt then><coord>)
 | fDis([<clause opt then><coord>)
 | fChoice([<phrase><coord>)

<fd expression> ::= 
    fFdCompare(<atom> <phrase> <phrase> <coord>)
 | fFdIn(<atom> <phrase> <phrase> <coord>)

<clause> ::= fClause(<phrase> <phrase> <phrase>)

<clause opt then> ::= fClause(<phrase> <phrase> <opt then>)

<opt then> ::= fNoThen(<coord>)
 | <phrase>

C.3 Gump Extensions

<compilation unit> += 
    fSynTopLevelProductionTemplates([<prod clause>])

<phrase> += fScanner(<naked variable>
         [<class descriptor>] [<meth>]
         [<scanner rule><atom> <coord>)
 | fParser(<naked variable>
        [<class descriptor>] [<meth>]
        <token clause> [<parser descriptor><int>
        <coord>)

<grammar symbol> ::= <atom literal>
 | <naked variable>

Scanners

<scanner rule> ::= fMode(<naked variable> [<mode descriptor>])
 | <lex clause>

<mode descriptor> ::= fInheritedModes([<naked variable>])
 | <lex clause>

<lex clause> ::= fLexicalAbbreviation(<grammar symbol> <regex>)
 | fLexicalRule(<regex> <phrase>)

<regex> ::= <string>

Parsers

<token clause> ::= fToken([<token decl>])

<token decl> ::= <atom literal>
 | <atom literal>#<phrase>

<parser descriptor> ::= <prod clause>
 | <syntax rule>

<prod clause> ::= 
    fProductionTemplate(<prod key> [<prod param>]
                    [<syntax rule>] [<syn expression>]
                    [<prod ret>])

<prod param> ::= <naked variable>
 | <wildcard>

<prod key> ::= none#<string>
 | <atom>#<string>

<prod ret> ::= none
 | <naked variable>
 | fDollar(<coord>)

<syntax rule> ::= fSyntaxRule(<grammar symbol> [<syn formal>]
            <syn expression>)

<syn formal> ::= <naked variable>
 | <wildcard>
 | fDollar(<coord>)

<syn expression> ::= 
    fSynApplication(<grammar symbol> [<phrase>])
 | fSynAction(<phrase>)
 | fSynSequence([<naked variable>] [<syn expression>])
 | fSynAlternative([<syn expression>])
 | fSynAssignment(<variable> <syn expression>)
 | fSynTemplateInstantiation(<prod key> [<syn expression>]
                          <coord>)


Leif Kornstaedt
Version 1.1.0 (20000207)