Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Related Pages

Compiler - compile a constraint grammar


Detailed Description

Author:
Michael Daum (see also AUTHORS and THANKS for more)
Id
compile.c,v 1.87 2004/10/04 14:36:12 micha Exp

This module implements a compiler in order to translate constraints into C code.


Data Structures

struct  ApproverStruct
struct  CompilerStruct
struct  MakeInfoStruct

Defines

#define FINIT_GRAMMAR   "finitGrammar"
#define INIT_GRAMMAR   "initGrammar"

Typedefs

typedef ApproverStructApprover
typedef CompilerStructCompiler
typedef CompilerStruct CompilerStruct
typedef MakeInfoStructMakeInfo
typedef MakeInfoStruct MakeInfoStruct

Enumerations

enum  ReturnType {
  RTBoolean = (1L << 0), RTNumber = (1L << 1), RTString = (1L << 2), RTAVNode = (1L << 3),
  RTList = (1L << 4), RTConjunction = (1L << 5), RTDisjunction = (1L << 6), RTError = (1L << 7),
  RTLexemNode = (1L << 8), RTGraphemNode = (1L << 9), RTNoError = (1L << 10), RTPeek = (1L << 11),
  RTLexemPosition = (1L << 12)
}

Functions

void comAnalyzeGrammar (void)
void comApprove (int no, char **args)
Boolean comCompareAllLvPairs (Approver, ConstraintNet net)
Boolean comCompareAllLvs (Approver, ConstraintNet, ConstraintNet)
Boolean comCompareLvs (LevelValue, LevelValue)
Boolean comCompareNets (Approver, ConstraintNet, ConstraintNet)
Boolean comCompareWithContext (Approver, ConstraintNet net, List contextList)
String comCompile (int no, char **args)
String comConnextionToString (Connexion)
int comConstraintDepth (Constraint)
String comDirectionToString (Direction)
String comEscapeQuotes (String)
void comFinalize (void)
LevelValue comFindComparableLv (ConstraintNet, LevelValue)
void comFinitGrammar (Input thisInput)
int comFormulaDepth (Formula)
String comFormulaTypeToString (Formula)
void comFree (Compiler)
void comFreeApprover (Approver)
int comFunctionDepth (String, List)
void comIndent (void)
int comIndexOfConstraint (String)
int comIndexOfHierarchy (String)
int comIndexOfVarInfo (VarInfo)
Boolean comInitGrammar (Input thisInput)
void comInitialize (void)
Input comLoad (String filename)
Boolean comMake (void)
void comMakeInfoFree (MakeInfo)
MakeInfo comMakeInfoNew (void)
int comMaxLookupStrings (Constraint)
int comMaxLookupStringsInFormula (Formula)
int comMaxLookupStringsInTerm (Term)
Compiler comNew (void)
Approver comNewApprover (void)
void comOutdent (void)
int comPredicateDepth (String, List)
void comPrint (String,...)
void comPrintln (String,...)
int comRegisterString (String)
ReturnType comReturnTypeOfFormula (Formula)
ReturnType comReturnTypeOfFunction (String, List)
ReturnType comReturnTypeOfPredicate (String, List)
ReturnType comReturnTypeOfTerm (Term)
String comReturnTypeToString (ReturnType)
int comTermDepth (Term)
String comTermTypeToString (Term)
Boolean comTranslate (void)
void comTranslateAbs (List, int)
void comTranslateArithmetics (Term, int)
void comTranslateBetween (String, List, int)
void comTranslateBinaryConstraints (void)
void comTranslateBottomPeek (Term, int)
void comTranslateChunkHead (String, List, int)
void comTranslateConnected (String, List, int)
void comTranslateConnexion (Formula)
void comTranslateConstraint (Constraint)
void comTranslateDirection (Formula)
void comTranslateDistance (List, int)
void comTranslateEquation (Formula, int)
void comTranslateExists (List)
void comTranslateFormula (Formula, int)
void comTranslateFunction (String, List, int)
void comTranslateGuard (String, List, int)
void comTranslateHas (String, List, int)
void comTranslateHeight (List, int)
void comTranslateIs (String, List, int)
void comTranslateLexemNodeAccess (Term, int)
void comTranslateLexicalAccess (Term)
void comTranslateLookup (List, int)
void comTranslateMatch (List, int)
void comTranslateMinMax (String, List, int)
void comTranslateNumber (Term, int)
void comTranslateParens (List, int)
void comTranslateParent (List, int)
void comTranslatePhrasequotes (List, int)
void comTranslatePredicate (String, List, int)
void comTranslatePrint (List, int)
void comTranslatePts (List, int)
void comTranslateQuotes (List, int)
void comTranslateStartStop (String, List, int)
void comTranslateString (Term, int)
void comTranslateSubsumes (String, List, int)
void comTranslateTerm (Term, Boolean, Boolean, int)
void comTranslateTopPeek (Term, int)
void comTranslateUnaryConstraints (void)
void comTranslateUnder (String, List, int)
void comTranslateUnEquation (Formula, int)
String comValueTypeToString (Value)
void comWriteDeclarations (void)
void comWriteError (String,...)
void comWriteFinitFunction (void)
void comWriteFunctions (void)
void comWriteHeader (void)
void comWriteInitFunction (void)
void comWriteWarning (String,...)

Variables

Compiler com
MakeInfo makeInfo


Define Documentation

#define FINIT_GRAMMAR   "finitGrammar"
 

abbrev. Definition at line 51 of file compile.c.

Referenced by comFinitGrammar(), comWriteDeclarations(), and comWriteFinitFunction().

#define INIT_GRAMMAR   "initGrammar"
 

abbrev. Definition at line 50 of file compile.c.

Referenced by comInitGrammar(), comWriteDeclarations(), and comWriteInitFunction().


Typedef Documentation

typedef ApproverStruct* Approver
 

type of an Approver Definition at line 89 of file compile.c.

Referenced by comApprove(), and comNewApprover().

typedef struct CompilerStruct* Compiler
 

type of a Compiler Definition at line 76 of file compile.c.

Referenced by comFree(), and comNew().

typedef struct CompilerStruct CompilerStruct
 

definition of a CDG compiler object.

typedef struct MakeInfoStruct* MakeInfo
 

A Pointer to a MakeInfoStruct Definition at line 106 of file compile.c.

Referenced by comMakeInfoFree(), and comMakeInfoNew().

typedef struct MakeInfoStruct MakeInfoStruct
 

default make settings. This structure bundles all the information that is needed to compile and link a binary CDG grammar. This is called MakeInfo in according to the normal place where such information is kept.


Enumeration Type Documentation

enum ReturnType
 

possible return types of formulas, predicates, functions, terms.

Enumeration values:
RTBoolean  Boolean return type
RTNumber  Number return type
RTString  String return type
RTAVNode  AVNode return type
RTList  List return type
RTConjunction  Conjunction return type
RTDisjunction  Disjunction return type
RTError  Syntax error "return type"
RTLexemNode  LexemNode return type
RTGraphemNode  GraphemNode return type
RTNoError  indicate that no error is possible in the returning function
RTPeek  indicate a lexicon access in the returning function
RTLexemPosition  indicate the position where the returning function is peeking 0: modifier, 1: modifiee
Definition at line 111 of file compile.c.

Referenced by comReturnTypeOfFormula(), comReturnTypeOfFunction(), comReturnTypeOfPredicate(), comReturnTypeOfTerm(), comTranslateAbs(), comTranslateArithmetics(), comTranslateBetween(), comTranslateChunkHead(), comTranslateConnected(), comTranslateConstraint(), comTranslateDistance(), comTranslateEquation(), comTranslateFormula(), comTranslateGuard(), comTranslateHas(), comTranslateIs(), comTranslateLookup(), comTranslateMatch(), comTranslateMinMax(), comTranslateParens(), comTranslateParent(), comTranslatePhrasequotes(), comTranslatePrint(), comTranslateQuotes(), comTranslateStartStop(), comTranslateSubsumes(), comTranslateTerm(), comTranslateUnder(), and comTranslateUnEquation().


Function Documentation

void comAnalyzeGrammar void   ) 
 

analyze the currently loaded grammar Definition at line 4582 of file compile.c.

References com, comConstraintDepth(), comMaxLookupStrings(), CompilerStruct::maxLookupStrings, and CompilerStruct::maxValues.

Referenced by comTranslate().

void comApprove int  no,
char **  args
 

approve a compiled grammar Definition at line 5700 of file compile.c.

References Approver, CDG_DEFAULT, CDG_ERROR, CDG_WARNING, cdgCtrlCAllowed, cdgCtrlCTrapped, cdgFlush(), cdgNets, cdgPrintf(), cnBuild(), cnDelete(), comCompareNets(), comFreeApprover(), comNewApprover(), ConstraintNet, evalEvaluationMethod, EvalMethodType, FALSE, hkVerbosity, ConstraintNetStruct::id, NULL, ApproverStruct::timer, timerElapsed(), timerStart(), ApproverStruct::totalCompiledBinaryTime, ApproverStruct::totalCompiledUnaryTime, ApproverStruct::totalInterpretedBinaryTime, ApproverStruct::totalInterpretedUnaryTime, and TRUE.

Referenced by cmdTesting().

Boolean comCompareAllLvPairs Approver  ap,
ConstraintNet  net
 

compare each pair of levelvalues in both networks Definition at line 5308 of file compile.c.

References ConstraintNetStruct::cache, CDG_ERROR, cdgCtrlCTrapped, cdgPrintf(), ConstraintViolationStruct::constraint, ConstraintNet, ConstraintViolation, cvCompare(), cvDelete(), evalBinary(), evalEvaluationMethod, FALSE, BadnessStruct::hard, ConstraintViolationStruct::lv1, ConstraintViolationStruct::lv2, BadnessStruct::no, ApproverStruct::noRounds, NULL, ConstraintViolationStruct::penalty, scDelete(), scNew(), scUseCache, BadnessStruct::soft, ApproverStruct::timer, timerElapsed(), timerStart(), ApproverStruct::totalCompiledBinaryTime, ApproverStruct::totalInterpretedBinaryTime, TRUE, and ConstraintNetStruct::values.

Referenced by comCompareNets().

Boolean comCompareAllLvs Approver  ap,
ConstraintNet  net1,
ConstraintNet  net2
 

compare each levelvalue in both networks returns TRUE if all are equal, else FALSE Definition at line 5266 of file compile.c.

References CDG_ERROR, cdgCtrlCTrapped, cdgPrintf(), comCompareLvs(), comFindComparableLv(), ConstraintNet, FALSE, NULL, TRUE, and ConstraintNetStruct::values.

Referenced by comCompareNets().

Boolean comCompareLvs LevelValue  lv1,
LevelValue  lv2
 

compare two levelvalues returns TRUE if equal, else FALSE Definition at line 5157 of file compile.c.

References CDG_ERROR, cdgPrintf(), FALSE, NULL, and TRUE.

Referenced by comCompareAllLvs().

Boolean comCompareNets Approver  ap,
ConstraintNet  net1,
ConstraintNet  net2
 

compare two constraint networks Definition at line 5643 of file compile.c.

References CDG_ERROR, cdgPrintf(), comCompareAllLvPairs(), comCompareAllLvs(), comCompareWithContext(), ConstraintNet, ConstraintNode, FALSE, ConstraintNetStruct::nodes, NULL, TRUE, ConstraintNodeStruct::values, and ConstraintNetStruct::values.

Referenced by comApprove().

Boolean comCompareWithContext Approver  ap,
ConstraintNet  net,
List  contextList
 

compare the nets after applying context_sensitive constraints Definition at line 5473 of file compile.c.

References ConstraintNetStruct::cache, CDG_ERROR, cdgCtrlCTrapped, cdgPrintf(), ConstraintViolationStruct::constraint, ConstraintNet, ConstraintViolation, cvCompare(), cvDelete(), evalBinary(), evalEvaluationMethod, FALSE, BadnessStruct::hard, ConstraintViolationStruct::lv1, ConstraintViolationStruct::lv2, BadnessStruct::no, ApproverStruct::noRounds, NULL, ConstraintViolationStruct::penalty, scDelete(), scNew(), scUseCache, BadnessStruct::soft, ApproverStruct::timer, timerElapsed(), timerStart(), ApproverStruct::totalCompiledBinaryTime, ApproverStruct::totalInterpretedBinaryTime, TRUE, and ConstraintNetStruct::values.

Referenced by comCompareNets().

String comCompile int  no,
char **  args
 

comCompile: entry function to this package.

  • translate the currently loaded cdg into C
  • make a shared object out of it
  • load it

returns the name of the so file, NULL on failure Definition at line 4922 of file compile.c.

References MakeInfoStruct::cc, CompilerStruct::ccFile, CompilerStruct::ccFileName, CDG_DEFAULT, CDG_ERROR, cdgPrintf(), MakeInfoStruct::cFlags, com, comFree(), comMake(), comNew(), comTranslate(), FALSE, MakeInfoStruct::includes, MakeInfoStruct::ld, MakeInfoStruct::ldFlags, MakeInfoStruct::ldLibs, makeInfo, NULL, CompilerStruct::objFileName, CompilerStruct::soFileName, CompilerStruct::translateOnly, and TRUE.

Referenced by cmdCompile().

String comConnextionToString Connexion  connexion  ) 
 

string representation of a connexion Definition at line 579 of file compile.c.

Referenced by comTranslateConnexion(), and comTranslateConstraint().

int comConstraintDepth Constraint  constraint  ) 
 

compute the number of variables needed to evaluate a constraint Definition at line 4698 of file compile.c.

References comFormulaDepth(), comTermDepth(), and max.

Referenced by comAnalyzeGrammar().

String comDirectionToString Direction  direction  ) 
 

string representation of a direction Definition at line 597 of file compile.c.

Referenced by comTranslateConstraint(), and comTranslateDirection().

String comEscapeQuotes String  str  ) 
 

escape quotes in strings Definition at line 394 of file compile.c.

References NULL.

Referenced by comTranslateConstraint(), comTranslateEquation(), comTranslateLookup(), comTranslateMatch(), comTranslateSubsumes(), comTranslateUnEquation(), comWriteError(), comWriteInitFunction(), and comWriteWarning().

void comFinalize void   ) 
 

finalize the compiler module Definition at line 5087 of file compile.c.

References comMakeInfoFree(), and makeInfo.

Referenced by cdgFinalize().

LevelValue comFindComparableLv ConstraintNet  net,
LevelValue  lv
 

find a lv using the same modifier-lexem, label and modifiee-lexem Definition at line 5123 of file compile.c.

References ConstraintNet, NULL, and ConstraintNetStruct::values.

Referenced by comCompareAllLvs().

void comFinitGrammar Input  thisInput  ) 
 

finalize a dll grammar Definition at line 5065 of file compile.c.

References CDG_ERROR, cdgPrintf(), FINIT_GRAMMAR, and NULL.

int comFormulaDepth Formula  formula  ) 
 

compute the number of variables needed to evaluate a formula Definition at line 4709 of file compile.c.

References comPredicateDepth(), comTermDepth(), and max.

Referenced by comConstraintDepth(), and comTranslateFormula().

String comFormulaTypeToString Formula  formula  ) 
 

string representation of a formula type Definition at line 535 of file compile.c.

Referenced by comReturnTypeOfFormula(), and comTranslateFormula().

void comFree Compiler  thisCom  ) 
 

destructor for a Compiler Definition at line 297 of file compile.c.

References cdgFreeString(), Compiler, CompilerStruct::connexions, CompilerStruct::directions, CompilerStruct::indentStrings, NULL, and CompilerStruct::strings.

Referenced by comCompile().

void comFreeApprover Approver  ap  ) 
 

free an approver Definition at line 5111 of file compile.c.

References NULL, ApproverStruct::timer, and timerFree().

Referenced by comApprove().

int comFunctionDepth String  functor,
List  args
 

compute the number of variables needed to evaluate a function Definition at line 4755 of file compile.c.

References comTermDepth(), max, and NULL.

Referenced by comTermDepth().

void comIndent void   ) 
 

increase indentation Definition at line 355 of file compile.c.

References com, CompilerStruct::indent, CompilerStruct::indentString, CompilerStruct::indentStrings, and min.

Referenced by comTranslateArithmetics(), comTranslateConnexion(), comTranslateConstraint(), comTranslateDirection(), comTranslateEquation(), comTranslateFormula(), comTranslateFunction(), comTranslateHas(), comTranslatePredicate(), comTranslateTopPeek(), comTranslateUnEquation(), comWriteDeclarations(), comWriteFinitFunction(), comWriteFunctions(), and comWriteInitFunction().

int comIndexOfConstraint String  id  ) 
 

get the index of a constraint Definition at line 1238 of file compile.c.

References comWriteError(), and NULL.

Referenced by comTranslateConstraint().

int comIndexOfHierarchy String  id  ) 
 

get the index of a hierarchy Definition at line 1217 of file compile.c.

References comWriteError(), and NULL.

Referenced by comTranslateMatch(), and comTranslateSubsumes().

int comIndexOfVarInfo VarInfo  varInfo  ) 
 

get index of assigned variable Definition at line 1259 of file compile.c.

References com, and CompilerStruct::currentConstraint.

Referenced by comTranslateBottomPeek(), comTranslateConnexion(), comTranslateDirection(), comTranslateExists(), comTranslateLexemNodeAccess(), comTranslateLexicalAccess(), comTranslateString(), and comTranslateTopPeek().

Boolean comInitGrammar Input  thisInput  ) 
 

initialize a dll grammar Definition at line 5043 of file compile.c.

References CDG_ERROR, cdgPrintf(), FALSE, INIT_GRAMMAR, NULL, and TRUE.

void comInitialize void   ) 
 

initialize the compiler module Definition at line 5018 of file compile.c.

References MakeInfoStruct::cc, MakeInfoStruct::cFlags, comMakeInfoNew(), MakeInfoStruct::includes, MakeInfoStruct::ld, MakeInfoStruct::ldFlags, MakeInfoStruct::ldLibs, makeInfo, and NULL.

Referenced by cdgInitialize().

Input comLoad String  filename  ) 
 

load a dll grammar Definition at line 3790 of file compile.c.

References CDG_ERROR, CDG_INFO, cdgPrintf(), com, NULL, and CompilerStruct::soFileName.

Referenced by cmdCompile().

Boolean comMake void   ) 
 

compile a shared object from the recently translated code Definition at line 3751 of file compile.c.

References MakeInfoStruct::cc, CompilerStruct::ccFileName, CDG_DEBUG, CDG_ERROR, CDG_INFO, cdgFlush(), cdgPrintf(), MakeInfoStruct::cFlags, com, FALSE, MakeInfoStruct::includes, MakeInfoStruct::ld, MakeInfoStruct::ldFlags, MakeInfoStruct::ldLibs, makeInfo, NULL, CompilerStruct::objFileName, CompilerStruct::soFileName, and TRUE.

Referenced by comCompile().

void comMakeInfoFree MakeInfo  thisMakeInfo  ) 
 

destructor of a MakeInfo Definition at line 338 of file compile.c.

References MakeInfoStruct::cc, cdgFreeString(), MakeInfoStruct::cFlags, MakeInfoStruct::includes, MakeInfoStruct::ld, MakeInfoStruct::ldFlags, MakeInfoStruct::ldLibs, and MakeInfo.

Referenced by comFinalize().

MakeInfo comMakeInfoNew void   ) 
 

constructor for a MakeInfo Definition at line 321 of file compile.c.

References MakeInfoStruct::cc, MakeInfoStruct::cFlags, MakeInfoStruct::includes, MakeInfoStruct::ld, MakeInfoStruct::ldFlags, MakeInfoStruct::ldLibs, MakeInfo, and NULL.

Referenced by comInitialize().

int comMaxLookupStrings Constraint  constraint  ) 
 

compute the number of strings needed for evaluationg 'lookup' functions in a constraint Definition at line 4616 of file compile.c.

References comMaxLookupStringsInFormula(), comMaxLookupStringsInTerm(), and max.

Referenced by comAnalyzeGrammar().

int comMaxLookupStringsInFormula Formula  formula  ) 
 

compute the number of strings needed for evaluationg 'lookup' functions in a formla Definition at line 4627 of file compile.c.

References comMaxLookupStringsInTerm(), and max.

Referenced by comMaxLookupStrings().

int comMaxLookupStringsInTerm Term  term  ) 
 

compute the number of strings needed for evaluationg 'lookup' functions in a term Definition at line 4665 of file compile.c.

References NULL.

Referenced by comMaxLookupStrings(), and comMaxLookupStringsInFormula().

Compiler comNew void   ) 
 

constructor for a Compiler Definition at line 249 of file compile.c.

References CompilerStruct::ccFileName, Compiler, CompilerStruct::connexions, CompilerStruct::currentConstraint, CompilerStruct::directions, FALSE, CompilerStruct::indent, CompilerStruct::indentString, CompilerStruct::indentStrings, CompilerStruct::needsIndent, NULL, CompilerStruct::objFileName, CompilerStruct::soFileName, CompilerStruct::strings, CompilerStruct::translateOnly, and TRUE.

Referenced by comCompile().

Approver comNewApprover void   ) 
 

allocate a new approver Definition at line 5094 of file compile.c.

References Approver, ApproverStruct::noRounds, ApproverStruct::timer, timerNew(), ApproverStruct::totalCompiledBinaryTime, ApproverStruct::totalCompiledUnaryTime, ApproverStruct::totalInterpretedBinaryTime, and ApproverStruct::totalInterpretedUnaryTime.

Referenced by comApprove().

void comOutdent void   ) 
 

decrease indentation Definition at line 365 of file compile.c.

References com, CompilerStruct::indent, CompilerStruct::indentString, CompilerStruct::indentStrings, and min.

Referenced by comTranslateArithmetics(), comTranslateConnexion(), comTranslateConstraint(), comTranslateDirection(), comTranslateEquation(), comTranslateFormula(), comTranslateFunction(), comTranslateHas(), comTranslatePredicate(), comTranslateTopPeek(), comTranslateUnEquation(), comWriteDeclarations(), comWriteFinitFunction(), comWriteFunctions(), and comWriteInitFunction().

int comPredicateDepth String  functor,
List  args
 

compute the number of variables needed to evaluate a predicate Definition at line 4816 of file compile.c.

References comTermDepth(), max, and NULL.

Referenced by comFormulaDepth().

void comPrint String  format,
  ...
 

no good c program without its own printf Definition at line 462 of file compile.c.

References CompilerStruct::ccFile, com, FALSE, CompilerStruct::indentString, and CompilerStruct::needsIndent.

Referenced by comTranslateAbs(), comTranslateArithmetics(), comTranslateBetween(), comTranslateBottomPeek(), comTranslateChunkHead(), comTranslateConnected(), comTranslateConstraint(), comTranslateDirection(), comTranslateDistance(), comTranslateEquation(), comTranslateExists(), comTranslateFormula(), comTranslateFunction(), comTranslateGuard(), comTranslateHas(), comTranslateHeight(), comTranslateIs(), comTranslateLexemNodeAccess(), comTranslateLexicalAccess(), comTranslateLookup(), comTranslateMatch(), comTranslateMinMax(), comTranslateNumber(), comTranslateParens(), comTranslateParent(), comTranslatePhrasequotes(), comTranslatePredicate(), comTranslatePrint(), comTranslatePts(), comTranslateQuotes(), comTranslateStartStop(), comTranslateString(), comTranslateSubsumes(), comTranslateTerm(), comTranslateTopPeek(), comTranslateUnder(), comTranslateUnEquation(), and comWriteDeclarations().

void comPrintln String  format,
  ...
 

grant a newline at the end Definition at line 376 of file compile.c.

References CompilerStruct::ccFile, com, CompilerStruct::indentString, CompilerStruct::needsIndent, and TRUE.

Referenced by comTranslateAbs(), comTranslateArithmetics(), comTranslateBetween(), comTranslateBottomPeek(), comTranslateChunkHead(), comTranslateConnected(), comTranslateConnexion(), comTranslateConstraint(), comTranslateDirection(), comTranslateDistance(), comTranslateEquation(), comTranslateExists(), comTranslateFormula(), comTranslateFunction(), comTranslateGuard(), comTranslateHas(), comTranslateHeight(), comTranslateIs(), comTranslateLookup(), comTranslateMatch(), comTranslateMinMax(), comTranslateParens(), comTranslateParent(), comTranslatePhrasequotes(), comTranslatePredicate(), comTranslatePrint(), comTranslatePts(), comTranslateQuotes(), comTranslateStartStop(), comTranslateSubsumes(), comTranslateTerm(), comTranslateTopPeek(), comTranslateUnder(), comTranslateUnEquation(), comWriteDeclarations(), comWriteFinitFunction(), comWriteFunctions(), comWriteHeader(), and comWriteInitFunction().

int comRegisterString String  string  ) 
 

register a string to be allocated statically later returns the index in strings Definition at line 1272 of file compile.c.

References com, and CompilerStruct::strings.

Referenced by comTranslateString().

ReturnType comReturnTypeOfFormula Formula  formula  ) 
 

check the return type of a formula Definition at line 4477 of file compile.c.

References comFormulaTypeToString(), comReturnTypeOfPredicate(), comReturnTypeOfTerm(), comReturnTypeToString(), comWriteWarning(), ReturnType, RTBoolean, RTError, RTLexemNode, RTLexemPosition, RTNoError, RTNumber, and RTPeek.

Referenced by comTranslateFormula().

ReturnType comReturnTypeOfFunction String  functor,
List  args
 

check the return type of a function Definition at line 4137 of file compile.c.

References comReturnTypeOfTerm(), comReturnTypeToString(), comWriteError(), comWriteWarning(), FALSE, NULL, ReturnType, RTError, RTLexemNode, RTLexemPosition, RTList, RTNoError, RTNumber, RTPeek, and RTString.

Referenced by comReturnTypeOfTerm().

ReturnType comReturnTypeOfPredicate String  functor,
List  args
 

check the return type of a predicate Definition at line 3820 of file compile.c.

References comReturnTypeOfTerm(), comReturnTypeToString(), comWriteError(), comWriteWarning(), NULL, ReturnType, RTBoolean, RTError, RTLexemNode, RTLexemPosition, RTNoError, RTNumber, RTPeek, and RTString.

Referenced by comReturnTypeOfFormula().

ReturnType comReturnTypeOfTerm Term  term  ) 
 

check the return type of a term Definition at line 4394 of file compile.c.

References comReturnTypeOfFunction(), comReturnTypeToString(), comTermTypeToString(), comWriteWarning(), NULL, ReturnType, RTAVNode, RTError, RTLexemNode, RTLexemPosition, RTNoError, RTNumber, RTPeek, and RTString.

Referenced by comReturnTypeOfFormula(), comReturnTypeOfFunction(), comReturnTypeOfPredicate(), comTranslateAbs(), comTranslateArithmetics(), comTranslateBetween(), comTranslateChunkHead(), comTranslateConnected(), comTranslateConstraint(), comTranslateDistance(), comTranslateEquation(), comTranslateGuard(), comTranslateHas(), comTranslateIs(), comTranslateLookup(), comTranslateMatch(), comTranslateMinMax(), comTranslateParens(), comTranslateParent(), comTranslatePhrasequotes(), comTranslatePrint(), comTranslateQuotes(), comTranslateStartStop(), comTranslateSubsumes(), comTranslateTerm(), comTranslateUnder(), and comTranslateUnEquation().

String comReturnTypeToString ReturnType  returnType  ) 
 

string representation of a returntype Definition at line 479 of file compile.c.

References RTAVNode, RTBoolean, RTConjunction, RTDisjunction, RTError, RTGraphemNode, RTLexemNode, RTLexemPosition, RTList, RTNoError, RTNumber, RTPeek, and RTString.

Referenced by comReturnTypeOfFormula(), comReturnTypeOfFunction(), comReturnTypeOfPredicate(), comReturnTypeOfTerm(), comTranslateAbs(), comTranslateArithmetics(), comTranslateChunkHead(), comTranslateDistance(), comTranslateEquation(), comTranslateGuard(), comTranslateStartStop(), and comTranslateUnEquation().

int comTermDepth Term  term  ) 
 

compute the number of variables needed to evaluate a term Definition at line 4871 of file compile.c.

References comFunctionDepth(), max, and NULL.

Referenced by comConstraintDepth(), comFormulaDepth(), comFunctionDepth(), and comPredicateDepth().

String comTermTypeToString Term  term  ) 
 

string representation of a term type Definition at line 514 of file compile.c.

Referenced by comReturnTypeOfTerm().

Boolean comTranslate void   ) 
 

translate the current cdg to C Definition at line 3721 of file compile.c.

References CompilerStruct::ccFileName, CDG_INFO, cdgFlush(), cdgPrintf(), com, comAnalyzeGrammar(), comTranslateBinaryConstraints(), comTranslateUnaryConstraints(), comWriteDeclarations(), comWriteFunctions(), comWriteHeader(), and TRUE.

Referenced by comCompile().

void comTranslateAbs List  args,
int  tmpIndex
 

translate the abs function Definition at line 1482 of file compile.c.

References comPrint(), comPrintln(), comReturnTypeOfTerm(), comReturnTypeToString(), comTranslateLexicalAccess(), comTranslateNumber(), comTranslateTerm(), comWriteError(), FALSE, ReturnType, RTNoError, RTNumber, RTPeek, and TRUE.

Referenced by comTranslateFunction().

void comTranslateArithmetics Term  term,
int  tmpIndex
 

translate the arithmetic term operations Definition at line 2010 of file compile.c.

References comIndent(), comOutdent(), comPrint(), comPrintln(), comReturnTypeOfTerm(), comReturnTypeToString(), comTranslateLexicalAccess(), comTranslateNumber(), comTranslateTerm(), comWriteError(), FALSE, ReturnType, RTNoError, RTNumber, RTPeek, and TRUE.

Referenced by comTranslateTerm().

void comTranslateBetween String  functor,
List  args,
int  tmpIndex
 

translate the 'between' predicate Definition at line 2634 of file compile.c.

References comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateLexemNodeAccess(), comTranslateNumber(), comTranslateString(), comTranslateTerm(), ReturnType, RTLexemNode, RTLexemPosition, RTNumber, RTString, and TRUE.

Referenced by comTranslatePredicate().

void comTranslateBinaryConstraints void   ) 
 

translate each binary constraint into a separate c-function Definition at line 3704 of file compile.c.

References com, comTranslateConstraint(), and CompilerStruct::indent.

Referenced by comTranslate().

void comTranslateBottomPeek Term  term,
int  tmpIndex
 

translate a bottom peek Definition at line 2119 of file compile.c.

References comIndexOfVarInfo(), comPrint(), comPrintln(), comTranslateLexicalAccess(), and NULL.

Referenced by comTranslateTerm().

void comTranslateChunkHead String  functor,
List  args,
int  tmpIndex
 

translate the chunk_head predicate Definition at line 2560 of file compile.c.

References comPrint(), comPrintln(), comReturnTypeOfTerm(), comReturnTypeToString(), comTranslateLexemNodeAccess(), comWriteError(), ReturnType, RTLexemNode, RTLexemPosition, and RTNoError.

Referenced by comTranslatePredicate().

void comTranslateConnected String  functor,
List  args,
int  tmpIndex
 

translate the 'connected' predicate Definition at line 2768 of file compile.c.

References com, comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateLexemNodeAccess(), CompilerStruct::currentConstraint, ReturnType, RTLexemNode, and RTLexemPosition.

Referenced by comTranslatePredicate().

void comTranslateConnexion Formula  formula  ) 
 

translate a connexion in case of the unsymmetric connexions 'Under' & 'Over' a distinction between the order (lv1, lv2) and (lv2, lv1) is made. in the other cases this doesn't matter. Definition at line 3563 of file compile.c.

References comConnextionToString(), comIndent(), comIndexOfVarInfo(), comOutdent(), and comPrintln().

Referenced by comTranslateFormula().

void comTranslateConstraint Constraint  constraint  ) 
 

translate a constraint into a c-function Definition at line 3617 of file compile.c.

References com, comConnextionToString(), comDirectionToString(), comEscapeQuotes(), comIndent(), comIndexOfConstraint(), comOutdent(), comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateFormula(), comTranslateLexicalAccess(), comTranslateNumber(), comTranslateTerm(), CompilerStruct::currentConstraint, FALSE, NULL, ReturnType, RTNoError, RTPeek, and TRUE.

Referenced by comTranslateBinaryConstraints(), and comTranslateUnaryConstraints().

void comTranslateDirection Formula  formula  ) 
 

translate the direction formulas Definition at line 3406 of file compile.c.

References comDirectionToString(), comIndent(), comIndexOfVarInfo(), comOutdent(), comPrint(), comPrintln(), and comWriteError().

Referenced by comTranslateFormula().

void comTranslateDistance List  args,
int  tmpIndex
 

translate the distance function Definition at line 1435 of file compile.c.

References comPrint(), comPrintln(), comReturnTypeOfTerm(), comReturnTypeToString(), comTranslateLexemNodeAccess(), comTranslateTerm(), comWriteError(), FALSE, ReturnType, RTLexemNode, RTLexemPosition, RTNoError, and TRUE.

Referenced by comTranslateFunction().

void comTranslateEquation Formula  formula,
int  tmpIndex
 

translate the equal and not equal formulas Definition at line 3061 of file compile.c.

References com, comEscapeQuotes(), comIndent(), comOutdent(), comPrint(), comPrintln(), comReturnTypeOfTerm(), comReturnTypeToString(), comTranslateLexemNodeAccess(), comTranslateLexicalAccess(), comTranslateNumber(), comTranslateString(), comTranslateTerm(), comWriteError(), comWriteWarning(), CompilerStruct::currentConstraint, FALSE, ReturnType, RTLexemNode, RTLexemPosition, RTNoError, RTNumber, RTPeek, RTString, and TRUE.

Referenced by comTranslateFormula().

void comTranslateExists List  args  ) 
 

translate the exists predicate Definition at line 2504 of file compile.c.

References comIndexOfVarInfo(), comPrint(), comPrintln(), and NULL.

Referenced by comTranslatePredicate().

void comTranslateFormula Formula  formula,
int  tmpIndex
 

translate a formula to c code Definition at line 3459 of file compile.c.

References com, comFormulaDepth(), comFormulaTypeToString(), comIndent(), comOutdent(), comPrint(), comPrintln(), comReturnTypeOfFormula(), comTranslateConnexion(), comTranslateDirection(), comTranslateEquation(), comTranslatePredicate(), comTranslateUnEquation(), comWriteWarning(), CompilerStruct::currentFormula, ReturnType, RTBoolean, RTError, and RTNoError.

Referenced by comTranslateConstraint().

void comTranslateFunction String  functor,
List  args,
int  tmpIndex
 

translate a function to c code Definition at line 1361 of file compile.c.

References comIndent(), comOutdent(), comPrint(), comPrintln(), comTranslateAbs(), comTranslateDistance(), comTranslateHeight(), comTranslateLookup(), comTranslateMatch(), comTranslateMinMax(), comTranslateParens(), comTranslateParent(), comTranslatePhrasequotes(), comTranslatePts(), comTranslateQuotes(), and comWriteError().

Referenced by comTranslateTerm().

void comTranslateGuard String  functor,
List  args,
int  tmpIndex
 

translate the root, spec and nonspec guard-predicates Definition at line 2989 of file compile.c.

References comPrint(), comPrintln(), comReturnTypeOfTerm(), comReturnTypeToString(), comTranslateLexemNodeAccess(), comTranslateTerm(), comWriteError(), ReturnType, RTLexemNode, RTLexemPosition, RTNoError, and TRUE.

Referenced by comTranslatePredicate().

void comTranslateHas String  functor,
List  args,
int  tmpIndex
 

translate the 'has' predicate Definition at line 2818 of file compile.c.

References com, comIndent(), comOutdent(), comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateLexemNodeAccess(), comTranslateLexicalAccess(), comTranslateNumber(), comTranslateString(), comTranslateTerm(), CompilerStruct::currentFormula, FALSE, ReturnType, RTLexemPosition, RTPeek, RTString, and TRUE.

Referenced by comTranslatePredicate().

void comTranslateHeight List  args,
int  tmpIndex
 

translate the `height' function Definition at line 1681 of file compile.c.

References comPrint(), comPrintln(), comTranslateLexemNodeAccess(), comWriteError(), and NULL.

Referenced by comTranslateFunction().

void comTranslateIs String  functor,
List  args,
int  tmpIndex
 

translate the 'is' predicate Definition at line 2715 of file compile.c.

References com, comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateLexemNodeAccess(), comTranslateString(), comWriteWarning(), CompilerStruct::currentConstraint, ReturnType, RTLexemNode, and RTLexemPosition.

Referenced by comTranslatePredicate().

void comTranslateLexemNodeAccess Term  term,
int  tmpIndex
 

translate a ^id and @id Definition at line 1292 of file compile.c.

References comIndexOfVarInfo(), comPrint(), and comWriteError().

Referenced by comTranslateBetween(), comTranslateChunkHead(), comTranslateConnected(), comTranslateDistance(), comTranslateEquation(), comTranslateGuard(), comTranslateHas(), comTranslateHeight(), comTranslateIs(), comTranslateParens(), comTranslateParent(), comTranslatePhrasequotes(), comTranslatePts(), comTranslateQuotes(), comTranslateStartStop(), and comTranslateUnder().

void comTranslateLexicalAccess Term  term  ) 
 

translate a lexical access Definition at line 1328 of file compile.c.

References comIndexOfVarInfo(), comPrint(), and comWriteError().

Referenced by comTranslateAbs(), comTranslateArithmetics(), comTranslateBottomPeek(), comTranslateConstraint(), comTranslateEquation(), comTranslateHas(), comTranslateLookup(), comTranslateMatch(), comTranslatePrint(), comTranslateSubsumes(), comTranslateTopPeek(), and comTranslateUnEquation().

void comTranslateLookup List  args,
int  tmpIndex
 

translate the lookup function Definition at line 1536 of file compile.c.

References com, comEscapeQuotes(), comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateLexicalAccess(), comTranslateString(), comTranslateTerm(), CompilerStruct::currentConstraint, FALSE, ReturnType, RTNoError, RTPeek, and RTString.

Referenced by comTranslateFunction().

void comTranslateMatch List  args,
int  tmpIndex
 

translate the match function Definition at line 1763 of file compile.c.

References com, comEscapeQuotes(), comIndexOfHierarchy(), comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateLexicalAccess(), comTranslateString(), comTranslateTerm(), comWriteError(), CompilerStruct::currentConstraint, FALSE, ReturnType, RTList, RTNoError, RTPeek, RTString, and TRUE.

Referenced by comTranslateFunction().

void comTranslateMinMax String  functor,
List  args,
int  tmpIndex
 

translate the min and max function Definition at line 1708 of file compile.c.

References comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateNumber(), comTranslateTerm(), FALSE, NULL, ReturnType, RTNoError, RTPeek, and TRUE.

Referenced by comTranslateFunction().

void comTranslateNumber Term  term,
int  tmpIndex
 

translate a number access Definition at line 1902 of file compile.c.

References comPrint().

Referenced by comTranslateAbs(), comTranslateArithmetics(), comTranslateBetween(), comTranslateConstraint(), comTranslateEquation(), comTranslateHas(), comTranslateMinMax(), and comTranslateUnEquation().

void comTranslateParens List  args,
int  tmpIndex
 

translate the parens function Definition at line 1610 of file compile.c.

References comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateLexemNodeAccess(), ReturnType, and RTLexemPosition.

Referenced by comTranslateFunction().

void comTranslateParent List  args,
int  tmpIndex
 

translate the parent function Definition at line 1634 of file compile.c.

References com, comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateLexemNodeAccess(), CompilerStruct::currentConstraint, ReturnType, and RTLexemPosition.

Referenced by comTranslateFunction().

void comTranslatePhrasequotes List  args,
int  tmpIndex
 

translate the phrasequotes function Definition at line 1512 of file compile.c.

References comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateLexemNodeAccess(), ReturnType, and RTLexemPosition.

Referenced by comTranslateFunction().

void comTranslatePredicate String  functor,
List  args,
int  tmpIndex
 

translate a predicate to c code Definition at line 2319 of file compile.c.

References comIndent(), comOutdent(), comPrint(), comPrintln(), comTranslateBetween(), comTranslateChunkHead(), comTranslateConnected(), comTranslateExists(), comTranslateGuard(), comTranslateHas(), comTranslateIs(), comTranslatePrint(), comTranslateStartStop(), comTranslateSubsumes(), and comTranslateUnder().

Referenced by comTranslateFormula().

void comTranslatePrint List  args,
int  tmpIndex
 

translate the print predicate Definition at line 2294 of file compile.c.

References comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateLexicalAccess(), comTranslateTerm(), FALSE, NULL, ReturnType, RTNoError, RTPeek, and TRUE.

Referenced by comTranslatePredicate().

void comTranslatePts List  args,
int  tmpIndex
 

translate the pts function Definition at line 1662 of file compile.c.

References comPrint(), comPrintln(), and comTranslateLexemNodeAccess().

Referenced by comTranslateFunction().

void comTranslateQuotes List  args,
int  tmpIndex
 

translate the quotes function Definition at line 1586 of file compile.c.

References comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateLexemNodeAccess(), ReturnType, and RTLexemPosition.

Referenced by comTranslateFunction().

void comTranslateStartStop String  functor,
List  args,
int  tmpIndex
 

translate the start and stop predicate Definition at line 3024 of file compile.c.

References comPrint(), comPrintln(), comReturnTypeOfTerm(), comReturnTypeToString(), comTranslateLexemNodeAccess(), comTranslateTerm(), comWriteError(), ReturnType, RTLexemNode, RTLexemPosition, RTNoError, and TRUE.

Referenced by comTranslatePredicate().

void comTranslateString Term  term,
int  tmpIndex
 

translate a string access Definition at line 1916 of file compile.c.

References comIndexOfVarInfo(), comPrint(), and comRegisterString().

Referenced by comTranslateBetween(), comTranslateEquation(), comTranslateHas(), comTranslateIs(), comTranslateLookup(), comTranslateMatch(), and comTranslateSubsumes().

void comTranslateSubsumes String  functor,
List  args,
int  tmpIndex
 

translate the subsumes and compatible predicates Definition at line 2390 of file compile.c.

References com, comEscapeQuotes(), comIndexOfHierarchy(), comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateLexicalAccess(), comTranslateString(), comTranslateTerm(), comWriteError(), CompilerStruct::currentConstraint, ReturnType, RTNoError, RTPeek, RTString, and TRUE.

Referenced by comTranslatePredicate().

void comTranslateTerm Term  term,
Boolean  insideFormula,
Boolean  needsSeparator,
int  tmpIndex
 

translate a term to c code Definition at line 1939 of file compile.c.

References comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateArithmetics(), comTranslateBottomPeek(), comTranslateFunction(), comTranslateTopPeek(), FALSE, ReturnType, and RTNoError.

Referenced by comTranslateAbs(), comTranslateArithmetics(), comTranslateBetween(), comTranslateConstraint(), comTranslateDistance(), comTranslateEquation(), comTranslateGuard(), comTranslateHas(), comTranslateLookup(), comTranslateMatch(), comTranslateMinMax(), comTranslatePrint(), comTranslateStartStop(), comTranslateSubsumes(), and comTranslateUnEquation().

void comTranslateTopPeek Term  term,
int  tmpIndex
 

translate a top peek Definition at line 2192 of file compile.c.

References comIndent(), comIndexOfVarInfo(), comOutdent(), comPrint(), comPrintln(), comTranslateLexicalAccess(), and NULL.

Referenced by comTranslateTerm().

void comTranslateUnaryConstraints void   ) 
 

translate each unary constraint into a separate c-function Definition at line 3600 of file compile.c.

References com, comTranslateConstraint(), and CompilerStruct::indent.

Referenced by comTranslate().

void comTranslateUnder String  functor,
List  args,
int  tmpIndex
 

translate the 'under' predicate Definition at line 2592 of file compile.c.

References comPrint(), comPrintln(), comReturnTypeOfTerm(), comTranslateLexemNodeAccess(), comWriteError(), ReturnType, RTLexemNode, and RTNoError.

Referenced by comTranslatePredicate().

void comTranslateUnEquation Formula  formula,
int  tmpIndex
 

translate the <, <=, >, >= formulas Definition at line 3289 of file compile.c.

References com, comEscapeQuotes(), comIndent(), comOutdent(), comPrint(), comPrintln(), comReturnTypeOfTerm(), comReturnTypeToString(), comTranslateLexicalAccess(), comTranslateNumber(), comTranslateTerm(), comWriteError(), CompilerStruct::currentConstraint, ReturnType, RTNoError, RTNumber, RTPeek, and TRUE.

Referenced by comTranslateFormula().

String comValueTypeToString Value  value  ) 
 

string representation of a value type Definition at line 560 of file compile.c.

void comWriteDeclarations void   ) 
 

write declaration section Definition at line 650 of file compile.c.

References com, comIndent(), comOutdent(), comPrint(), comPrintln(), FINIT_GRAMMAR, INIT_GRAMMAR, CompilerStruct::maxValues, and NULL.

Referenced by comTranslate().

void comWriteError String  format,
  ...
 

write a preprocessor error Definition at line 440 of file compile.c.

References CompilerStruct::ccFile, com, comEscapeQuotes(), CompilerStruct::currentConstraint, CompilerStruct::needsIndent, and TRUE.

Referenced by comIndexOfConstraint(), comIndexOfHierarchy(), comReturnTypeOfFunction(), comReturnTypeOfPredicate(), comTranslateAbs(), comTranslateArithmetics(), comTranslateChunkHead(), comTranslateDirection(), comTranslateDistance(), comTranslateEquation(), comTranslateFunction(), comTranslateGuard(), comTranslateHeight(), comTranslateLexemNodeAccess(), comTranslateLexicalAccess(), comTranslateMatch(), comTranslateStartStop(), comTranslateSubsumes(), comTranslateUnder(), and comTranslateUnEquation().

void comWriteFinitFunction void   ) 
 

write the grammar finalization function Definition at line 1086 of file compile.c.

References com, comIndent(), comOutdent(), comPrintln(), FINIT_GRAMMAR, and CompilerStruct::strings.

Referenced by comWriteFunctions().

void comWriteFunctions void   ) 
 

write helper functions Definition at line 755 of file compile.c.

References com, comIndent(), comOutdent(), comPrintln(), comWriteFinitFunction(), comWriteInitFunction(), and CompilerStruct::indent.

Referenced by comTranslate().

void comWriteHeader void   ) 
 

write header Definition at line 612 of file compile.c.

References comPrintln(), and NULL.

Referenced by comTranslate().

void comWriteInitFunction void   ) 
 

write the grammar initialization function Definition at line 1122 of file compile.c.

References com, comEscapeQuotes(), comIndent(), comOutdent(), comPrintln(), INIT_GRAMMAR, CompilerStruct::maxLookupStrings, NULL, and CompilerStruct::strings.

Referenced by comWriteFunctions().

void comWriteWarning String  format,
  ...
 

write a preprocessor warning Definition at line 418 of file compile.c.

References CompilerStruct::ccFile, com, comEscapeQuotes(), CompilerStruct::currentConstraint, CompilerStruct::needsIndent, and TRUE.

Referenced by comReturnTypeOfFormula(), comReturnTypeOfFunction(), comReturnTypeOfPredicate(), comReturnTypeOfTerm(), comTranslateEquation(), comTranslateFormula(), and comTranslateIs().


Variable Documentation

Compiler com [static]
 

this is allocated on every call to comCompile Definition at line 132 of file compile.c.

Referenced by comAnalyzeGrammar(), comCompile(), comIndent(), comIndexOfVarInfo(), comLoad(), comMake(), comOutdent(), comPrint(), comPrintln(), comRegisterString(), comTranslate(), comTranslateBinaryConstraints(), comTranslateConnected(), comTranslateConstraint(), comTranslateEquation(), comTranslateFormula(), comTranslateHas(), comTranslateIs(), comTranslateLookup(), comTranslateMatch(), comTranslateParent(), comTranslateSubsumes(), comTranslateUnaryConstraints(), comTranslateUnEquation(), comWriteDeclarations(), comWriteError(), comWriteFinitFunction(), comWriteFunctions(), comWriteInitFunction(), and comWriteWarning().

MakeInfo makeInfo [static]
 

this is allocated once on comInitialize Definition at line 133 of file compile.c.

Referenced by comCompile(), comFinalize(), comInitialize(), and comMake().


CDG 0.95 (20 Oct 2004)