From 9c91ee36d2050b4a6b6b9ff7948252a98cf0fa5e Mon Sep 17 00:00:00 2001 From: tengel Date: Wed, 20 Mar 2024 09:28:18 -0500 Subject: [PATCH] adding CExpr --- CExpr/CEXPR.CNT | 85 +++ CExpr/CEXPR.HLP | Bin 0 -> 35549 bytes CExpr/Cexpr.cpp | 1229 +++++++++++++++++++++++++++++++++++++++ CExpr/Cexpr.dsp | 134 +++++ CExpr/Cexpr.dsw | 29 + CExpr/Cexpr.h | 246 ++++++++ CExpr/Cexpr.mak | 234 ++++++++ CExpr/Cexpr.mdp | Bin 0 -> 35328 bytes CExpr/Cexpr.opt | Bin 0 -> 48640 bytes CExpr/Cexpr.plg | 35 ++ CExpr/DOSLEX.C | 1208 ++++++++++++++++++++++++++++++++++++++ CExpr/DOSYACC.C | 516 ++++++++++++++++ CExpr/Debug/empty.dir | 0 CExpr/EXPR.H | 124 ++++ CExpr/LEX_YY.C | 1213 ++++++++++++++++++++++++++++++++++++++ CExpr/Lexer.l | 193 ++++++ CExpr/PARSER.Y | 157 +++++ CExpr/Release/empty.dir | 0 CExpr/STDAFX.H | 16 + CExpr/WX_HASH.CPP | 350 +++++++++++ CExpr/WX_HASH.H | 100 ++++ CExpr/Wx_list.cpp | 598 +++++++++++++++++++ CExpr/Wx_list.h | 155 +++++ CExpr/Y_TAB.C | 516 ++++++++++++++++ CExpr/old/DOSLEX.C | 1208 ++++++++++++++++++++++++++++++++++++++ CExpr/old/DOSYACC.C | 516 ++++++++++++++++ CExpr/old/LEXER.L | 193 ++++++ CExpr/old/LEX_YY.C | 1213 ++++++++++++++++++++++++++++++++++++++ CExpr/old/PARSER.Y | 157 +++++ CExpr/old/Y_TAB.C | 516 ++++++++++++++++ 30 files changed, 10941 insertions(+) create mode 100644 CExpr/CEXPR.CNT create mode 100644 CExpr/CEXPR.HLP create mode 100644 CExpr/Cexpr.cpp create mode 100644 CExpr/Cexpr.dsp create mode 100644 CExpr/Cexpr.dsw create mode 100644 CExpr/Cexpr.h create mode 100644 CExpr/Cexpr.mak create mode 100644 CExpr/Cexpr.mdp create mode 100644 CExpr/Cexpr.opt create mode 100644 CExpr/Cexpr.plg create mode 100644 CExpr/DOSLEX.C create mode 100644 CExpr/DOSYACC.C create mode 100644 CExpr/Debug/empty.dir create mode 100644 CExpr/EXPR.H create mode 100644 CExpr/LEX_YY.C create mode 100644 CExpr/Lexer.l create mode 100644 CExpr/PARSER.Y create mode 100644 CExpr/Release/empty.dir create mode 100644 CExpr/STDAFX.H create mode 100644 CExpr/WX_HASH.CPP create mode 100644 CExpr/WX_HASH.H create mode 100644 CExpr/Wx_list.cpp create mode 100644 CExpr/Wx_list.h create mode 100644 CExpr/Y_TAB.C create mode 100644 CExpr/old/DOSLEX.C create mode 100644 CExpr/old/DOSYACC.C create mode 100644 CExpr/old/LEXER.L create mode 100644 CExpr/old/LEX_YY.C create mode 100644 CExpr/old/PARSER.Y create mode 100644 CExpr/old/Y_TAB.C diff --git a/CExpr/CEXPR.CNT b/CExpr/CEXPR.CNT new file mode 100644 index 0000000..08d838a --- /dev/null +++ b/CExpr/CEXPR.CNT @@ -0,0 +1,85 @@ +:Base cexpr.hlp +1 Introduction +2 Introduction=topic0 +2 Data file manipulation=topic1 +2 Availability and location of CExpr=topic2 +1 CExpr compilation +2 CExpr compilation=topic3 +1 Bugs and future developments +2 Bugs and future developments=topic4 +2 Bugs=topic5 +2 Future developments=topic6 +1 Tutorial +2 Tutorial=topic7 +1 Class reference +2 Class reference=topic8 +2 CExpr +3 CExpr=topic9 +3 CExpr::CExpr=topic10 +3 CExpr::~CExpr=topic11 +3 CExpr::AddAttributeValue=topic12 +3 CExpr::AddAttributeValueString=topic13 +3 CExpr::AddAttributeValueStringList=topic14 +3 CExpr::AddAttributeValueWord=topic15 +3 CExpr::Append=topic16 +3 CExpr::Arg=arg +3 CExpr::AttributeValue=topic17 +3 CExpr::Copy=topic18 +3 CExpr::DeleteAttributeValue +4 CExpr::DeleteAttributeValue=topic19 +3 CExpr::Functor +4 CExpr::Functor=topic20 +3 CExpr::GetAttributeValue +4 CExpr::GetAttributeValue=topic21 +3 CExpr::GetAttributeValueStringList +4 CExpr::GetAttributeValueStringList=topic22 +3 CExpr::GetClientData +4 CExpr::GetClientData=topic23 +3 CExpr::GetFirst +4 CExpr::GetFirst=getfirst +3 CExpr::GetLast +4 CExpr::GetLast=getlast +3 CExpr::GetNext +4 CExpr::GetNext=getnext +3 CExpr::Insert +4 CExpr::Insert=topic24 +3 CExpr::IntegerValue +4 CExpr::IntegerValue=topic25 +3 CExpr::Nth +4 CExpr::Nth=nth +3 CExpr::RealValue +4 CExpr::RealValue=topic26 +3 CExpr::SetClientData +4 CExpr::SetClientData=topic27 +3 CExpr::StringValue +4 CExpr::StringValue=topic28 +3 CExpr::Type +4 CExpr::Type=topic29 +3 CExpr::WordValue +4 CExpr::WordValue=topic30 +3 CExpr::WriteLispExpr +4 CExpr::WriteLispExpr=topic31 +3 CExpr::WriteClause +4 CExpr::WriteClause=topic32 +3 CExpr::WriteExpr +4 CExpr::WriteExpr=topic33 +2 CExprDatabase: public wxList +3 CExprDatabase: public wxList=topic34 +3 CExprDatabase::CExprDatabase=topic35 +3 CExprDatabase::~CExprDatabase=topic36 +3 CExprDatabase::Append=topic37 +3 CExprDatabase::BeginFind=topic38 +3 CExprDatabase::ClearDatabase=topic39 +3 CExprDatabase::FindClause=topic40 +3 CExprDatabase::FindClauseByFunctor=topic41 +3 CExprDatabase::GetErrorCount=geterrorcount +3 CExprDatabase::HashFind=topic42 +3 CExprDatabase::Read=databaseread +3 CExprDatabase::ReadFromString=topic43 +3 CExprDatabase::Write=databasewrite +3 CExprDatabase::WriteLisp +4 CExprDatabase::WriteLisp=topic44 +2 Macros +3 Macros=topic45 +1 Change log +2 Change log=topic46 diff --git a/CExpr/CEXPR.HLP b/CExpr/CEXPR.HLP new file mode 100644 index 0000000000000000000000000000000000000000..d973bf1f2b71ecedf6eae840fec021a8304897c3 GIT binary patch literal 35549 zcmbSz2V7J~_vp;r?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D!K>My3=a@Hd-Iq_!eF+cgKEr&m0z%60(feaJTVZ?KA_;oq2Wgpzc5} zz&Ha6EM3?44UTKPei%sI+~6qhn*{b +#include +#include + +#include "expr.h" +#include "cexpr.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +extern "C" void add_expr(char *); +extern "C" void LexFromFile(FILE *fd); +extern "C" void LexFromString(char *buf); + +CExprDatabase *theCExprDatabase = NULL; +CExprErrorHandler currentCExprErrorHandler; + +IMPLEMENT_DYNAMIC(CExprDatabase, wxList) + +CExpr::CExpr(const CString& functor) +{ + type = CExprList; + next = NULL; + last = NULL; + value.first = NULL; + + CExpr *pfunctor = new CExpr(CExprWord, functor); + Append(pfunctor); + client_data = NULL; +} + +CExpr::CExpr(CExprType the_type, const CString& word_or_string) +{ + type = the_type; + + switch (the_type) + { + case CExprWord: + value.word = copystring((const char *)word_or_string); + break; + case CExprString: + value.string = copystring((const char *)word_or_string); + break; + case CExprList: + last = NULL; + value.first = NULL; + break; + case CExprReal: + case CExprInteger: + case CExprNull: + break; + } + client_data = NULL; + next = NULL; +} + +CExpr::CExpr(CExprType the_type, char *word_or_string, BOOL allocate) +{ + type = the_type; + + switch (the_type) + { + case CExprWord: + value.word = allocate ? copystring(word_or_string) : word_or_string; + break; + case CExprString: + value.string = allocate ? copystring(word_or_string) : word_or_string; + break; + case CExprList: + last = NULL; + value.first = NULL; + break; + case CExprReal: + case CExprInteger: + case CExprNull: + break; + } + client_data = NULL; + next = NULL; +} + +CExpr::CExpr(long the_integer) +{ + type = CExprInteger; + value.integer = the_integer; + client_data = NULL; + next = NULL; +} + +CExpr::CExpr(float the_real) +{ + type = CExprReal; + value.real = the_real; + client_data = NULL; + next = NULL; +} + +CExpr::CExpr(wxList *the_list) +{ + type = CExprList; + client_data = NULL; + last = NULL; + value.first = NULL; + + CExpr *listExpr = new CExpr(CExprList); + + wxNode *node = the_list->First(); + while (node) + { + CExpr *expr = (CExpr *)node->Data(); + listExpr->Append(expr); + node = node->Next(); + } + Append(listExpr); + + delete the_list; +} + +CExpr::~CExpr(void) +{ + switch (type) + { + case CExprInteger: + case CExprReal: + { + break; + } + case CExprString: + { + delete[] value.string; + break; + } + case CExprWord: + { + delete[] value.word; + break; + } + case CExprList: + { + CExpr *expr = value.first; + while (expr) + { + CExpr *expr1 = expr->next; + + delete expr; + expr = expr1; + } + break; + } + case CExprNull: break; + } +} + +void CExpr::Append(CExpr *expr) +{ + if (!value.first) + value.first = expr; + + if (last) + last->next = expr; + last = expr; +} + +void CExpr::Insert(CExpr *expr) +{ + expr->next = value.first; + value.first = expr; + + if (!last) + last = expr; +} + +CExpr *CExpr::Copy(void) +{ + // This seems to get round an optimizer bug when + // using Watcom C++ 10a in WIN32 compilation mode. + // If these lines not present, the type seems to be + // interpreted wrongly as an integer. + // I don't want to turn optimization off since it's needed + // for reading in files quickly. +#if defined(__WATCOMC__) + char buf[2]; + sprintf(buf, ""); +#endif + + switch (type) + { + case CExprInteger: + return new CExpr(value.integer); + case CExprReal: + return new CExpr(value.real); + case CExprString: + return new CExpr(CExprString, CString(value.string)); + case CExprWord: + return new CExpr(CExprWord, CString(value.word)); + case CExprList: + { + CExpr *expr = value.first; + CExpr *new_list = new CExpr(CExprList); + while (expr) + { + CExpr *expr2 = expr->Copy(); + new_list->Append(expr2); + expr = expr->next; + } + return new_list; + } + case CExprNull: + break; + } + return NULL; +} + + +// Get the CExpr (containing (= CExpr Value) form) for the given word +// or string, assuming that we have Attribute=Value, ... +CExpr *CExpr::GetAttributeValueNode(const CString& word) // Use only for a clause or list +{ + if (type != CExprList) + return NULL; + + CExpr *expr = value.first; + while (expr) + { + if (expr->type == CExprList) + { + CExpr *firstNode = expr->value.first; + if ((firstNode->type == CExprWord) && (firstNode->value.word[0] == '=')) + { + CExpr *secondNode = firstNode->next; + if ((secondNode->type == CExprWord) && + (strcmp((const char *)word, secondNode->value.word) == 0)) + { + return expr; + } + } + } + expr = expr->next; + } + return NULL; +} + +// Get the value (in CExpr form) for the given word or string, assuming +// that we have Attribute=Value, ... +CExpr *CExpr::AttributeValue(const CString& word) // Use only for a clause or list +{ + if (type != CExprList) + return NULL; + + CExpr *attExpr = GetAttributeValueNode(word); + if (attExpr && attExpr->value.first && attExpr->value.first->next) + return attExpr->value.first->next->next; + else return NULL; +} + +CString CExpr::Functor(void) // Use only for a clause +{ + if ((type != CExprList) || !value.first) + return CString(""); + + if (value.first->type == CExprWord) + return CString(value.first->value.word); + else + return CString(""); +} + +BOOL CExpr::IsFunctor(const CString& f) // Use only for a clause +{ + if ((type != CExprList) || !value.first) + return FALSE; + + return (value.first->type == CExprWord && + (strcmp((const char *)f, value.first->value.word) == 0)); +} + +// Return nth argument of a clause (starting from 1) +CExpr *CExpr::Arg(CExprType theType, int arg) +{ + CExpr *expr = value.first; + int i; + for (i = 1; i < arg; i++) + if (expr) + expr = expr->next; + + if (expr && (expr->type == theType)) + return expr; + else + return NULL; +} + +// Return nth argument of a list expression (starting from zero) +CExpr *CExpr::Nth(int arg) +{ + if (type != CExprList) + return NULL; + + CExpr *expr = value.first; + int i; + for (i = 0; i < arg; i++) + if (expr) + expr = expr->next; + else return NULL; + + if (expr) + return expr; + else + return NULL; +} + + // Returns the number of elements in a list expression +int CExpr::Number(void) +{ + if (type != CExprList) + return 0; + + int i = 0; + CExpr *expr = value.first; + while (expr) + { + expr = expr->next; + i ++; + } + return i; +} + +void CExpr::DeleteAttributeValue(const CString& attribute) +{ + if (type != CExprList) + return; + + CExpr *expr = value.first; + CExpr *lastExpr = this; + while (expr) + { + if (expr->type == CExprList) + { + CExpr *firstNode = expr->value.first; + if ((firstNode->type == CExprWord) && (firstNode->value.word[0] == '=')) + { + CExpr *secondNode = firstNode->next; + if ((secondNode->type == CExprWord) && + (strcmp((const char *)attribute, secondNode->value.word) == 0)) + { + CExpr *nextExpr = expr->next; + delete expr; + + lastExpr->next = nextExpr; + + if (last == expr) + last = lastExpr; + + return; + } + } + } + lastExpr = expr; + expr = expr->next; + } + return; +} + +void CExpr::AddAttributeValue(const CString& attribute, CExpr *val) +{ + if (type != CExprList) + { +// cout << "Error! tried to add an attribute-value pair to a nonlist CExpr expression\n"; + return; + } + // Warning - existing code may assume that any existing value + // is deleted first. For efficiency, we leave this to the application. +// DeleteAttributeValue(attribute); + + CExpr *patt = new CExpr(CExprWord, attribute); + CExpr *pequals = new CExpr(CExprWord, "="); + + CExpr *listExpr = new CExpr(CExprList); + + listExpr->Append(pequals); + listExpr->Append(patt); + listExpr->Append(val); + + Append(listExpr); +} + +void CExpr::AddAttributeValue(const CString& attribute, long val) +{ + if (type != CExprList) + { +// cout << "Error! tried to add an attribute-value pair to a nonlist CExpr expression\n"; + return; + } + // Warning - existing code may assume that any existing value + // is deleted first. For efficiency, we leave this to the application. +// DeleteAttributeValue(attribute); + + CExpr *patt = new CExpr(CExprWord, attribute); + CExpr *pval = new CExpr(val); + CExpr *pequals = new CExpr(CExprWord, "="); + + CExpr *listExpr = new CExpr(CExprList); + + listExpr->Append(pequals); + listExpr->Append(patt); + listExpr->Append(pval); + + Append(listExpr); +} + +void CExpr::AddAttributeValue(const CString& attribute, float val) +{ + if (type != CExprList) + { +// cout << "Error! tried to add an attribute-value pair to a nonlist CExpr expression\n"; + return; + } + +// DeleteAttributeValue(attribute); + CExpr *patt = new CExpr(CExprWord, attribute); + CExpr *pval = new CExpr(val); + CExpr *pequals = new CExpr(CExprWord, "="); + + CExpr *listExpr = new CExpr(CExprList); + + listExpr->Append(pequals); + listExpr->Append(patt); + listExpr->Append(pval); + + Append(listExpr); +} + +void CExpr::AddAttributeValueString(const CString& attribute, const CString& val) +{ + if (type != CExprList) + { +// cout << "Error! tried to add an attribute-value pair to a nonlist CExpr expression\n"; + return; + } + +// DeleteAttributeValue(attribute); + + CExpr *patt = new CExpr(CExprWord, attribute); + CExpr *pval = new CExpr(CExprString, val); + CExpr *pequals = new CExpr(CExprWord, "="); + + CExpr *listExpr = new CExpr(CExprList); + + listExpr->Append(pequals); + listExpr->Append(patt); + listExpr->Append(pval); + + Append(listExpr); +} + +void CExpr::AddAttributeValueWord(const CString& attribute, const CString& val) +{ + if (type != CExprList) + { +// cout << "Error! tried to add an attribute-value pair to a nonlist CExpr expression\n"; + return; + } + +// DeleteAttributeValue(attribute); + + CExpr *patt = new CExpr(CExprWord, attribute); + CExpr *pval = new CExpr(CExprWord, val); + CExpr *pequals = new CExpr(CExprWord, "="); + + CExpr *listExpr = new CExpr(CExprList); + + listExpr->Append(pequals); + listExpr->Append(patt); + listExpr->Append(pval); + + Append(listExpr); +} + +void CExpr::AddAttributeValue(const CString& attribute, wxList *val) +{ + if (type != CExprList) + { +// cout << "Error! tried to add an attribute-value pair to a nonlist CExpr expression\n"; + return; + } + if (!val) + return; + +// DeleteAttributeValue(attribute); + + CExpr *patt = new CExpr(CExprWord, attribute); + CExpr *pval = new CExpr(val); + CExpr *pequals = new CExpr(CExprWord, "="); + + CExpr *listExpr = new CExpr(CExprList); + + listExpr->Append(pequals); + listExpr->Append(patt); + listExpr->Append(pval); + + Append(listExpr); +} + +void CExpr::AddAttributeValueStringList(const CString& attribute, wxList *string_list) +{ + if (type != CExprList) + { +// cout << "Error! tried to add an attribute-value pair to a nonlist CExpr expression\n"; + return; + } + if (!string_list) + return; + +// DeleteAttributeValue(attribute); + + // First make a list of CExpr strings + CExpr *listExpr = new CExpr(CExprList); + wxNode *node = string_list->First(); + while (node) + { + char *string = (char *)node->Data(); + CExpr *expr = new CExpr(CExprString, CString(string)); + listExpr->Append(expr); + node = node->Next(); + } + + // Now make an (=, Att, Value) triple + CExpr *patt = new CExpr(CExprWord, attribute); + CExpr *pequals = new CExpr(CExprWord, "="); + + CExpr *listExpr2 = new CExpr(CExprList); + + listExpr2->Append(pequals); + listExpr2->Append(patt); + listExpr2->Append(listExpr); + + Append(listExpr2); +} + +BOOL CExpr::GetAttributeValue(const CString& att, int& var) +{ + CExpr *expr = AttributeValue(att); + + if (expr && (expr->Type() == CExprInteger || expr->Type() == CExprReal)) + { + var = (int)(expr->IntegerValue()); + return TRUE; + } + else + return FALSE; +} + +BOOL CExpr::GetAttributeValue(const CString& att, long& var) +{ + CExpr *expr = AttributeValue(att); + + if (expr && (expr->Type() == CExprInteger || expr->Type() == CExprReal)) + { + var = expr->IntegerValue(); + return TRUE; + } + else + return FALSE; +} + +BOOL CExpr::GetAttributeValue(const CString& att, float& var) +{ + CExpr *expr = AttributeValue(att); + if (expr && (expr->Type() == CExprInteger || expr->Type() == CExprReal)) + { + var = expr->RealValue(); + return TRUE; + } + else + return FALSE; +} + +BOOL CExpr::GetAttributeValue(const CString& att, CString& var) // Word OR string -> string +{ + CExpr *expr = AttributeValue(att); + if (expr && expr->Type() == CExprWord) + { + var = expr->WordValue(); + return TRUE; + } + else if (expr && expr->Type() == CExprString) + { + var = expr->StringValue(); + return TRUE; + } + else + return FALSE; +} + +BOOL CExpr::GetAttributeValue(const CString& att, CExpr **var) +{ + CExpr *expr = AttributeValue(att); + if (expr) + { + *var = expr; + return TRUE; + } + else + return FALSE; +} + +BOOL CExpr::GetAttributeValueStringList(const CString& att, wxList *var) +{ + CExpr *expr = AttributeValue(att); + if (expr && expr->Type() == CExprList) + { + CExpr *string_expr = expr->value.first; + while (string_expr) + { + if (string_expr->Type() == CExprString) + var->Append((CObject *)copystring(string_expr->StringValue())); + + string_expr = string_expr->next; + } + return TRUE; + } + else + return FALSE; +} + +void CExpr::WriteClause(ostream& stream) // Write this expression as a top-level clause +{ + if (type != CExprList) + return; + + CExpr *node = value.first; + if (node) + { + node->WriteExpr(stream); + stream << "("; + node = node->next; + BOOL first = TRUE; + while (node) + { + if (!first) + stream << " "; + node->WriteExpr(stream); + node = node->next; + if (node) stream << ",\n"; + first = FALSE; + } + stream << ").\n\n"; + } +} + +void CExpr::WriteExpr(ostream& stream) // Write as any other subexpression +{ + // This seems to get round an optimizer bug when + // using Watcom C++ 10a in WIN32 compilation mode. + // If these lines not present, the type seems to be + // interpreted wrongly as an integer. + // I don't want to turn optimization off since it's needed + // for reading in files quickly. +#if defined(__WATCOMC__) + char buf[2]; + sprintf(buf, ""); +#endif + + switch (type) + { + case CExprInteger: + { + stream << value.integer; + break; + } + case CExprReal: + { + float f = value.real; +/* Now the parser can cope with this. + // Prevent printing in 'e' notation. Any better way? + if (fabs(f) < 0.00001) + f = 0.0; +*/ + char buf[40]; + sprintf(buf, "%.6g", f); + stream << buf; + break; + } + case CExprString: + { + stream << "\""; + int i; + int len = strlen(value.string); + for (i = 0; i < len; i++) + { + char ch = value.string[i]; + if (ch == '"' || ch == '\\') + stream << "\\"; + stream << ch; + } + + stream << "\""; + break; + } + case CExprWord: + { + BOOL quote_it = FALSE; + int len = strlen(value.word); + if ((len == 0) || (len > 0 && (value.word[0] > 64 && value.word[0] < 91))) + quote_it = TRUE; + else + { + int i; + for (i = 0; i < len; i++) + if ((!isalpha(value.word[i])) && (!isdigit(value.word[i])) && + (value.word[i] != '_')) + { quote_it = TRUE; i = len; } + } + + if (quote_it) + stream << "'"; + + stream << value.word; + + if (quote_it) + stream << "'"; + + break; + } + case CExprList: + { + if (!value.first) + stream << "[]"; + else + { + CExpr *expr = value.first; + + if ((expr->Type() == CExprWord) && (strcmp(expr->WordValue(), "=") == 0)) + { + CExpr *arg1 = expr->next; + CExpr *arg2 = arg1->next; + arg1->WriteExpr(stream); + stream << " = "; + arg2->WriteExpr(stream); + } + else + { + stream << "["; + while (expr) + { + expr->WriteExpr(stream); + expr = expr->next; + if (expr) stream << ", "; + } + stream << "]"; + } + } + break; + } + case CExprNull: break; + } +} + +void CExpr::WriteLispExpr(ostream& stream) +{ + switch (type) + { + case CExprInteger: + { + stream << value.integer; + break; + } + case CExprReal: + { + stream << value.real; + break; + } + case CExprString: + { + stream << "\"" << value.string << "\""; + break; + } + case CExprWord: + { + stream << value.word; + break; + } + case CExprList: + { + CExpr *expr = value.first; + + stream << "("; + while (expr) + { + expr->WriteLispExpr(stream); + expr = expr->next; + if (expr) stream << " "; + } + + stream << ")"; + break; + } + case CExprNull: break; + } +} + +// CExpr 'database' (list of expressions) +CExprDatabase::CExprDatabase(CExprErrorHandler handler) +{ + position = NULL; + hash_table = NULL; + currentCExprErrorHandler = handler; + noErrors = 0; +} + +CExprDatabase::CExprDatabase(CExprType type, const CString& attribute, int size, + CExprErrorHandler handler) +{ + position = NULL; + attribute_to_hash = attribute; + if (type == CExprString) + hash_table = new wxHashTable(wxKEY_STRING, size); + else if (type == CExprInteger) + hash_table = new wxHashTable(wxKEY_INTEGER, size); + else hash_table = NULL; + + currentCExprErrorHandler = handler; + noErrors = 0; +} + +CExprDatabase::~CExprDatabase(void) +{ + ClearDatabase(); + if (hash_table) + delete hash_table; +} + +int CExprDatabase::GetItemCount(void) // get count of possible items +{ + int z = 0; + wxNode *node = First(); + while (node) + { + z++; + node = node->Next(); + } + return z; +} + +void CExprDatabase::BeginFind(void) // Initialise a search +{ + position = First(); +} + +CExpr *CExprDatabase::FindClause(long id) // Find a term based on an integer id attribute + // e.g. node(id=23, type=rectangle, ....). +{ + CExpr *found = NULL; + while (position && !found) + { + CExpr *term = (CExpr *)position->Data(); + + if (term->Type() == CExprList) + { + CExpr *value = term->AttributeValue("id"); + if (value->Type() == CExprInteger && value->IntegerValue() == id) + found = term; + } + position = position->Next(); + } + return found; +} + +// Find on basis of attribute/value pairs, e.g. type=rectangle +CExpr *CExprDatabase::FindClause(const CString& word, const CString& val) +{ + CExpr *found = NULL; + while (position && !found) + { + CExpr *term = (CExpr *)position->Data(); + + if (term->Type() == CExprList) + { + CExpr *value = term->AttributeValue(word); + if ((value->Type() == CExprWord && value->WordValue() == val) || + (value->Type() == CExprString && value->StringValue() == val)) + found = term; + } + position = position->Next(); + } + return found; +} + +CExpr *CExprDatabase::FindClause(const CString& word, long val) +{ + CExpr *found = NULL; + while (position && !found) + { + CExpr *term = (CExpr *)position->Data(); + + if (term->Type() == CExprList) + { + CExpr *value = term->AttributeValue(word); + if ((value->Type() == CExprInteger) && (value->IntegerValue() == val)) + found = term; + } + position = position->Next(); + } + return found; +} + +CExpr *CExprDatabase::FindClause(const CString& word, float val) +{ + CExpr *found = NULL; + while (position && !found) + { + CExpr *term = (CExpr *)position->Data(); + + if (term->Type() == CExprList) + { + CExpr *value = term->AttributeValue(word); + if ((value->Type() == CExprReal) && (value->RealValue() == val)) + found = term; + } + position = position->Next(); + } + return found; +} + +CExpr *CExprDatabase::FindClauseByFunctor(const CString& functor) +{ + CExpr *found = NULL; + while (position && !found) + { + CExpr *term = (CExpr *)position->Data(); + + if (term->Type() == CExprList) + { + if (term->Functor() == functor) + found = term; + } + position = position->Next(); + } + return found; +} + +// If hashing is on, must store in hash table too +void CExprDatabase::Append(CExpr *clause) +{ + wxList::Append((CObject *)clause); + if (hash_table) + { + CString functor(clause->Functor()); + CExpr *expr = clause->AttributeValue(attribute_to_hash); + if (expr) + { + long functor_key = hash_table->MakeKey((char *)(const char *)functor); + long value_key = 0; + if (expr && expr->Type() == CExprString) + { + value_key = hash_table->MakeKey((char *)(const char *)expr->StringValue()); + hash_table->Put(functor_key + value_key, (char *)(const char *)expr->StringValue(), (CObject *)clause); + } + else if (expr && expr->Type() == CExprInteger) + { + value_key = expr->IntegerValue(); + hash_table->Put(functor_key + value_key, expr->IntegerValue(), (CObject *)clause); + } + + } + } +} + +CExpr *CExprDatabase::HashFind(const CString& functor, long value) +{ + long key = hash_table->MakeKey((char *)(const char *)functor) + value; + + // The key alone isn't guaranteed to be unique: + // must supply value too. Let's assume the value of the + // id is going to be reasonably unique. + return (CExpr *)hash_table->Get(key, value); +} + +CExpr *CExprDatabase::HashFind(const CString& functor, const CString& value) +{ + long key = hash_table->MakeKey((char *)(const char *)functor) + hash_table->MakeKey((char *)(const char *)value); + return (CExpr *)hash_table->Get(key, (char *)(const char *)value); +} + +void CExprDatabase::ClearDatabase(void) +{ + noErrors = 0; + wxNode *node = First(); + while (node) + { + CExpr *expr = (CExpr *)node->Data(); + delete expr; + delete node; + node = First(); + } + + if (hash_table) + hash_table->Clear(); +} + +BOOL CExprDatabase::Read(const CString& filename) +{ + noErrors = 0; + + FILE *f = fopen((const char *)filename, "r"); + if (f) + { + theCExprDatabase = this; + + LexFromFile(f); + yyparse(); + fclose(f); + + CExprCleanUp(); + return (noErrors == 0); + } + else + { + return FALSE; + } +} + +BOOL CExprDatabase::ReadFromString(const CString& buffer) +{ + noErrors = 0; + theCExprDatabase = this; + + LexFromString((char *)(const char *)buffer); + yyparse(); + CExprCleanUp(); + return (noErrors == 0); +} + +BOOL CExprDatabase::Write(const CString& fileName) +{ + ofstream str((char *)(const char *)fileName); + if (str.bad()) + return FALSE; + return Write(str); +} + +BOOL CExprDatabase::Write(ostream& stream) +{ + noErrors = 0; + wxNode *node = First(); + while (node) + { + CExpr *expr = (CExpr *)node->Data(); + expr->WriteClause(stream); + node = node->Next(); + } + return (noErrors == 0); +} + +void CExprDatabase::WriteLisp(ostream& stream) +{ + noErrors = 0; + wxNode *node = First(); + while (node) + { + CExpr *expr = (CExpr *)node->Data(); + expr->WriteLispExpr(stream); + stream << "\n\n"; + node = node->Next(); + } +} + +void add_expr(CExpr * expr) +{ + theCExprDatabase->Append(expr); +} + +// Checks functor +BOOL CExprIsFunctor(CExpr *expr, const CString& functor) +{ + if (expr && (expr->Type() == CExprList)) + { + CExpr *first_expr = expr->value.first; + + if (first_expr && (first_expr->Type() == CExprWord) && + (first_expr->WordValue() == functor)) + return TRUE; + else + return FALSE; + } + else + return FALSE; +} + +/* + * Called from parser + * + */ + +char *make_integer(char *str) +{ + CExpr *x = new CExpr(atol(str)); + + return (char *)x; +} + +char *make_real(char *str1, char *str2) +{ + char buf[50]; + + sprintf(buf, "%s.%s", str1, str2); + float f = (float)atof(buf); + CExpr *x = new CExpr(f); + + return (char *)x; +} + +// extern "C" double exp10(double); + +char *make_exp(char *str1, char *str2) +{ + double mantissa = (double)atoi(str1); + double exponent = (double)atoi(str2); + + double d = mantissa * pow(10.0, exponent); + + CExpr *x = new CExpr((float)d); + + return (char *)x; +} + +char *make_exp2(char *str1, char *str2, char *str3) +{ + char buf[50]; + + sprintf(buf, "%s.%s", str1, str2); + double mantissa = (double)atof(buf); + double exponent = (double)atoi(str3); + + double d = mantissa * pow(10.0, exponent); + + CExpr *x = new CExpr((float)d); + + return (char *)x; +} + +char *make_word(char *str) +{ + CExpr *x = new CExpr(CExprWord, str); + return (char *)x; +} + +char *make_string(char *str) +{ + char *s, *t; + int len, i; + + str++; /* skip leading quote */ + len = strlen(str) - 1; /* ignore trailing quote */ + + s = new char[len + 1]; + + t = s; + for(i=0; iInsert(car); + return (char *)cdr; +} + +void process_command(char * cexpr) +{ + CExpr *expr = (CExpr *)cexpr; + add_expr(expr); +} + +void syntax_error(char *s) +{ + if (currentCExprErrorHandler) + (void)(*(currentCExprErrorHandler))(CEXPR_ERROR_SYNTAX, "syntax error"); + if (theCExprDatabase) theCExprDatabase->noErrors += 1; +} + +#ifdef _WINDLL +char *__cdecl strdup(const char *s) +{ + int len = strlen(s); + char *new_s = (char *)malloc(sizeof(char)*(len+1)); + strcpy(new_s, s); + return new_s; +} +#endif diff --git a/CExpr/Cexpr.dsp b/CExpr/Cexpr.dsp new file mode 100644 index 0000000..a207677 --- /dev/null +++ b/CExpr/Cexpr.dsp @@ -0,0 +1,134 @@ +# Microsoft Developer Studio Project File - Name="cexpr" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=cexpr - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Cexpr.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Cexpr.mak" CFG="cexpr - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "cexpr - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "cexpr - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe + +!IF "$(CFG)" == "cexpr - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir ".\Release" +# PROP BASE Intermediate_Dir ".\Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 1 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir ".\Release" +# PROP Intermediate_Dir ".\Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "USE_DEFINE" /D "YY_USE_PROTOS" /D "_MBCS" /FD /c +# SUBTRACT CPP /YX +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "cexpr - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir ".\cexpr___" +# PROP BASE Intermediate_Dir ".\cexpr___" +# PROP BASE Target_Dir "" +# PROP Use_MFC 1 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir ".\Debug" +# PROP Intermediate_Dir ".\Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "USE_DEFINE" /D "YY_USE_PROTOS" /D "_MBCS" /FD /c +# SUBTRACT CPP /YX +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "cexpr - Win32 Release" +# Name "cexpr - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90" +# Begin Source File + +SOURCE=.\cexpr.cpp +# End Source File +# Begin Source File + +SOURCE=.\wx_hash.cpp +# End Source File +# Begin Source File + +SOURCE=.\wx_list.cpp +# End Source File +# Begin Source File + +SOURCE=.\Y_tab.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" +# Begin Source File + +SOURCE=.\cexpr.h +# End Source File +# Begin Source File + +SOURCE=.\expr.h +# End Source File +# Begin Source File + +SOURCE=.\stdafx.h +# End Source File +# Begin Source File + +SOURCE=.\wx_hash.h +# End Source File +# Begin Source File + +SOURCE=.\wx_list.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\Lex_yy.c +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 +# End Source File +# End Target +# End Project diff --git a/CExpr/Cexpr.dsw b/CExpr/Cexpr.dsw new file mode 100644 index 0000000..0b754e5 --- /dev/null +++ b/CExpr/Cexpr.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 5.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "cexpr"=.\Cexpr.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/CExpr/Cexpr.h b/CExpr/Cexpr.h new file mode 100644 index 0000000..dd2bff3 --- /dev/null +++ b/CExpr/Cexpr.h @@ -0,0 +1,246 @@ +/* + * File: cexpr.h + * Purpose: Prolog-like file I/O + * Author: Julian Smart + * Created: 1997 + * Updated: + * Copyright: (c) 1997, Julian Smart + */ + +/* sccsid[] = "%W% %G%" */ + +#ifndef __CEXPRH__ +#define __CEXPRH__ + +#include +#include +#include "wx_list.h" +#include "wx_hash.h" +#include "expr.h" + +// Error types +#define CEXPR_ERROR_GENERAL 1 +#define CEXPR_ERROR_SYNTAX 2 + +// Error handler function definition. If app returns TRUE, +// carry on processing. +typedef BOOL (*CExprErrorHandler) (int errorType, char *msg); + +extern CExprErrorHandler currentCExprErrorHandler; + +extern "C" FILE *yyin; +//#ifndef __WATCOMC__ +extern "C" +//#endif + int yyparse(void); + +typedef enum { + CExprNull, + CExprInteger, + CExprReal, + CExprWord, + CExprString, + CExprList +} CExprType; + +class CExprDatabase; +class ClipsTemplate; +class ClipsTemplateSlot; + +class CExpr +{ + public: + CObject *client_data; + CExprType type; + union { + long integer; + char *word; + char *string; + float real; + CExpr *first; // If is a list expr, points to the first node + } value; + + CExpr *next; // If this is a node in a list, points to the next node + CExpr *last; // If is a list expr, points to the last node + + CExpr(CExprType the_type, char *word_or_string, BOOL allocate); + CExpr(const CString& functor); // Assume this is a new clause - pass functor + CExpr(CExprType the_type, const CString& word_or_string = ""); + CExpr(long the_integer); + CExpr(float the_real); + CExpr(wxList *the_list); + ~CExpr(void); + + inline CExprType Type(void) { return type; } + inline long IntegerValue(void) + { + if (type == CExprInteger) + return value.integer; + else if (type == CExprReal) + return (long)value.real; + else return 0; + } + + inline float RealValue(void) { + if (type == CExprReal) + return value.real; + else if (type == CExprInteger) + return (float)value.integer; + else return (float)0.0; + } + + inline CString WordValue(void) { + if (type == CExprWord) + return value.word; + else if (type == CExprString) + return CString(value.string); + else return CString(""); + } + + inline CString StringValue(void) { + if (type == CExprString) + return CString(value.string); + else if (type == CExprWord) + return CString(value.word); + else return CString(""); + } + + // Get nth arg of clause (starting from 1) + CExpr *Arg(CExprType type, int arg); + + // Return nth argument of a list expression (starting from zero) + CExpr *Nth(int arg); + // Returns the number of elements in a list expression + int Number(void); + + CExpr *Copy(void); + + CExpr *GetAttributeValueNode(const CString& word); // Use only for a clause or list + CExpr *AttributeValue(const CString& word); // Use only for a clause + CString Functor(void); // Only for a clause + BOOL IsFunctor(const CString& s); // Only for a clause + void WriteClause(ostream& stream); // Write this expression as a top-level clause + void WriteExpr(ostream& stream); // Write as any other subexpression + void WriteLispExpr(ostream& stream); + void WriteClipsClause(ostream& stream, BOOL filtering = FALSE, + CExprDatabase *database = NULL); + void WriteClipsSlot(ostream& stream, ClipsTemplate *temp); + void WriteClipsList(ostream& stream); + + // Append an expression to a list + void Append(CExpr *expr); + // Insert at beginning of list + void Insert(CExpr *expr); + + // Get first expr in list + inline CExpr *GetFirst(void) { return ((type == CExprList) ? value.first : NULL); } + + // Get next expr if this is a node in a list + inline CExpr *GetNext(void) { return next; } + + // Get last expr in list + inline CExpr *GetLast(void) { return ((type == CExprList) ? last : NULL); } + + // This should really be called SetAttributeValue since any existing + // attribute-value is deleted first. + void AddAttributeValue(const CString& attribute, long value); + void AddAttributeValue(const CString& attribute, float value); + void AddAttributeValueWord(const CString& attribute, const CString& value); + void AddAttributeValueString(const CString& attribute, const CString& value); + void AddAttributeValue(const CString& attribute, wxList *value); + void AddAttributeValue(const CString& attribute, CExpr *value); + void AddAttributeValueStringList(const CString& attribute, wxList *string_list); + + void DeleteAttributeValue(const CString& attribute); + + BOOL GetAttributeValue(const CString& att, int& var); + BOOL GetAttributeValue(const CString& att, long& var); + BOOL GetAttributeValue(const CString& att, float& var); + BOOL GetAttributeValue(const CString& att, CString& var); // Word OR string -> string + BOOL GetAttributeValue(const CString& att, CExpr **var); + + // Add string items to list if the list attribute exists + BOOL GetAttributeValueStringList(const CString& att, wxList *var); + + // Associate other data with this expression, e.g. when reading in a + // number of linked items - store C++ object pointer with the expression + // so we can index into the CExpr database and fish out the pointer. + inline void SetClientData(CObject *data) { client_data = data; } + inline CObject *GetClientData(void) { return client_data; } +}; + +class CExprDatabase: public wxList +{ + DECLARE_DYNAMIC(CExprDatabase) + private: + wxNode *position; // Where we are in a search + wxHashTable *hash_table; + CString attribute_to_hash; + public: + int noErrors; + + CExprDatabase(CExprErrorHandler handler = 0); + + // Use hashing on both the functor, and the attribute of + // specified type (CExprString or CExprInteger) and name. + // So to find node 45 + // (i.e. match the clause node(id=45, ...)) + // it usually requires 1 look-up: the keys for functor and attribute + // are added together. + // Obviously if the attribute was missing in a clause, it would + // fail to be found by this method, but could be retrieved by a + // linear search using BeginFind and FindClauseByFunctor, + // or just searching through the list as per usual. + + CExprDatabase(CExprType type, const CString& attribute, int size = 500, + CExprErrorHandler handler = 0); + + ~CExprDatabase(void); + + int GetItemCount(void); // get count of possible items + void BeginFind(void); // Initialise a search + CExpr *FindClause(long id); // Find a term based on an integer id attribute + // e.g. node(id=23, type=rectangle, ....). + + // Find on basis of attribute/value pairs, e.g. type=rectangle + // This doesn't use hashing; it's a linear search. + CExpr *FindClause(const CString& word, const CString& value); + CExpr *FindClause(const CString& word, long value); + CExpr *FindClause(const CString& word, float value); + CExpr *FindClauseByFunctor(const CString& functor); + + CExpr *HashFind(const CString& functor, const CString& value); + CExpr *HashFind(const CString& functor, long value); + + void Append(CExpr *expr); // Does cleverer things if hashing is on + void ClearDatabase(void); + inline int GetErrorCount() { return noErrors; } + BOOL Read(const CString& filename); + BOOL ReadFromString(const CString& buffer); + BOOL Write(const CString& fileName); + BOOL Write(ostream& stream); + void WriteLisp(ostream& stream); +}; + +// Function call-style interface - some more convenience wrappers/unwrappers + +// Make a call +CExpr *CExprMakeCall(const CString& functor ...); + +#define CExprMakeInteger(x) (new CExpr((long)x)) +#define CExprMakeReal(x) (new CExpr((float)x)) +#define CExprMakeString(x) (new CExpr(CExprString, x)) +#define CExprMakeWord(x) (new CExpr(CExprWord, x)) +#define CExprMake(x) (new CExpr(x)) + +// Checks functor +BOOL CExprIsFunctor(CExpr *expr, const CString& functor); + +// Temporary variable for communicating between read.cc and YACC/LEX +extern CExprDatabase *theCExprDatabase; + +// YACC/LEX can leave memory lying around... +extern "C" CExprCleanUp(); + +#endif + diff --git a/CExpr/Cexpr.mak b/CExpr/Cexpr.mak new file mode 100644 index 0000000..1f81da4 --- /dev/null +++ b/CExpr/Cexpr.mak @@ -0,0 +1,234 @@ +# Microsoft Developer Studio Generated NMAKE File, Format Version 4.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +!IF "$(CFG)" == "" +CFG=cexpr - Win32 Debug +!MESSAGE No configuration specified. Defaulting to cexpr - Win32 Debug. +!ENDIF + +!IF "$(CFG)" != "cexpr - Win32 Release" && "$(CFG)" != "cexpr - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE on this makefile +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Cexpr.mak" CFG="cexpr - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "cexpr - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "cexpr - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF +################################################################################ +# Begin Project +# PROP Target_Last_Scanned "cexpr - Win32 Debug" +CPP=cl.exe + +!IF "$(CFG)" == "cexpr - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 2 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +OUTDIR=.\Release +INTDIR=.\Release + +ALL : "$(OUTDIR)\Cexpr.lib" + +CLEAN : + -@erase ".\Release\Cexpr.lib" + -@erase ".\Release\wx_hash.obj" + -@erase ".\Release\cexpr.obj" + -@erase ".\Release\wx_list.obj" + -@erase ".\Release\Y_tab.obj" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "USE_DEFINE" /D "YY_USE_PROTOS" /D "_AFXDLL" /D "_MBCS" /c +# SUBTRACT CPP /YX +CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\ + "USE_DEFINE" /D "YY_USE_PROTOS" /D "_AFXDLL" /D "_MBCS" /Fo"$(INTDIR)/" /c +CPP_OBJS=.\Release/ +CPP_SBRS= +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/Cexpr.bsc" +BSC32_SBRS= +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +LIB32_FLAGS=/nologo /out:"$(OUTDIR)/Cexpr.lib" +LIB32_OBJS= \ + "$(INTDIR)/wx_hash.obj" \ + "$(INTDIR)/cexpr.obj" \ + "$(INTDIR)/wx_list.obj" \ + "$(INTDIR)/Y_tab.obj" + +"$(OUTDIR)\Cexpr.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) + $(LIB32) @<< + $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) +<< + +!ELSEIF "$(CFG)" == "cexpr - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "cexpr___" +# PROP BASE Intermediate_Dir "cexpr___" +# PROP BASE Target_Dir "" +# PROP Use_MFC 2 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +OUTDIR=.\Debug +INTDIR=.\Debug + +ALL : "$(OUTDIR)\Cexpr.lib" + +CLEAN : + -@erase ".\Debug\Cexpr.lib" + -@erase ".\Debug\wx_list.obj" + -@erase ".\Debug\cexpr.obj" + -@erase ".\Debug\wx_hash.obj" + -@erase ".\Debug\Y_tab.obj" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "USE_DEFINE" /D "YY_USE_PROTOS" /D "_AFXDLL" /D "_MBCS" /c +# SUBTRACT CPP /YX +CPP_PROJ=/nologo /MDd /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D\ + "USE_DEFINE" /D "YY_USE_PROTOS" /D "_AFXDLL" /D "_MBCS" /Fo"$(INTDIR)/" /c +CPP_OBJS=.\Debug/ +CPP_SBRS= +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/Cexpr.bsc" +BSC32_SBRS= +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +LIB32_FLAGS=/nologo /out:"$(OUTDIR)/Cexpr.lib" +LIB32_OBJS= \ + "$(INTDIR)/wx_list.obj" \ + "$(INTDIR)/cexpr.obj" \ + "$(INTDIR)/wx_hash.obj" \ + "$(INTDIR)/Y_tab.obj" + +"$(OUTDIR)\Cexpr.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) + $(LIB32) @<< + $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) +<< + +!ENDIF + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +################################################################################ +# Begin Target + +# Name "cexpr - Win32 Release" +# Name "cexpr - Win32 Debug" + +!IF "$(CFG)" == "cexpr - Win32 Release" + +!ELSEIF "$(CFG)" == "cexpr - Win32 Debug" + +!ENDIF + +################################################################################ +# Begin Source File + +SOURCE=.\wx_hash.cpp +DEP_CPP_WX_HA=\ + ".\stdafx.h"\ + ".\wx_list.h"\ + ".\wx_hash.h"\ + + +"$(INTDIR)\wx_hash.obj" : $(SOURCE) $(DEP_CPP_WX_HA) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\wx_list.cpp +DEP_CPP_WX_LI=\ + ".\stdafx.h"\ + ".\wx_list.h"\ + + +"$(INTDIR)\wx_list.obj" : $(SOURCE) $(DEP_CPP_WX_LI) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\cexpr.cpp +DEP_CPP_CEXPR=\ + ".\stdafx.h"\ + ".\expr.h"\ + ".\cexpr.h"\ + ".\wx_list.h"\ + ".\wx_hash.h"\ + + +"$(INTDIR)\cexpr.obj" : $(SOURCE) $(DEP_CPP_CEXPR) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Y_tab.c +DEP_CPP_Y_TAB=\ + ".\expr.h"\ + ".\Lex_yy.c"\ + + +"$(INTDIR)\Y_tab.obj" : $(SOURCE) $(DEP_CPP_Y_TAB) "$(INTDIR)" ".\Lex_yy.c" + + +# End Source File +# End Target +# End Project +################################################################################ diff --git a/CExpr/Cexpr.mdp b/CExpr/Cexpr.mdp new file mode 100644 index 0000000000000000000000000000000000000000..b439e1fc669c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Nu zaf=N*Q2ak%#{WtF@0MQAE&iYQe;fZUCN)I?Q9u+B1w;W+Kok%KM1dErfcSqp`|2^wfh3 z^*(U0=$+xU)3Mjf>6ZL&$^Vx8Z^{3Trk8N+BBq__QkLhr9;SiqK)h&p6-A5(GyP-J%hKS zgeCk9PJfjP*F=;oeoM=yZPV2(|8Kv$#m(Wi16YTzkkR6o$7ns-8PD>$y*WlS1*A4( z7JIVozrTgxU)a)0J8{K2Vw$!uJrkJ)c$@I)kFx{$?B#(Ty|erB(8bQ~?p#;rz)<&K zXIIximwvTt=xQ#1=@U)sz^7?J(%@Wakuv5sq74;pp;4LtvHl_(dH>7M$jy98$@{" with flags "" + +Creating temp file "E:\TEMP\RSPC.tmp" with contents +Creating command line "cl.exe @E:\TEMP\RSPC.tmp" +Creating command line "link.exe -lib /nologo /out:".\Release\Cexpr.lib" .\Release\cexpr.obj .\Release\wx_hash.obj .\Release\wx_list.obj .\Release\Y_tab.obj" +Compiling... +cexpr.cpp +wx_hash.cpp +wx_list.cpp +Generating Code... +Compiling... +Y_tab.c +lexer.l(277) : warning C4013: 'read' undefined; assuming extern returning int +y_tab.c(516) : warning C4102: 'yyerrlab' : unreferenced label +y_tab.c(516) : warning C4102: 'yynewerror' : unreferenced label +Generating Code... +Creating library... + + + +Cexpr.lib - 0 error(s), 3 warning(s) diff --git a/CExpr/DOSLEX.C b/CExpr/DOSLEX.C new file mode 100644 index 0000000..60a57fd --- /dev/null +++ b/CExpr/DOSLEX.C @@ -0,0 +1,1208 @@ +/* A lexical scanner generated by flex */ + +/* scanner skeleton version: + * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.16 90/08/03 14:09:36 vern Exp $ + */ + +#define FLEX_SCANNER + +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include +#include + +/* use prototypes in function declarations */ +#define YY_USE_PROTOS + +/* the "const" storage-class-modifier is valid */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#ifdef __STDC__ + +#ifdef __GNUC__ +#include +#else +#include +#endif /* __GNUC__ */ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + + +#ifdef __TURBOC__ +#define YY_USE_CONST +#endif + + +#ifndef YY_USE_CONST +#define const +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +/* we can't get here if it's an ANSI C compiler, or a C++ compiler, + * so it's got to be a K&R compiler, and therefore there's no standard + * place from which to include these definitions + */ +/* +char *malloc(); +int free(); +*/ + +int read(); +#endif + + +/* amount of stuff to slurp up with each read */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* returned upon end-of-file */ +#define YY_END_TOK 0 + +/* copy whatever the last rule matched to the standard output */ + +/* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */ +/* this used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite() + */ +#define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout ) + +/* gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#define YY_INPUT(buf,result,max_size) \ + if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "read() in flex scanner failed" ); +#define YY_NULL 0 + +/* no semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#define yyterminate() return ( YY_NULL ) + +/* report a fatal error */ + +/* The funky do-while is used to turn this macro definition into + * a single C statement (which needs a semi-colon terminator). + * This avoids problems with code like: + * + * if ( something_happens ) + * YY_FATAL_ERROR( "oops, the something happened" ); + * else + * everything_okay(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the YY_FATAL_ERROR() call. + */ + +#define YY_FATAL_ERROR(msg) \ + do \ + { \ + (void) fputs( msg, stderr ); \ + (void) putc( '\n', stderr ); \ + exit( 1 ); \ + } \ + while ( 0 ) + +/* default yywrap function - always treat EOF as an EOF */ +int yywrap(void) { return 1; } + + +/* enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN + */ +#define BEGIN yy_start = 1 + 2 * + +/* action number for EOF rule of a given start state */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* special action meaning "start processing a new file" */ +#define YY_NEW_FILE \ + do \ + { \ + yy_init_buffer( yy_current_buffer, yyin ); \ + yy_load_buffer_state(); \ + } \ + while ( 0 ) + +/* default declaration of generated scanner - a define so the user can + * easily add parameters + */ +#define YY_DECL int yylex YY_PROTO(( void )) + +/* code executed at the end of each rule */ +#define YY_BREAK break; + +#define YY_END_OF_BUFFER_CHAR 0 + +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */ +#endif + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +#define YY_CHAR unsigned char +# line 1 "lexer.l" +#define INITIAL 0 +# line 9 "lexer.l" +/* + * File: lexer.l + * Description: Lexical analyser for PROLOGIO; can be used with + * either lex and flex. + */ +#include + +/* +++steve162e: added, otherwise, CExpr_input will be undefined (at least under LINUX) + please check, if this is also TRUE under other UNIXes. + */ + +#if defined(FLEX_SCANNER) && defined(_LINUX) +#define CExpr_input my_input +#endif +/* ---steve162e */ + +#include "expr.h" +#ifdef wx_x +extern char *malloc(); +#endif +#define Return(x) return x; + +#if defined(VMS) && !defined(strdup) +#define strdup(s) (strcpy((char *)malloc(strlen(s)+1), s)); +#endif + +static size_t lex_buffer_length = 0; +static const char *lex_buffer = NULL; +static size_t lex_string_ptr = 0; +static int lex_read_from_string = 0; + +static int my_input(void); +static int my_unput(char); + +#ifdef FLEX_SCANNER +#undef YY_INPUT +# define YY_INPUT(buf,result,max_size) \ + if (lex_read_from_string) \ + { int c = my_input(); result = (c == 0) ? YY_NULL : ((buf)[0]=(c), 1); } \ + else \ + if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "read() in flex scanner failed" ); +#else +# undef unput +# define unput(_c) my_unput(_c) +#endif + +# line 58 "lexer.l" + +/* done after the current pattern has been matched and before the + * corresponding action - sets up yytext + */ +#define YY_DO_BEFORE_ACTION \ + yytext = yy_bp; \ + yyleng = yy_cp - yy_bp; \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* return all but the first 'n' matched characters back to the input stream */ +#define yyless(n) \ + do \ + { \ + /* undo effects of setting up yytext */ \ + *yy_cp = yy_hold_char; \ + yy_c_buf_p = yy_cp = yy_bp + n; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#undef unput +#define unput(c) yyunput( c, yytext ) + + +struct yy_buffer_state + { + FILE *yy_input_file; + + YY_CHAR *yy_ch_buf; /* input buffer */ + YY_CHAR *yy_buf_pos; /* current position in input buffer */ + + /* size of input buffer in bytes, not including room for EOB characters*/ + int yy_buf_size; + + /* number of characters read into yy_ch_buf, not including EOB characters */ + int yy_n_chars; + + int yy_eof_status; /* whether we've seen an EOF on this buffer */ +#define EOF_NOT_SEEN 0 + /* "pending" happens when the EOF has been seen but there's still + * some text process + */ +#define EOF_PENDING 1 +#define EOF_DONE 2 + }; + +static YY_BUFFER_STATE yy_current_buffer; + +/* we provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state" + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed */ +static YY_CHAR yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + + +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +#ifndef YY_USER_INIT +#define YY_USER_INIT +#endif + +extern YY_CHAR *yytext; +extern int yyleng; +extern FILE *yyin, *yyout; + +YY_CHAR *yytext; +int yyleng; + +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; + +#define YY_END_OF_BUFFER 18 +typedef int yy_state_type; +static const short int yy_accept[34] = + { 0, + 0, 0, 18, 16, 13, 14, 16, 16, 6, 7, + 16, 8, 12, 16, 1, 11, 3, 9, 10, 2, + 0, 5, 0, 0, 0, 4, 1, 15, 3, 5, + 0, 0, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 4, 1, 1, 1, 1, 5, 6, + 7, 8, 9, 10, 9, 11, 12, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 1, 1, 1, + 14, 1, 1, 1, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 16, 17, 18, 1, 15, 1, 15, 15, 15, 15, + + 19, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 1, 20, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static const YY_CHAR yy_meta[21] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 1, 2, 1, 3, 1, 2, 1 + } ; + +static const short int yy_base[37] = + { 0, + 0, 0, 48, 55, 55, 55, 17, 42, 55, 55, + 19, 55, 55, 23, 17, 55, 0, 55, 55, 0, + 18, 55, 19, 23, 21, 55, 12, 55, 0, 24, + 25, 29, 55, 49, 52, 22 + } ; + +static const short int yy_def[37] = + { 0, + 33, 1, 33, 33, 33, 33, 34, 35, 33, 33, + 33, 33, 33, 33, 33, 33, 36, 33, 33, 36, + 34, 33, 34, 34, 35, 33, 33, 33, 36, 34, + 34, 34, 0, 33, 33, 33 + } ; + +static const short int yy_nxt[76] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 4, 11, 12, + 13, 14, 15, 16, 17, 18, 4, 19, 20, 4, + 22, 22, 30, 29, 27, 26, 22, 22, 30, 27, + 28, 27, 30, 23, 23, 23, 24, 24, 24, 31, + 23, 32, 24, 24, 24, 23, 26, 33, 24, 21, + 21, 21, 25, 25, 3, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33 + } ; + +static const short int yy_chk[76] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 7, 21, 23, 36, 27, 25, 24, 30, 31, 15, + 14, 11, 32, 7, 21, 23, 7, 21, 23, 24, + 30, 31, 24, 30, 31, 32, 8, 3, 32, 34, + 34, 34, 35, 35, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33 + } ; + +static yy_state_type yy_last_accepting_state; +static YY_CHAR *yy_last_accepting_cpos; + +/* the intent behind this definition is that it'll catch + * any uses of REJECT which flex missed + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 + +/* these variables are all declared out here so that section 3 code can + * manipulate them + */ +/* points to current character in buffer */ +static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr )); +void yyrestart YY_PROTO(( FILE *input_file )); +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); + +#define yy_new_buffer yy_create_buffer + +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif + +YY_DECL + { + register yy_state_type yy_current_state; + register YY_CHAR *yy_cp, *yy_bp; + register int yy_act; + + + + + if ( yy_init ) + { + YY_USER_INIT; + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( yy_current_buffer ) + yy_init_buffer( yy_current_buffer, yyin ); + else + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + + yy_init = 0; + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* support of yytext */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of the + * current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[*yy_cp]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = yy_def[yy_current_state]; + if ( yy_current_state >= 34 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 33 ); + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + YY_USER_ACTION; + +do_action: /* this label is used only to access EOF actions */ + + + switch ( yy_act ) + { + case 0: /* must backtrack */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +# line 60 "lexer.l" +{yylval.s = strdup(yytext); Return(INTEGER);} + YY_BREAK +case 2: +# line 62 "lexer.l" +Return(EXP); + YY_BREAK +case 3: +# line 64 "lexer.l" +{yylval.s = strdup(yytext); Return(WORD);} + YY_BREAK +case 4: +# line 66 "lexer.l" +{int len = strlen(yytext); + yytext[len-1] = 0; + yylval.s = strdup(yytext+1); + Return(WORD);} + YY_BREAK +case 5: +# line 71 "lexer.l" +{yylval.s = strdup(yytext); Return(STRING);} + YY_BREAK +case 6: +# line 73 "lexer.l" +Return(OPEN); + YY_BREAK +case 7: +# line 75 "lexer.l" +Return(CLOSE); + YY_BREAK +case 8: +# line 77 "lexer.l" +Return(COMMA); + YY_BREAK +case 9: +# line 79 "lexer.l" +Return(OPEN_SQUARE); + YY_BREAK +case 10: +# line 81 "lexer.l" +Return(CLOSE_SQUARE); + YY_BREAK +case 11: +# line 83 "lexer.l" +Return(EQUALS); + YY_BREAK +case 12: +# line 85 "lexer.l" +Return(PERIOD); + YY_BREAK +case 13: +# line 87 "lexer.l" +; + YY_BREAK +case 14: +# line 89 "lexer.l" +; + YY_BREAK +case 15: +# line 91 "lexer.l" +{ loop: +#ifdef __cplusplus + while (yyinput() != '*'); + switch (yyinput()) +#else + while (input() != '*'); + switch (input()) +#endif + { + case '/': break; + case '*': unput('*'); + default: goto loop; + } + } + YY_BREAK +case 16: +# line 106 "lexer.l" +Return(ERROR); + YY_BREAK +case 17: +# line 108 "lexer.l" +ECHO; + YY_BREAK +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* amount of text matched not including the EOB char */ + int yy_amount_of_matched_text = yy_cp - yytext - 1; + + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + + /* note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the end- + * of-buffer state). Contrast this with the test in yyinput(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* this was really a NUL */ + { + yy_state_type yy_next_state; + + yy_c_buf_p = yytext + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* okay, we're now positioned to make the + * NUL transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we + * don't want to build jamming into it because + * then it will run more slowly) + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = yytext + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* consume the NUL */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* note: because we've taken care in + * yy_get_next_buffer() to have set up yytext, + * we can now set up yy_c_buf_p so that if some + * total hoser (like flex itself) wants + * to call the scanner after we return the + * YY_NULL, it'll still work - another YY_NULL + * will get returned. + */ + yy_c_buf_p = yytext + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF((yy_start - 1) / 2); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + } + break; + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: +#ifdef FLEX_DEBUG + printf( "action # %d\n", yy_act ); +#endif + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } + } + } + + +/* yy_get_next_buffer - try to read in a new buffer + * + * synopsis + * int yy_get_next_buffer(); + * + * returns a code representing an action + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ + +static int yy_get_next_buffer() + + { + register YY_CHAR *dest = yy_current_buffer->yy_ch_buf; + register YY_CHAR *source = yytext - 1; /* copy prev. char, too */ + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + /* try to read more data */ + + /* first move last chars to start of buffer */ + number_to_move = yy_c_buf_p - yytext; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_n_chars = 0; + + else + { + int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + else if ( num_to_read <= 0 ) + YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); + + /* read in more data */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == 1 ) + { + ret_val = EOB_ACT_END_OF_FILE; + yy_current_buffer->yy_eof_status = EOF_DONE; + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_eof_status = EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + /* yytext begins at the second character in yy_ch_buf; the first + * character is the one which preceded it before reading in the latest + * buffer; it needs to be kept around in case it's a newline, so + * yy_get_previous_state() will have with '^' rules active + */ + + yytext = &yy_current_buffer->yy_ch_buf[1]; + + return ( ret_val ); + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached + * + * synopsis + * yy_state_type yy_get_previous_state(); + */ + +static yy_state_type yy_get_previous_state() + + { + register yy_state_type yy_current_state; + register YY_CHAR *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = yy_def[yy_current_state]; + if ( yy_current_state >= 34 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return ( yy_current_state ); + } + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +register yy_state_type yy_current_state; +#endif + + { + register int yy_is_jam; + register YY_CHAR *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = yy_def[yy_current_state]; + if ( yy_current_state >= 34 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 33); + + return ( yy_is_jam ? 0 : yy_current_state ); + } + + +#ifdef YY_USE_PROTOS +static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp ) +#else +static void yyunput( c, yy_bp ) +YY_CHAR c; +register YY_CHAR *yy_bp; +#endif + + { + register YY_CHAR *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */ + register YY_CHAR *dest = + &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2]; + register YY_CHAR *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += dest - source; + yy_bp += dest - source; + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + if ( yy_cp > yy_bp && yy_cp[-1] == '\n' ) + yy_cp[-2] = '\n'; + + *--yy_cp = c; + + /* note: the formal parameter *must* be called "yy_bp" for this + * macro to now work correctly + */ + YY_DO_BEFORE_ACTION; /* set up yytext again */ + } + + +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + + { + int c; + YY_CHAR *yy_cp = yy_c_buf_p; + + *yy_cp = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* this was really a NUL */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + yytext = yy_c_buf_p; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + { + yy_c_buf_p = yytext + YY_MORE_ADJ; + return ( EOF ); + } + + YY_NEW_FILE; + +#ifdef __cplusplus + return ( yyinput() ); +#else + return ( input() ); +#endif + } + break; + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext + YY_MORE_ADJ; + break; + + case EOB_ACT_LAST_MATCH: +#ifdef __cplusplus + YY_FATAL_ERROR( "unexpected last match in yyinput()" ); +#else + YY_FATAL_ERROR( "unexpected last match in input()" ); +#endif + } + } + } + + c = *yy_c_buf_p; + yy_hold_char = *++yy_c_buf_p; + + return ( c ); + } + + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + + { + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* flush out information for old buffer */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* we don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) ); + + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) ); + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + yy_init_buffer( b, file ); + + return ( b ); + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + free( (char *) b->yy_ch_buf ); + free( (char *) b ); + } + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + { + b->yy_input_file = file; + + /* we put in the '\n' and start reading from [1] so that an + * initial match-at-newline will be true. + */ + + b->yy_ch_buf[0] = '\n'; + b->yy_n_chars = 1; + + /* we always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[1]; + + b->yy_eof_status = EOF_NOT_SEEN; + } +# line 108 "lexer.l" + + + +#ifdef FLEX_SCANNER +static int lex_input() { + return input(); +} +#else /* BSD/AT&T lex */ +#ifndef input +# error "Sorry, but need either flex or AT&T lex" +#endif +static int lex_input() { + return input(); +} +/* # undef unput +# define unput(_c) my_unput(_c) +*/ + +# undef input +# define input() my_input() +static int my_unput(char c) +{ + if (lex_read_from_string) { + /* Make sure we have something */ + if (lex_string_ptr) { + if (c == '\n') yylineno--; + lex_string_ptr--; + } + } else { + yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar; +/* unput(c); Causes infinite recursion! */ + } + return c; +} + +#endif + +/* Public */ +void LexFromFile(FILE *fd) +{ + lex_read_from_string = 0; + yyin = fd; + /* Don't know why this is necessary, but otherwise + * lex only works _once_! + */ +#ifdef FLEX_SCANNER + yy_init = 1; +#endif +} + +void LexFromString(char *buffer) +{ + lex_read_from_string = 1; + lex_buffer = buffer; + lex_buffer_length = strlen(buffer); + lex_string_ptr = 0; + /* Don't know why this is necessary, but otherwise + * lex only works _once_! + */ +#ifdef FLEX_SCANNER + yy_init = 1; +#endif +} + +static int my_input( void ) +{ + if (lex_read_from_string) { + if (lex_string_ptr == lex_buffer_length) + return 0; + else { + char c = lex_buffer[lex_string_ptr++]; +#ifndef FLEX_SCANNER + if (c == '\n') yylineno++; +#endif + return c; + } + } else { + return lex_input(); + } +} + diff --git a/CExpr/DOSYACC.C b/CExpr/DOSYACC.C new file mode 100644 index 0000000..03f7726 --- /dev/null +++ b/CExpr/DOSYACC.C @@ -0,0 +1,516 @@ +#ifndef lint +static char yysccsid[] = "@(#)yaccpar 1.7 (Berkeley) 09/09/90"; +#endif +#define YYBYACC 1 +#line 2 "parser.y" +#include "string.h" +#include "expr.h" + +#ifndef __EXTERN_C__ +#define __EXTERN_C__ 1 +#endif + +#if defined(__cplusplus) || defined(__STDC__) +#if defined(__cplusplus) && defined(__EXTERN_C__) +extern "C" { +#endif +#endif +int yylex(void); +int yylook(void); +int yywrap(void); +int yyback(int *, int); + +/* You may need to put /DLEX_SCANNER in your makefile + * if you're using LEX! + */ +#ifdef LEX_SCANNER +/* int yyoutput(int); */ +void yyoutput(int); +#else +void yyoutput(int); +#endif + +#if defined(__cplusplus) || defined(__STDC__) +#if defined(__cplusplus) && defined(__EXTERN_C__) +} +#endif +#endif +#line 36 "parser.y" +typedef union { + char *s; +/* struct pexpr *expr; */ +} YYSTYPE; +#line 44 "y_tab.c" +#define INTEGER 1 +#define WORD 2 +#define STRING 3 +#define PERIOD 13 +#define OPEN 4 +#define CLOSE 5 +#define COMMA 6 +#define NEWLINE 7 +#define ERROR 8 +#define OPEN_SQUARE 9 +#define CLOSE_SQUARE 10 +#define EQUALS 11 +#define EXP 14 +#define YYERRCODE 256 +short yylhs[] = { -1, + 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, + 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, +}; +short yylen[] = { 2, + 0, 2, 2, 2, 2, 4, 2, 3, 0, 1, + 3, 3, 1, 1, 1, 1, 3, 3, 5, 1, +}; +short yydefred[] = { 1, + 0, 0, 0, 0, 2, 0, 5, 3, 0, 0, + 0, 15, 7, 20, 0, 0, 13, 4, 0, 0, + 0, 0, 8, 0, 6, 0, 18, 0, 12, 11, + 0, 19, +}; +short yydgoto[] = { 1, + 5, 14, 15, 16, 17, +}; +short yysindex[] = { 0, + -2, 9, 2, 1, 0, 10, 0, 0, 11, -5, + 17, 0, 0, 0, 14, -1, 0, 0, 33, 38, + 41, 16, 0, 11, 0, 29, 0, 40, 0, 0, + 44, 0, +}; +short yyrindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 42, 21, + 24, 0, 0, 0, 0, 30, 0, 0, 0, 0, + 0, 0, 0, 31, 0, 27, 0, 24, 0, 0, + 0, 0, +}; +short yygindex[] = { 0, + 0, 45, -8, 0, 26, +}; +#define YYTABLESIZE 254 +short yytable[] = { 3, + 19, 10, 11, 12, 24, 9, 4, 20, 21, 4, + 13, 10, 11, 12, 8, 30, 10, 28, 12, 4, + 9, 7, 18, 23, 4, 16, 16, 22, 14, 14, + 16, 17, 17, 14, 10, 9, 17, 25, 26, 10, + 9, 27, 31, 9, 32, 6, 9, 29, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2, +}; +short yycheck[] = { 2, + 9, 1, 2, 3, 6, 4, 9, 13, 14, 9, + 10, 1, 2, 3, 13, 24, 1, 2, 3, 9, + 4, 13, 13, 10, 9, 5, 6, 11, 5, 6, + 10, 5, 6, 10, 5, 5, 10, 5, 1, 10, + 10, 1, 14, 4, 1, 1, 5, 22, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 256, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 14 +#if YYDEBUG +char *yyname[] = { +"end-of-file","INTEGER","WORD","STRING","OPEN","CLOSE","COMMA","NEWLINE", +"ERROR","OPEN_SQUARE","CLOSE_SQUARE","EQUALS",0,"PERIOD","EXP", +}; +char *yyrule[] = { +"$accept : commands", +"commands :", +"commands : commands command", +"command : WORD PERIOD", +"command : expr PERIOD", +"command : error PERIOD", +"expr : WORD OPEN arglist CLOSE", +"expr : OPEN_SQUARE CLOSE_SQUARE", +"expr : OPEN_SQUARE arglist CLOSE_SQUARE", +"arglist :", +"arglist : arg", +"arglist : arg COMMA arglist", +"arg : WORD EQUALS arg1", +"arg : arg1", +"arg1 : WORD", +"arg1 : STRING", +"arg1 : INTEGER", +"arg1 : INTEGER PERIOD INTEGER", +"arg1 : INTEGER EXP INTEGER", +"arg1 : INTEGER PERIOD INTEGER EXP INTEGER", +"arg1 : expr", +}; +#endif +#define yyclearin (yychar=(-1)) +#define yyerrok (yyerrflag=0) +#ifdef YYSTACKSIZE +#ifndef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#endif +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 600 +#define YYMAXDEPTH 600 +#endif +#endif +int yydebug; +int yynerrs; +int yyerrflag; +int yychar; +short *yyssp; +YYSTYPE *yyvsp; +YYSTYPE yyval; +YYSTYPE yylval; +short yyss[YYSTACKSIZE]; +YYSTYPE yyvs[YYSTACKSIZE]; +#define yystacksize YYSTACKSIZE +#line 118 "parser.y" + +#include "lex_yy.c" + +/* +void yyerror(s) +char *s; +{ + syntax_error(s); +} +*/ + +/* Ansi prototype. If this doesn't work for you... uncomment + the above instead. + */ + +void yyerror(char *s) +{ + syntax_error(s); +} + +/* + * Unfortunately, my DOS version of FLEX + * requires yywrap to be #def'ed, whereas + * the UNIX flex expects a proper function. + */ + +/* Not sure if __SC__ is the appropriate thing + * to test + */ + +#ifndef __SC__ +#ifdef USE_DEFINE +#ifndef yywrap +#define yywrap() 1 +#endif +#else +int yywrap() { return 1; } +#endif +#endif +#line 247 "y_tab.c" +#define YYABORT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +int +yyparse() +{ + register int yym, yyn, yystate; +#if YYDEBUG + register char *yys; + extern char *getenv(); + + if (yys = getenv("YYDEBUG")) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } +#endif + + yynerrs = 0; + yyerrflag = 0; + yychar = (-1); + + yyssp = yyss; + yyvsp = yyvs; + *yyssp = yystate = 0; + +yyloop: + if (yyn = yydefred[yystate]) goto yyreduce; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("yydebug: state %d, reading %d (%s)\n", yystate, + yychar, yys); + } +#endif + } + if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { +#if YYDEBUG + if (yydebug) + printf("yydebug: state %d, shifting to state %d\n", + yystate, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + yychar = (-1); + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; +#ifdef lint + goto yynewerror; +#endif +yynewerror: + yyerror("syntax error"); +#ifdef lint + goto yyerrlab; +#endif +yyerrlab: + ++yynerrs; +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("yydebug: state %d, error recovery shifting\ + to state %d\n", *yyssp, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("yydebug: error recovery discarding state %d\n", + *yyssp); +#endif + if (yyssp <= yyss) goto yyabort; + --yyssp; + --yyvsp; + } + } + } + else + { + if (yychar == 0) goto yyabort; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("yydebug: state %d, error recovery discards token %d (%s)\n", + yystate, yychar, yys); + } +#endif + yychar = (-1); + goto yyloop; + } +yyreduce: +#if YYDEBUG + if (yydebug) + printf("yydebug: state %d, reducing by rule %d (%s)\n", + yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + yyval = yyvsp[1-yym]; + switch (yyn) + { +case 3: +#line 68 "parser.y" +{process_command(cexpr_cons(make_word(yyvsp[-1].s), NULL)); free(yyvsp[-1].s);} +break; +case 4: +#line 70 "parser.y" +{process_command(yyvsp[-1].s);} +break; +case 5: +#line 72 "parser.y" +{syntax_error("Unrecognized command.");} +break; +case 6: +#line 76 "parser.y" +{yyval.s = cexpr_cons(make_word(yyvsp[-3].s), yyvsp[-1].s); free(yyvsp[-3].s);} +break; +case 7: +#line 78 "parser.y" +{yyval.s = cexpr_cons(NULL, NULL);} +break; +case 8: +#line 80 "parser.y" +{yyval.s = yyvsp[-1].s; } +break; +case 9: +#line 84 "parser.y" +{yyval.s = NULL;} +break; +case 10: +#line 86 "parser.y" +{yyval.s = cexpr_cons(yyvsp[0].s, NULL);} +break; +case 11: +#line 89 "parser.y" +{yyval.s = cexpr_cons(yyvsp[-2].s, yyvsp[0].s);} +break; +case 12: +#line 93 "parser.y" +{yyval.s = cexpr_cons(make_word("="), cexpr_cons(make_word(yyvsp[-2].s), cexpr_cons(yyvsp[0].s, NULL))); + free(yyvsp[-2].s); } +break; +case 13: +#line 96 "parser.y" +{yyval.s = yyvsp[0].s; } +break; +case 14: +#line 99 "parser.y" +{yyval.s = make_word(yyvsp[0].s); free(yyvsp[0].s);} +break; +case 15: +#line 101 "parser.y" +{yyval.s = make_string(yyvsp[0].s); free(yyvsp[0].s);} +break; +case 16: +#line 103 "parser.y" +{yyval.s = make_integer(yyvsp[0].s); free(yyvsp[0].s);} +break; +case 17: +#line 105 "parser.y" +{yyval.s = make_real(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); } +break; +case 18: +#line 107 "parser.y" +{yyval.s = make_exp(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); } +break; +case 19: +#line 110 "parser.y" +{yyval.s = make_exp2(yyvsp[-4].s, yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-4].s); free(yyvsp[-2].s); + free(yyvsp[0].s); } +break; +case 20: +#line 114 "parser.y" +{yyval.s = yyvsp[0].s;} +break; +#line 461 "y_tab.c" + } + yyssp -= yym; + yystate = *yyssp; + yyvsp -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("yydebug: after reduction, shifting from state 0 to\ + state %d\n", YYFINAL); +#endif + yystate = YYFINAL; + *++yyssp = YYFINAL; + *++yyvsp = yyval; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("yydebug: state %d, reading %d (%s)\n", + YYFINAL, yychar, yys); + } +#endif + } + if (yychar == 0) goto yyaccept; + goto yyloop; + } + if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("yydebug: after reduction, shifting from state %d \ +to state %d\n", *yyssp, yystate); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate; + *++yyvsp = yyval; + goto yyloop; +yyoverflow: + yyerror("yacc stack overflow"); +yyabort: + return (1); +yyaccept: + return (0); +} diff --git a/CExpr/Debug/empty.dir b/CExpr/Debug/empty.dir new file mode 100644 index 0000000..e69de29 diff --git a/CExpr/EXPR.H b/CExpr/EXPR.H new file mode 100644 index 0000000..aa1b2a7 --- /dev/null +++ b/CExpr/EXPR.H @@ -0,0 +1,124 @@ +/* + * File: expr.h + * Purpose: + * Author: Julian Smart + * Created: 1993 + * Updated: + * Copyright: (c) 1993 + */ + +/* sccsid[] = "%W% %G%" */ + +#ifndef __EXPRH__ +#define __EXPRH__ + +#include +#include + +/* Rename all YACC/LEX stuff or we'll conflict with other + * applications + */ + +#define yyback CExpr_yyback +#define yylook CExpr_yylook +#define yywrap CExpr_yywrap +#define yyoutput CExpr_yyoutput +#define yylex CExpr_yylex +#define yyerror CExpr_yyerror +#define input CExpr_input +#define unput CExpr_unput + +#define yyleng CExpr_yyleng +#define yytext CExpr_yytext +#define yymorfg CExpr_yymorfg +#define yylineno CExpr_yylineno +#define yytchar CExpr_yytchar +#define yyin CExpr_yyin +#define yyout CExpr_yyout +#define yysvf CExpr_yysvf +#define yyestate CExpr_yyestate +#define yysvec CExpr_yysvec +#define yybgin CExpr_yybgin +#define yyprevious CExpr_yyprevious +#define yylhs CExpr_yylhs +#define yylen CExpr_yylen +#define yydefred CExpr_yydefred +#define yydgoto CExpr_yydgoto +#define yysindex CExpr_yysindex +#define yyrindex CExpr_yyrindex +#define yygindex CExpr_yygindex +#define yytable CExpr_yytable +#define yycheck CExpr_yycheck +#define yyname CExpr_yyname +#define yyrule CExpr_yyrule +#define yydebug CExpr_yydebug +#define yynerrs CExpr_yynerrs +#define yyerrflag CExpr_yyerrflag +#define yychar CExpr_yychar +#define yyvsp CExpr_yyvsp +#define yyssp CExpr_yyssp +#define yyval CExpr_yyval +#define yylval CExpr_yylval +#define yyss CExpr_yyss +#define yyvs CExpr_yyvs +#define yyparse CExpr_yyparse + +/* +++steve162e: more defines necessary */ +#define yy_init_buffer CExpr_yy_init_buffer +#define yy_create_buffer CExpr_yy_create_buffer +#define yy_load_buffer_state CExpr_yy_load_buffer_state +#define yyrestart CExpr_yyrestart +#define yy_switch_to_buffer CExpr_yy_switch_to_buffer +#define yy_delete_buffer CExpr_yy_delete_buffer +/* ---steve162e */ + +/* WG 1/96: still more for flex 2.5 */ +#define yy_scan_buffer CExpr_scan_buffer +#define yy_scan_string CExpr_scan_string +#define yy_scan_bytes CExpr_scan_bytes +#define yy_flex_debug CExpr_flex_debug +#define yy_flush_buffer CExpr_flush_buffer +#define yyleng CExpr_yyleng +#define yytext CExpr_yytext + +#ifdef __cplusplus +extern "C" { +char *cexpr_cons(char *, char *); +char * make_integer(char *); +char * make_word(char *); +char * make_string(char *); +char * make_real(char *, char *); +char * make_exp(char *, char *); +char * make_exp2(char *, char *, char*); +void add_expr(char *); +void process_command(char *); +void syntax_error(char *); +} +#else +#if __BORLANDC__ +char *cexpr_cons(char *, char *); +char * make_integer(char *); +char * make_word(char *); +char * make_string(char *); +char * make_real(char *, char *); +char * make_exp(char *, char *); +char * make_exp2(char *, char *, char*); +void add_expr(char *); +void process_command(char *); +void syntax_error(char *); +#else +char *cexpr_cons(); +char * make_integer(); +char * make_word(); +char * make_string(); +char * make_real(); +char * make_exp(); +char * make_exp2(); + +void add_expr(); +void process_command(); +void syntax_error(); +#endif +#endif + +#endif diff --git a/CExpr/LEX_YY.C b/CExpr/LEX_YY.C new file mode 100644 index 0000000..7cb9405 --- /dev/null +++ b/CExpr/LEX_YY.C @@ -0,0 +1,1213 @@ +/* A lexical scanner generated by flex */ + +/* scanner skeleton version: + * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.16 90/08/03 14:09:36 vern Exp $ + */ + +#define FLEX_SCANNER + +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include +#include + +/* use prototypes in function declarations */ +#define YY_USE_PROTOS + +/* the "const" storage-class-modifier is valid */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#ifdef __STDC__ + +#ifdef __GNUC__ +#include +#else +#include +#endif /* __GNUC__ */ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + + +#ifdef __TURBOC__ +#define YY_USE_CONST +#endif + + +#ifndef YY_USE_CONST +#define const +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +/* we can't get here if it's an ANSI C compiler, or a C++ compiler, + * so it's got to be a K&R compiler, and therefore there's no standard + * place from which to include these definitions + */ +/* +char *malloc(); +int free(); +*/ + +int read(); +#endif + + +/* amount of stuff to slurp up with each read */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* returned upon end-of-file */ +#define YY_END_TOK 0 + +/* copy whatever the last rule matched to the standard output */ + +/* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */ +/* this used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite() + */ +#define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout ) + +/* gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#define YY_INPUT(buf,result,max_size) \ + if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "read() in flex scanner failed" ); +#define YY_NULL 0 + +/* no semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#define yyterminate() return ( YY_NULL ) + +/* report a fatal error */ + +/* The funky do-while is used to turn this macro definition into + * a single C statement (which needs a semi-colon terminator). + * This avoids problems with code like: + * + * if ( something_happens ) + * YY_FATAL_ERROR( "oops, the something happened" ); + * else + * everything_okay(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the YY_FATAL_ERROR() call. + */ + +#define YY_FATAL_ERROR(msg) \ + do \ + { \ + (void) fputs( msg, stderr ); \ + (void) putc( '\n', stderr ); \ + exit( 1 ); \ + } \ + while ( 0 ) + +/* default yywrap function - always treat EOF as an EOF */ +int yywrap(void) { return 1; } + + +/* enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN + */ +#define BEGIN yy_start = 1 + 2 * + +/* action number for EOF rule of a given start state */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* special action meaning "start processing a new file" */ +#define YY_NEW_FILE \ + do \ + { \ + yy_init_buffer( yy_current_buffer, yyin ); \ + yy_load_buffer_state(); \ + } \ + while ( 0 ) + +/* default declaration of generated scanner - a define so the user can + * easily add parameters + */ +#define YY_DECL int yylex YY_PROTO(( void )) + +/* code executed at the end of each rule */ +#define YY_BREAK break; + +#define YY_END_OF_BUFFER_CHAR 0 + +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */ +#endif + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +#define YY_CHAR unsigned char +# line 1 "lexer.l" +#define INITIAL 0 +# line 9 "lexer.l" +/* + * File: lexer.l + * Description: Lexical analyser for PROLOGIO; can be used with + * either lex and flex. + */ +#include + +/* +++steve162e: added, otherwise, CExpr_input will be undefined (at least under LINUX) + please check, if this is also TRUE under other UNIXes. + */ + +#if defined(FLEX_SCANNER) && defined(_LINUX) +#define CExpr_input my_input +#endif +/* ---steve162e */ + +#include "expr.h" +#ifdef wx_x +extern char *malloc(); +#endif +#define Return(x) return x; + +#if defined(VMS) && !defined(strdup) +#define strdup(s) (strcpy((char *)malloc(strlen(s)+1), s)); +#endif + +static size_t lex_buffer_length = 0; +static const char *lex_buffer = NULL; +static size_t lex_string_ptr = 0; +static int lex_read_from_string = 0; + +static int my_input(void); +static int my_unput(char); + +#ifdef FLEX_SCANNER +#undef YY_INPUT +# define YY_INPUT(buf,result,max_size) \ + if (lex_read_from_string) \ + { int c = my_input(); result = (c == 0) ? YY_NULL : ((buf)[0]=(c), 1); } \ + else \ + if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "read() in flex scanner failed" ); +#else +# undef unput +# define unput(_c) my_unput(_c) +#endif + +# line 58 "lexer.l" + +/* done after the current pattern has been matched and before the + * corresponding action - sets up yytext + */ +#define YY_DO_BEFORE_ACTION \ + yytext = yy_bp; \ + yyleng = yy_cp - yy_bp; \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* return all but the first 'n' matched characters back to the input stream */ +#define yyless(n) \ + do \ + { \ + /* undo effects of setting up yytext */ \ + *yy_cp = yy_hold_char; \ + yy_c_buf_p = yy_cp = yy_bp + n; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#undef unput +#define unput(c) yyunput( c, yytext ) + + +struct yy_buffer_state + { + FILE *yy_input_file; + + YY_CHAR *yy_ch_buf; /* input buffer */ + YY_CHAR *yy_buf_pos; /* current position in input buffer */ + + /* size of input buffer in bytes, not including room for EOB characters*/ + int yy_buf_size; + + /* number of characters read into yy_ch_buf, not including EOB characters */ + int yy_n_chars; + + int yy_eof_status; /* whether we've seen an EOF on this buffer */ +#define EOF_NOT_SEEN 0 + /* "pending" happens when the EOF has been seen but there's still + * some text process + */ +#define EOF_PENDING 1 +#define EOF_DONE 2 + }; + +static YY_BUFFER_STATE yy_current_buffer; + +/* we provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state" + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed */ +static YY_CHAR yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + + +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +#ifndef YY_USER_INIT +#define YY_USER_INIT +#endif + +extern YY_CHAR *yytext; +extern int yyleng; +extern FILE *yyin, *yyout; + +YY_CHAR *yytext; +int yyleng; + +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; + +#define YY_END_OF_BUFFER 18 +typedef int yy_state_type; +static const short int yy_accept[34] = + { 0, + 0, 0, 18, 16, 13, 14, 16, 16, 6, 7, + 16, 8, 12, 16, 1, 11, 3, 9, 10, 2, + 0, 5, 0, 0, 0, 4, 1, 15, 3, 5, + 0, 0, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 4, 1, 1, 1, 1, 5, 6, + 7, 8, 9, 10, 9, 11, 12, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 1, 1, 1, + 14, 1, 1, 1, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 16, 17, 18, 1, 15, 1, 15, 15, 15, 15, + + 19, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 1, 20, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static const YY_CHAR yy_meta[21] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 1, 2, 1, 3, 1, 2, 1 + } ; + +static const short int yy_base[37] = + { 0, + 0, 0, 48, 55, 55, 55, 17, 42, 55, 55, + 19, 55, 55, 23, 17, 55, 0, 55, 55, 0, + 18, 55, 19, 23, 21, 55, 12, 55, 0, 24, + 25, 29, 55, 49, 52, 22 + } ; + +static const short int yy_def[37] = + { 0, + 33, 1, 33, 33, 33, 33, 34, 35, 33, 33, + 33, 33, 33, 33, 33, 33, 36, 33, 33, 36, + 34, 33, 34, 34, 35, 33, 33, 33, 36, 34, + 34, 34, 0, 33, 33, 33 + } ; + +static const short int yy_nxt[76] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 4, 11, 12, + 13, 14, 15, 16, 17, 18, 4, 19, 20, 4, + 22, 22, 30, 29, 27, 26, 22, 22, 30, 27, + 28, 27, 30, 23, 23, 23, 24, 24, 24, 31, + 23, 32, 24, 24, 24, 23, 26, 33, 24, 21, + 21, 21, 25, 25, 3, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33 + } ; + +static const short int yy_chk[76] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 7, 21, 23, 36, 27, 25, 24, 30, 31, 15, + 14, 11, 32, 7, 21, 23, 7, 21, 23, 24, + 30, 31, 24, 30, 31, 32, 8, 3, 32, 34, + 34, 34, 35, 35, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33 + } ; + +static yy_state_type yy_last_accepting_state; +static YY_CHAR *yy_last_accepting_cpos; + +/* the intent behind this definition is that it'll catch + * any uses of REJECT which flex missed + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 + +/* these variables are all declared out here so that section 3 code can + * manipulate them + */ +/* points to current character in buffer */ +static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr )); +void yyrestart YY_PROTO(( FILE *input_file )); +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); + +#define yy_new_buffer yy_create_buffer + +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif + +YY_DECL + { + register yy_state_type yy_current_state; + register YY_CHAR *yy_cp, *yy_bp; + register int yy_act; + + + + + if ( yy_init ) + { + YY_USER_INIT; + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( yy_current_buffer ) + yy_init_buffer( yy_current_buffer, yyin ); + else + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + + yy_init = 0; + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* support of yytext */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of the + * current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[*yy_cp]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = yy_def[yy_current_state]; + if ( yy_current_state >= 34 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 33 ); + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + YY_USER_ACTION; + +do_action: /* this label is used only to access EOF actions */ + + + switch ( yy_act ) + { + case 0: /* must backtrack */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +# line 60 "lexer.l" +{yylval.s = strdup(yytext); Return(INTEGER);} + YY_BREAK +case 2: +# line 62 "lexer.l" +Return(EXP); + YY_BREAK +case 3: +# line 64 "lexer.l" +{yylval.s = strdup(yytext); Return(WORD);} + YY_BREAK +case 4: +# line 66 "lexer.l" +{int len = strlen(yytext); + yytext[len-1] = 0; + yylval.s = strdup(yytext+1); + Return(WORD);} + YY_BREAK +case 5: +# line 71 "lexer.l" +{yylval.s = strdup(yytext); Return(STRING);} + YY_BREAK +case 6: +# line 73 "lexer.l" +Return(OPEN); + YY_BREAK +case 7: +# line 75 "lexer.l" +Return(CLOSE); + YY_BREAK +case 8: +# line 77 "lexer.l" +Return(COMMA); + YY_BREAK +case 9: +# line 79 "lexer.l" +Return(OPEN_SQUARE); + YY_BREAK +case 10: +# line 81 "lexer.l" +Return(CLOSE_SQUARE); + YY_BREAK +case 11: +# line 83 "lexer.l" +Return(EQUALS); + YY_BREAK +case 12: +# line 85 "lexer.l" +Return(PERIOD); + YY_BREAK +case 13: +# line 87 "lexer.l" +; + YY_BREAK +case 14: +# line 89 "lexer.l" +; + YY_BREAK +case 15: +# line 91 "lexer.l" +{ loop: +#ifdef __cplusplus + while (yyinput() != '*'); + switch (yyinput()) +#else + while (input() != '*'); + switch (input()) +#endif + { + case '/': break; + case '*': unput('*'); + default: goto loop; + } + } + YY_BREAK +case 16: +# line 106 "lexer.l" +Return(ERROR); + YY_BREAK +case 17: +# line 108 "lexer.l" +ECHO; + YY_BREAK +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* amount of text matched not including the EOB char */ + int yy_amount_of_matched_text = yy_cp - yytext - 1; + + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + + /* note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the end- + * of-buffer state). Contrast this with the test in yyinput(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* this was really a NUL */ + { + yy_state_type yy_next_state; + + yy_c_buf_p = yytext + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* okay, we're now positioned to make the + * NUL transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we + * don't want to build jamming into it because + * then it will run more slowly) + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = yytext + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* consume the NUL */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* note: because we've taken care in + * yy_get_next_buffer() to have set up yytext, + * we can now set up yy_c_buf_p so that if some + * total hoser (like flex itself) wants + * to call the scanner after we return the + * YY_NULL, it'll still work - another YY_NULL + * will get returned. + */ + yy_c_buf_p = yytext + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF((yy_start - 1) / 2); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + } + break; + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: +#ifdef FLEX_DEBUG + printf( "action # %d\n", yy_act ); +#endif + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } + } + } + + +/* yy_get_next_buffer - try to read in a new buffer + * + * synopsis + * int yy_get_next_buffer(); + * + * returns a code representing an action + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ + +static int yy_get_next_buffer() + + { + register YY_CHAR *dest = yy_current_buffer->yy_ch_buf; + register YY_CHAR *source = yytext - 1; /* copy prev. char, too */ + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + /* try to read more data */ + + /* first move last chars to start of buffer */ + number_to_move = yy_c_buf_p - yytext; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_n_chars = 0; + + else + { + int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + else if ( num_to_read <= 0 ) + YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); + + /* read in more data */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == 1 ) + { + ret_val = EOB_ACT_END_OF_FILE; + yy_current_buffer->yy_eof_status = EOF_DONE; + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_eof_status = EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + /* yytext begins at the second character in yy_ch_buf; the first + * character is the one which preceded it before reading in the latest + * buffer; it needs to be kept around in case it's a newline, so + * yy_get_previous_state() will have with '^' rules active + */ + + yytext = &yy_current_buffer->yy_ch_buf[1]; + + return ( ret_val ); + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached + * + * synopsis + * yy_state_type yy_get_previous_state(); + */ + +static yy_state_type yy_get_previous_state() + + { + register yy_state_type yy_current_state; + register YY_CHAR *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = yy_def[yy_current_state]; + if ( yy_current_state >= 34 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return ( yy_current_state ); + } + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +register yy_state_type yy_current_state; +#endif + + { + register int yy_is_jam; + register YY_CHAR *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = yy_def[yy_current_state]; + if ( yy_current_state >= 34 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 33); + + return ( yy_is_jam ? 0 : yy_current_state ); + } + + +#ifdef YY_USE_PROTOS +static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp ) +#else +static void yyunput( c, yy_bp ) +YY_CHAR c; +register YY_CHAR *yy_bp; +#endif + + { + register YY_CHAR *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */ + register YY_CHAR *dest = + &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2]; + register YY_CHAR *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += dest - source; + yy_bp += dest - source; + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + if ( yy_cp > yy_bp && yy_cp[-1] == '\n' ) + yy_cp[-2] = '\n'; + + *--yy_cp = c; + + /* note: the formal parameter *must* be called "yy_bp" for this + * macro to now work correctly + */ + YY_DO_BEFORE_ACTION; /* set up yytext again */ + } + + +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + + { + int c; + YY_CHAR *yy_cp = yy_c_buf_p; + + *yy_cp = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* this was really a NUL */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + yytext = yy_c_buf_p; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + { + yy_c_buf_p = yytext + YY_MORE_ADJ; + return ( EOF ); + } + + YY_NEW_FILE; + +#ifdef __cplusplus + return ( yyinput() ); +#else + return ( input() ); +#endif + } + break; + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext + YY_MORE_ADJ; + break; + + case EOB_ACT_LAST_MATCH: +#ifdef __cplusplus + YY_FATAL_ERROR( "unexpected last match in yyinput()" ); +#else + YY_FATAL_ERROR( "unexpected last match in input()" ); +#endif + } + } + } + + c = *yy_c_buf_p; + yy_hold_char = *++yy_c_buf_p; + + return ( c ); + } + + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + + { + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* flush out information for old buffer */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* we don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) ); + + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) ); + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + yy_init_buffer( b, file ); + + return ( b ); + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + free( (char *) b->yy_ch_buf ); + free( (char *) b ); + } + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + { + b->yy_input_file = file; + + /* we put in the '\n' and start reading from [1] so that an + * initial match-at-newline will be true. + */ + + b->yy_ch_buf[0] = '\n'; + b->yy_n_chars = 1; + + /* we always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[1]; + + b->yy_eof_status = EOF_NOT_SEEN; + } +# line 108 "lexer.l" + + + +#ifdef FLEX_SCANNER +static int lex_input() { + return input(); +} +#else /* BSD/AT&T lex */ +#ifndef input +# error "Sorry, but need either flex or AT&T lex" +#endif +static int lex_input() { + return input(); +} +/* # undef unput +# define unput(_c) my_unput(_c) +*/ + +# undef input +# define input() my_input() +static int my_unput(char c) +{ + if (lex_read_from_string) { + /* Make sure we have something */ + if (lex_string_ptr) { + if (c == '\n') yylineno--; + lex_string_ptr--; + } + } else { + yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar; +/* unput(c); Causes infinite recursion! */ + } + return c; +} + +#endif + +/* Public */ +void LexFromFile(FILE *fd) +{ + lex_read_from_string = 0; + yyin = fd; + /* Don't know why this is necessary, but otherwise + * lex only works _once_! + */ +#ifdef FLEX_SCANNER + yy_init = 1; +#endif +} + +void LexFromString(char *buffer) +{ + lex_read_from_string = 1; + lex_buffer = buffer; + lex_buffer_length = strlen(buffer); + lex_string_ptr = 0; + /* Don't know why this is necessary, but otherwise + * lex only works _once_! + */ +#ifdef FLEX_SCANNER + yy_init = 1; +#endif +} + +static int my_input( void ) +{ + if (lex_read_from_string) { + if (lex_string_ptr == lex_buffer_length) + return 0; + else { + char c = lex_buffer[lex_string_ptr++]; +#ifndef FLEX_SCANNER + if (c == '\n') yylineno++; +#endif + return c; + } + } else { + return lex_input(); + } +} + +void CExprCleanUp() +{ + if (yy_current_buffer) + yy_delete_buffer(yy_current_buffer); +} diff --git a/CExpr/Lexer.l b/CExpr/Lexer.l new file mode 100644 index 0000000..8635661 --- /dev/null +++ b/CExpr/Lexer.l @@ -0,0 +1,193 @@ +SIGN [+-] +DIGIT [0-9] +ALPHA [a-zA-Z_] +ALPHADIGIT [a-zA-Z_0-9] +STRINGCHAR [^"\\] +WORDCHAR [^'\\] + +%{ +/* + * File: lexer.l + * Description: Lexical analyser for PROLOGIO; can be used with + * either lex and flex. + */ +#include + +/* +++steve162e: added, otherwise, CExpr_input will be undefined (at least under LINUX) + please check, if this is also TRUE under other UNIXes. + */ + +#if defined(FLEX_SCANNER) && defined(_LINUX) +#define CExpr_input my_input +#endif +/* ---steve162e */ + +#include "expr.h" +#ifdef wx_x +extern char *malloc(); +#endif +#define Return(x) return x; + +#if defined(VMS) && !defined(strdup) +#define strdup(s) (strcpy((char *)malloc(strlen(s)+1), s)); +#endif + +static size_t lex_buffer_length = 0; +static const char *lex_buffer = NULL; +static size_t lex_string_ptr = 0; +static int lex_read_from_string = 0; + +static int my_input(void); +static int my_unput(char); + +#ifdef FLEX_SCANNER +#undef YY_INPUT +# define YY_INPUT(buf,result,max_size) \ + if (lex_read_from_string) \ + { int c = my_input(); result = (c == 0) ? YY_NULL : ((buf)[0]=(c), 1); } \ + else \ + if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "read() in flex scanner failed" ); +#else +# undef unput +# define unput(_c) my_unput(_c) +#endif + +%} + +%% + +{SIGN}?{DIGIT}+ {yylval.s = strdup(yytext); Return(INTEGER);} + +"e" Return(EXP); + +{ALPHA}{ALPHADIGIT}* {yylval.s = strdup(yytext); Return(WORD);} + +"'"{WORDCHAR}*"'" {int len = strlen(yytext); + yytext[len-1] = 0; + yylval.s = strdup(yytext+1); + Return(WORD);} + +\"({STRINGCHAR}|\\\"|\|\\\\|\\)*\" {yylval.s = strdup(yytext); Return(STRING);} + +"(" Return(OPEN); + +")" Return(CLOSE); + +"," Return(COMMA); + +"[" Return(OPEN_SQUARE); + +"]" Return(CLOSE_SQUARE); + +"=" Return(EQUALS); + +"." Return(PERIOD); + +[ \t] ; + +\n ; + +"/*" { loop: +#ifdef __cplusplus + while (yyinput() != '*'); + switch (yyinput()) +#else + while (input() != '*'); + switch (input()) +#endif + { + case '/': break; + case '*': unput('*'); + default: goto loop; + } + } + +. Return(ERROR); + +%% + + +#ifdef FLEX_SCANNER +static int lex_input() { + return input(); +} +#else /* BSD/AT&T lex */ +#ifndef input +# error "Sorry, but need either flex or AT&T lex" +#endif +static int lex_input() { + return input(); +} +/* # undef unput +# define unput(_c) my_unput(_c) +*/ + +# undef input +# define input() my_input() +static int my_unput(char c) +{ + if (lex_read_from_string) { + /* Make sure we have something */ + if (lex_string_ptr) { + if (c == '\n') yylineno--; + lex_string_ptr--; + } + } else { + yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar; +/* unput(c); Causes infinite recursion! */ + } + return c; +} + +#endif + +/* Public */ +void LexFromFile(FILE *fd) +{ + lex_read_from_string = 0; + yyin = fd; + /* Don't know why this is necessary, but otherwise + * lex only works _once_! + */ +#ifdef FLEX_SCANNER + yy_init = 1; +#endif +} + +void LexFromString(char *buffer) +{ + lex_read_from_string = 1; + lex_buffer = buffer; + lex_buffer_length = strlen(buffer); + lex_string_ptr = 0; + /* Don't know why this is necessary, but otherwise + * lex only works _once_! + */ +#ifdef FLEX_SCANNER + yy_init = 1; +#endif +} + +static int my_input( void ) +{ + if (lex_read_from_string) { + if (lex_string_ptr == lex_buffer_length) + return 0; + else { + char c = lex_buffer[lex_string_ptr++]; +#ifndef FLEX_SCANNER + if (c == '\n') yylineno++; +#endif + return c; + } + } else { + return lex_input(); + } +} + +void CExprCleanUp() +{ + if (yy_current_buffer) + yy_delete_buffer(yy_current_buffer); +} diff --git a/CExpr/PARSER.Y b/CExpr/PARSER.Y new file mode 100644 index 0000000..7ede7ec --- /dev/null +++ b/CExpr/PARSER.Y @@ -0,0 +1,157 @@ + %{ +#include "string.h" +#include "expr.h" + +#ifndef __EXTERN_C__ +#define __EXTERN_C__ 1 +#endif + +#if defined(__cplusplus) || defined(__STDC__) +#if defined(__cplusplus) && defined(__EXTERN_C__) +extern "C" { +#endif +#endif +int yylex(void); +int yylook(void); +int yywrap(void); +int yyback(int *, int); +void yyerror(char *); + +/* You may need to put /DLEX_SCANNER in your makefile + * if you're using LEX! + */ +#ifdef LEX_SCANNER +/* int yyoutput(int); */ +void yyoutput(int); +#else +void yyoutput(int); +#endif + +#if defined(__cplusplus) || defined(__STDC__) +#if defined(__cplusplus) && defined(__EXTERN_C__) +} +#endif +#endif +%} + +%union { + char *s; +/* struct pexpr *expr; */ +} + + +%start commands + +%token INTEGER 1 +%token WORD 2 +%token STRING 3 +%token PERIOD 13 +%token OPEN 4 +%token CLOSE 5 +%token COMMA 6 +%token NEWLINE 7 +%token ERROR 8 +%token OPEN_SQUARE 9 +%token CLOSE_SQUARE 10 +%token EQUALS 11 +%token EXP 14 + +/* %type command expr arglist arg arg1 */ +%type command expr arglist arg arg1 + +%% + +commands : /* empty */ + | commands command + ; + +command : WORD PERIOD + {process_command(cexpr_cons(make_word($1), NULL)); free($1);} + | expr PERIOD + {process_command($1);} + | error PERIOD + {syntax_error("Unrecognized command.");} + ; + +expr : WORD OPEN arglist CLOSE + {$$ = cexpr_cons(make_word($1), $3); free($1);} + | OPEN_SQUARE CLOSE_SQUARE + {$$ = cexpr_cons(NULL, NULL);} + | OPEN_SQUARE arglist CLOSE_SQUARE + {$$ = $2; } + ; + +arglist : + {$$ = NULL;} + | arg + {$$ = cexpr_cons($1, NULL);} + | + arg COMMA arglist + {$$ = cexpr_cons($1, $3);} + ; + +arg : WORD EQUALS arg1 + {$$ = cexpr_cons(make_word("="), cexpr_cons(make_word($1), cexpr_cons($3, NULL))); + free($1); } + | arg1 + {$$ = $1; } + +arg1 : WORD + {$$ = make_word($1); free($1);} + | STRING + {$$ = make_string($1); free($1);} + | INTEGER + {$$ = make_integer($1); free($1);} + | INTEGER PERIOD INTEGER + {$$ = make_real($1, $3); free($1); free($3); } + | INTEGER EXP INTEGER + {$$ = make_exp($1, $3); free($1); free($3); } + | + INTEGER PERIOD INTEGER EXP INTEGER + {$$ = make_exp2($1, $3, $5); free($1); free($3); + free($5); } + + | expr + {$$ = $1;} + ; + +%% + +#include "lex_yy.c" + +/* +void yyerror(s) +char *s; +{ + syntax_error(s); +} +*/ + +/* Ansi prototype. If this doesn't work for you... uncomment + the above instead. + */ + +void yyerror(char *s) +{ + syntax_error(s); +} + +/* + * Unfortunately, my DOS version of FLEX + * requires yywrap to be #def'ed, whereas + * the UNIX flex expects a proper function. + */ + +/* Not sure if __SC__ is the appropriate thing + * to test + */ + +#ifndef __SC__ +#ifdef USE_DEFINE +#ifndef yywrap +#define yywrap() 1 +#endif +#else if !defined(__alpha) && !defined(__ultrix) +int yywrap() { return 1; } +#endif +#endif diff --git a/CExpr/Release/empty.dir b/CExpr/Release/empty.dir new file mode 100644 index 0000000..e69de29 diff --git a/CExpr/STDAFX.H b/CExpr/STDAFX.H new file mode 100644 index 0000000..8a137a0 --- /dev/null +++ b/CExpr/STDAFX.H @@ -0,0 +1,16 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include // MFC core and standard components +#include // MFC extensions +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows 95 Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + + + + diff --git a/CExpr/WX_HASH.CPP b/CExpr/WX_HASH.CPP new file mode 100644 index 0000000..723d70b --- /dev/null +++ b/CExpr/WX_HASH.CPP @@ -0,0 +1,350 @@ +/* + * File: wb_hash.cc + * Purpose: Hash table implementation + * Author: Julian Smart + * Created: 1993 + * Updated: August 1994 + * RCS_ID: $Id: wb_hash.cc,v 1.3 1994/08/14 21:34:01 edz Exp $ + * Copyright: (c) 1993, AIAI, University of Edinburgh + */ + +/* static const char sccsid[] = "@(#)wb_hash.cc 1.2 5/9/94"; */ + +#ifdef __GNUG__ +#pragma implementation "wx_hash.h" +#endif + +#include "stdafx.h" + +#include "wx_list.h" +#include "wx_hash.h" + +#include +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +IMPLEMENT_DYNAMIC(wxHashTable, CObject) + +wxHashTable::wxHashTable (int the_key_type, int size) +{ + n = size; + current_position = -1; + current_node = NULL; + + key_type = the_key_type; + hash_table = new wxList *[size]; + int i; + for (i = 0; i < size; i++) + hash_table[i] = NULL; +} + +wxHashTable::~wxHashTable (void) +{ + int i; + for (i = 0; i < n; i++) + if (hash_table[i]) + delete hash_table[i]; + delete[] hash_table; +} + +BOOL wxHashTable::Create(int the_key_type, int size) +{ + n = size; + current_position = -1; + current_node = NULL; + + key_type = the_key_type; + if (hash_table) + delete[] hash_table; + hash_table = new wxList *[size]; + int i; + for (i = 0; i < size; i++) + hash_table[i] = NULL; + return TRUE; +} + +void wxHashTable::Put (long key, long value, CObject * object) +{ + // Should NEVER be + if (key < 0) + key = -key; + + int position = (int) (key % n); + if (!hash_table[position]) + hash_table[position] = new wxList (wxKEY_INTEGER); + + hash_table[position]->Append (value, object); +} + +void wxHashTable::Put (long key, char *value, CObject * object) +{ + // Should NEVER be + if (key < 0) + key = -key; + + int position = (int) (key % n); + if (!hash_table[position]) + hash_table[position] = new wxList (wxKEY_INTEGER); + + hash_table[position]->Append (value, object); +} + +void wxHashTable::Put (long key, CObject * object) +{ + // Should NEVER be + if (key < 0) + key = -key; + + int position = (int) (key % n); + if (!hash_table[position]) + hash_table[position] = new wxList (wxKEY_INTEGER); + + hash_table[position]->Append (key, object); +} + +void wxHashTable::Put (const char *key, CObject * object) +{ + int position = (int) (MakeKey (key) % n); + + if (!hash_table[position]) + hash_table[position] = new wxList (wxKEY_STRING); + + hash_table[position]->Append (key, object); +} + +CObject *wxHashTable::Get (long key, long value) +{ + // Should NEVER be + if (key < 0) + key = -key; + + int position = (int) (key % n); + if (!hash_table[position]) + return NULL; + else + { + wxNode *node = hash_table[position]->Find (value); + if (node) + return node->Data (); + else + return NULL; + } +} + +CObject *wxHashTable::Get (long key, char *value) +{ + // Should NEVER be + if (key < 0) + key = -key; + + int position = (int) (key % n); + if (!hash_table[position]) + return NULL; + else + { + wxNode *node = hash_table[position]->Find (value); + if (node) + return node->Data (); + else + return NULL; + } +} + +CObject *wxHashTable::Get (long key) +{ + // Should NEVER be + if (key < 0) + key = -key; + + int position = (int) (key % n); + if (!hash_table[position]) + return NULL; + else + { + wxNode *node = hash_table[position]->Find (key); + return node ? node->Data () : NULL; + } +} + +CObject *wxHashTable::Get (const char *key) +{ + int position = (int) (MakeKey (key) % n); + + if (!hash_table[position]) + return NULL; + else + { + wxNode *node = hash_table[position]->Find (key); + return node ? node->Data () : NULL; + } +} + +CObject *wxHashTable::Delete (long key) +{ + // Should NEVER be + if (key < 0) + key = -key; + + int position = (int) (key % n); + if (!hash_table[position]) + return NULL; + else + { + wxNode *node = hash_table[position]->Find (key); + if (node) + { + CObject *data = node->Data (); + delete node; + return data; + } + else + return NULL; + } +} + +CObject *wxHashTable::Delete (const char *key) +{ + int position = (int) (MakeKey (key) % n); + if (!hash_table[position]) + return NULL; + else + { + wxNode *node = hash_table[position]->Find (key); + if (node) + { + CObject *data = node->Data (); + delete node; + return data; + } + else + return NULL; + } +} + +CObject *wxHashTable::Delete (long key, int value) +{ + // Should NEVER be + if (key < 0) + key = -key; + + int position = (int) (key % n); + if (!hash_table[position]) + return NULL; + else + { + wxNode *node = hash_table[position]->Find (value); + if (node) + { + CObject *data = node->Data (); + delete node; + return data; + } + else + return NULL; + } +} + +CObject *wxHashTable::Delete (long key, char *value) +{ +/* + // Should NEVER be + if (key < 0) + key = -key; +*/ + + int position = (int) (key % n); + if (!hash_table[position]) + return NULL; + else + { + wxNode *node = hash_table[position]->Find (value); + if (node) + { + CObject *data = node->Data (); + delete node; + return data; + } + else + return NULL; + } +} + +long wxHashTable::MakeKey (const char *string) +{ + long int_key = 0; + + while (*string) + int_key += (unsigned char) *string++; + +/* // Don't need this since int_key >= 0) + if (int_key < 0) + int_key = -int_key; +*/ + return int_key; +} + +void wxHashTable::BeginFind (void) +{ + current_position = -1; + current_node = NULL; +} + +wxNode *wxHashTable::Next (void) +{ + wxNode *found = NULL; + BOOL end = FALSE; + while (!end && !found) + { + if (!current_node) + { + current_position++; + if (current_position >= n) + { + current_position = -1; + current_node = NULL; + end = TRUE; + } + else + { + if (hash_table[current_position]) + { + current_node = hash_table[current_position]->First (); + found = current_node; + } + } + } + else + { + current_node = current_node->Next (); + found = current_node; + } + } + return found; +} + +void wxHashTable::DeleteContents (BOOL flag) +{ + int i; + for (i = 0; i < n; i++) + { + if (hash_table[i]) + hash_table[i]->DeleteContents (flag); + } +} + +void wxHashTable::Clear (void) +{ + int i; + for (i = 0; i < n; i++) + { + if (hash_table[i]) + hash_table[i]->Clear (); + } +} + + diff --git a/CExpr/WX_HASH.H b/CExpr/WX_HASH.H new file mode 100644 index 0000000..5925ea0 --- /dev/null +++ b/CExpr/WX_HASH.H @@ -0,0 +1,100 @@ +/* + * File: wx_hash.h + * Purpose: Basic hash table implementation + * Author: Julian Smart + * Created: 1993 + * Updated: + * Copyright: (c) 1993 + */ + +/* sccsid[] = "@(#)wx_hash.h 1.2 5/9/94" */ + +#ifndef wxb_hashh +#define wxb_hashh + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "wx_list.h" + +/* + * A hash table is an array of user-definable size with lists + * of data items hanging off the array positions. Usually there'll + * be a hit, so no search is required; otherwise we'll have to run down + * the list to find the desired item. +*/ + +#ifdef IN_CPROTO +typedef void *wxHashTable ; +#else + +class wxHashTable: public CObject +{ + DECLARE_DYNAMIC(wxHashTable) + + public: + int n; + int current_position; + wxNode *current_node; + + unsigned int key_type; + wxList **hash_table; + + wxHashTable(int the_key_type = wxKEY_INTEGER, int size = 1000); + ~wxHashTable(void); + + BOOL Create(int the_key_type = wxKEY_INTEGER, int size = 1000); + + // Note that there are 2 forms of Put, Get. + // With a key and a value, the *value* will be checked + // when a collision is detected. Otherwise, if there are + // 2 items with a different value but the same key, + // we'll retrieve the WRONG ONE. So where possible, + // supply the required value along with the key. + // In fact, the value-only versions make a key, and still store + // the value. The use of an explicit key might be required + // e.g. when combining several values into one key. + // When doing that, it's highly likely we'll get a collision, + // e.g. 1 + 2 = 3, 2 + 1 = 3. + + // key and value are NOT necessarily the same + void Put(long key, long value, CObject *object); + void Put(long key, char *value, CObject *object); + + // key and value are the same + void Put(long value, CObject *object); + void Put(const char *value, CObject *object); + + // key and value not the same + CObject *Get(long key, long value); + CObject *Get(long key, char *value); + + // key and value are the same + CObject *Get(long value); + CObject *Get(const char *value); + + // Deletes entry and returns data if found + CObject *Delete(long key); + CObject *Delete(const char *key); + + CObject *Delete(long key, int value); + CObject *Delete(long key, char *value); + + // Construct your own integer key from a string, e.g. in case + // you need to combine it with something + long MakeKey(const char *string); + + // Way of iterating through whole hash table (e.g. to delete everything) + // Not necessary, of course, if you're only storing pointers to + // objects maintained separately + + void BeginFind(void); + wxNode *Next(void); + + void DeleteContents(BOOL flag); + void Clear(void); +}; + +#endif // IN_CPROTO +#endif // wxb_hashh diff --git a/CExpr/Wx_list.cpp b/CExpr/Wx_list.cpp new file mode 100644 index 0000000..a5266ec --- /dev/null +++ b/CExpr/Wx_list.cpp @@ -0,0 +1,598 @@ +/* + * File: wb_list.cc + * Purpose: List implementation + * Author: Julian Smart + * Created: 1993 + * Updated: August 1994 + * RCS_ID: $Id: wb_list.cc,v 1.3 1994/08/14 21:34:01 edz Exp $ + * Copyright: (c) 1993, AIAI, University of Edinburgh + */ + +/* static const char sccsid[] = "@(#)wb_list.cc 1.2 5/9/94"; */ + +#ifdef __GNUG__ +#pragma implementation "wx_list.h" +#endif + +#include "stdafx.h" + +#include "wx_list.h" + +#include +#include + +IMPLEMENT_DYNAMIC(wxNode, CObject) +IMPLEMENT_DYNAMIC(wxList, CObject) +IMPLEMENT_DYNAMIC(wxStringList, wxList) + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +wxNode::wxNode (wxList * the_list, wxNode * last_one, wxNode * next_one, + CObject * object) +{ + data = object; + previous = last_one; + next = next_one; + list = the_list; + key.string = NULL; + + if (previous) + previous->next = this; + + if (next) + next->previous = this; +} + +// Keyed constructor +wxNode::wxNode (wxList * the_list, wxNode * last_one, wxNode * next_one, + CObject * object, long the_key) +{ + data = object; + previous = last_one; + next = next_one; + list = the_list; + key.integer = the_key; + + if (previous) + previous->next = this; + + if (next) + next->previous = this; +} + +wxNode::wxNode (wxList * the_list, wxNode * last_one, wxNode * next_one, + CObject * object, const char *the_key) +{ + data = object; + previous = last_one; + next = next_one; + list = the_list; + key.string = copystring (the_key); + + if (previous) + previous->next = this; + + if (next) + next->previous = this; +} + + +wxNode::~wxNode (void) +{ + if (list) + list->n--; + + if (list && list->destroy_data) + delete data; + + if (list && list->key_type == wxKEY_STRING && key.string) + delete[]key.string; + + // Make next node point back to the previous node from here + if (next) + next->previous = previous; + else if (list) + // If there's a new end of list (deleting the last one) + // make sure the list knows about it. + list->last_node = previous; + + // Make the previous node point to the next node from here + if (previous) + previous->next = next; + + // Or if no previous node (start of list), make sure list points at + // the next node which becomes the first!. + else if (list) + list->first_node = next; +} + +wxList::wxList (void) +{ + first_node = NULL; + last_node = NULL; + n = 0; + destroy_data = 0; + key_type = wxKEY_NONE; +} + +wxList::wxList (int N, CObject * Objects[]) +{ + wxNode *last = NULL; + + int i; + for (i = 0; i < N; i++) + { + wxNode *next = new wxNode (this, last, NULL, Objects[i]); + last = next; + if (i == 0) + first_node = next; + } + last_node = last; + n = N; + key_type = wxKEY_NONE; +} + +wxList::wxList (unsigned int the_key_type) +{ + n = 0; + destroy_data = 0; + first_node = NULL; + last_node = NULL; + key_type = the_key_type; +} + +// Variable argument list, terminated by a zero +wxList::wxList (CObject * first_one...) +{ +// #ifndef __sgi + + va_list ap; + + va_start (ap, first_one); + + wxNode *last = new wxNode (this, NULL, NULL, first_one); + first_node = last; + n = 1; + + for (;;) + { + CObject *object = va_arg (ap, CObject *); +// if (object == NULL) // Doesn't work in Windows -- segment is non-zero for NULL! +#ifdef wx_msw + if ((int) object == 0) +#else + if ((long) object == 0) +#endif + break; + else + { + wxNode *node = new wxNode (this, last, NULL, object); + last = node; + n++; + } + } + last_node = last; + va_end (ap); + + destroy_data = 0; + key_type = wxKEY_NONE; +/* +#else + fprintf (stderr, "Error: cannot use variable-argument functions on SGI!\n"); +#endif +*/ +} + +wxList::~wxList (void) +{ + wxNode *each = first_node; + while (each) + { + wxNode *next = each->Next (); + delete each; + each = next; + } +} + +wxNode *wxList::Nth (int i) +{ + int j = 0; + for (wxNode * current = First (); current; current = current->Next ()) + { + if (j++ == i) + return current; + } + return NULL; // No such element + +} + +wxNode *wxList::Find (long key) +{ + wxNode *current = First(); + while (current) + { + if (current->key.integer == key) + return current; + current = current->Next(); + } + + return NULL; // Not found! +} + +wxNode *wxList::Find (const char *key) +{ + wxNode *current = First(); + while (current) + { + if (!current->key.string) + { +// wxFatalError ("wxList: string key not present, probably did not Append correctly!"); + break; + } + if (strcmp (current->key.string, key) == 0) + return current; + current = current->Next(); + } + + return NULL; // Not found! + +} + +wxNode *wxList::Member (CObject * object) +{ + for (wxNode * current = First (); current; current = current->Next ()) + { + CObject *each = current->Data (); + if (each == object) + return current; + } + return NULL; +} + +BOOL wxList::DeleteNode (wxNode * node) +{ + if (node) + { + delete node; + return TRUE; + } + return FALSE; +} + +BOOL wxList::DeleteObject (CObject * object) +{ + // Search list for object + for (wxNode * current = first_node; current; current = current->Next ()) + { + if (current->Data () == object) + { + delete current; + return TRUE; + } + } + return FALSE; // Did not find the object + +} + + +// Insert new node at front of list +wxNode *wxList::Insert (CObject * object) +{ + wxNode *node = new wxNode (this, NULL, First (), object); + first_node = node; + + if (!(node->Next ())) + last_node = node; + + n++; + return node; +} + + +// Insert new node before given node. +wxNode *wxList::Insert (wxNode * position, CObject * object) +{ + wxNode *prev = NULL; + if (position) + prev = position->Previous (); + + wxNode *node = new wxNode (this, prev, position, object); + if (!first_node) + { + first_node = node; + last_node = node; + } + if (!prev) + first_node = node; + + n++; + return node; +} + +// Keyed append +wxNode *wxList::Append (long key, CObject * object) +{ + wxNode *node = new wxNode (this, last_node, NULL, object, key); + if (!first_node) + first_node = node; + last_node = node; + n++; + return node; +} + +wxNode *wxList::Append (const char *key, CObject * object) +{ + wxNode *node = new wxNode (this, last_node, NULL, object, key); + if (!first_node) + first_node = node; + last_node = node; + n++; + return node; +} + +void wxList::Clear (void) +{ + wxNode *current = first_node; + while (current) + { + wxNode *next = current->Next (); + delete current; + current = next; + } + first_node = NULL; + last_node = NULL; + n = 0; +} + +//Executes function F with all items present in the list +void wxList::ForEach(void (*F)(CObject *O)) +{ + wxNode *each = first_node; + while (each) + { (*F)( each->Data ()); + each = each->Next(); + } +} +// Returns a pointer to the item which returns TRUE with function F +// or NULL if no such item found +CObject *wxList::FirstThat(int (*F)(CObject *O)) +{ + wxNode *each = first_node; + while (each) + { if ((*F)( each->Data ())) return each->Data(); + each = each->Next(); + } + return NULL; +} +// Like FirstThat, but proceeds from the end backward +/* +CObject *wxList::LastThat(int (*F)(CObject *O)) +{ + wxNode *each = last_node; + while (each) + { if ((*F)( each->Data ())) return each->Data(); + each = each->Previous(); + } + return NULL; +} +*/ +// (stefan.hammes@urz.uni-heidelberg.de) +// +// function for sorting lists. the concept is borrowed from 'qsort'. +// by giving a sort function, arbitrary lists can be sorted. +// method: +// - put CObject pointers into an array +// - sort the array with qsort +// - put back the sorted CObject pointers into the list +// +// CAVE: the sort function receives pointers to CObject pointers (CObject **), +// so dereference right! +// EXAMPLE: +// int listcompare(const void *arg1, const void *arg2) +// { +// return(compare(**(wxString **)arg1, +// **(wxString **)arg2)); +// } +// +// void main() +// { +// wxList list; +// +// list.Append(new wxString("DEF")); +// list.Append(new wxString("GHI")); +// list.Append(new wxString("ABC")); +// list.Sort(listcompare); +// } + +void wxList::Sort(wxSortCompareFunction compfunc) +{ + // allocate an array for the CObject pointers of the list + const size_t num = Number(); + CObject **objArray = new CObject *[num]; + CObject **objPtr = objArray; + + // go through the list and put the pointers into the array + wxNode *node = First(); + while(node!=NULL){ + *objPtr++ = node->Data(); + node = node->Next(); + } + // sort the array + qsort((void *)objArray,num,sizeof(CObject *),compfunc); + // put the sorted pointers back into the list + objPtr = objArray; + node = First(); + while(node!=NULL){ + node->SetData(*objPtr++); + node = node->Next(); + } + // free the array + delete[] objArray; +} + +/* + * String list + * + */ + +wxStringList::wxStringList (void): +wxList () +{ +} + +// Variable argument list, terminated by a zero +// Makes new storage for the strings +wxStringList::wxStringList (char *first...) +{ +// #ifndef __sgi + + n = 0; + destroy_data = 0; + key_type = wxKEY_NONE; + first_node = NULL; + last_node = NULL; + + if (!first) + return; + + va_list ap; + + va_start (ap, first); + + wxNode *last = new wxNode (this, NULL, NULL, (CObject *) copystring (first)); + first_node = last; + n = 1; + + for (;;) + { + char *s = va_arg (ap, char *); +// if (s == NULL) +#ifdef wx_msw + if ((int) s == 0) +#else + if ((long) s == 0) +#endif + break; + else + { + wxNode *node = new wxNode (this, last, NULL, (CObject *) copystring (s)); + last = node; + n++; + } + } + last_node = last; + va_end (ap); +/* +#else + fprintf (stderr, "Error: cannot use variable-argument functions on SGI!\n"); +#endif +*/ +} + +wxStringList::~wxStringList (void) +{ + wxNode *each = first_node; + while (each) + { + char *s = (char *) each->Data (); + delete[]s; + wxNode *next = each->Next (); + delete each; + each = next; + } +} + +wxNode *wxStringList::Add (const char *s) +{ + return Append ((CObject *) (copystring (s))); +} + +void wxStringList::Delete (const char *s) +{ + for (wxNode * node = First (); node; node = node->Next ()) + { + char *string = (char *) node->Data (); + if (string == s || strcmp (string, s) == 0) + { + delete[]string; + delete node; + break; // Done! + + } + } // for + +} + +// Only makes new strings if arg is TRUE +char **wxStringList::ListToArray (BOOL new_copies) +{ + char **string_array = new char *[Number ()]; + wxNode *node = First (); + int i; + for (i = 0; i < n; i++) + { + char *s = (char *) node->Data (); + if (new_copies) + string_array[i] = copystring (s); + else + string_array[i] = s; + node = node->Next (); + } + return string_array; +} + +static int +wx_comparestrings (const void *arg1, const void *arg2) +{ + char **s1 = (char **) arg1; + char **s2 = (char **) arg2; + + return strcmp (*s1, *s2); +} + +// Sort a list of strings - deallocates old nodes, allocates new +void wxStringList::Sort (void) +{ + size_t N = n; + char **array = new char *[N]; + + size_t i = 0; + for (wxNode * node = First (); node; node = node->Next ()) + array[i++] = (char *) node->Data (); + + qsort (array, N, sizeof (char *), wx_comparestrings); + Clear (); + + for (i = 0; i < N; i++) + Append ((CObject *) (array[i])); + + delete[]array; +} + +// Checks whether s is a member of the list +BOOL wxStringList::Member (const char *s) +{ + for (wxNode * node = First (); node; node = node->Next ()) + { + const char *s1 = (const char *) node->Data (); + if (s == s1 || strcmp (s, s1) == 0) + return TRUE; + } + return FALSE; +} + +char * +copystring (const char *s) +{ + if (s == NULL) s = ""; + size_t len = strlen (s) + 1; + + char *news = new char[len]; + memcpy (news, s, len); // Should be the fastest + + return news; +} diff --git a/CExpr/Wx_list.h b/CExpr/Wx_list.h new file mode 100644 index 0000000..4affb0e --- /dev/null +++ b/CExpr/Wx_list.h @@ -0,0 +1,155 @@ +/* + * File: wx_list.h + * Purpose: wxList implementation much used in wxWindows + * Author: Julian Smart + * Created: 1993 + * Updated: + * Copyright: + */ + +/* sccsid[] = "@(#)wx_list.h 1.2 5/9/94" */ + +#ifndef wxb_listh +#define wxb_listh + +#ifdef __GNUG__ +#pragma interface +#endif + +#ifdef IN_CPROTO +typedef void *wxList ; +typedef void *wxNode; +typedef void *wxStringList; +#else + +class wxList; + +#define wxKEY_NONE 0 +#define wxKEY_INTEGER 1 +#define wxKEY_STRING 2 +class wxNode: public CObject +{ + DECLARE_DYNAMIC(wxNode) + private: + + CObject *data; + wxNode *next; + wxNode *previous; + + public: + wxList *list; + + // Optional key stuff + union + { + long integer; + char *string; + } key; + + wxNode(wxList *the_list = NULL, wxNode *last_one = NULL, wxNode *next_one = NULL, CObject *object = NULL); + wxNode(wxList *the_list, wxNode *last_one, wxNode *next_one, + CObject *object, long the_key); + wxNode(wxList *the_list, wxNode *last_one, wxNode *next_one, + CObject *object, const char *the_key); + ~wxNode(void); + + inline wxNode *Next(void) { return next; } + inline wxNode *Previous(void) { return previous; } + inline CObject *Data(void) { return data; } + inline void SetData(CObject *the_data) { data = the_data; } +}; + +// type of compare function for list sort operation (as in 'qsort') +typedef int (*wxSortCompareFunction)(const void *elem1, const void *elem2); + +class wxList: public CObject +{ + DECLARE_DYNAMIC(wxList) + + public: + int n; + int destroy_data; + wxNode *first_node; + wxNode *last_node; + unsigned int key_type; + + wxList(void); + wxList(unsigned int the_key_type); + wxList(int N, CObject *Objects[]); + wxList(CObject *object, ...); + ~wxList(void); + + inline int Number(void) { return n; } + + // Append to end of list + inline wxNode *Append(CObject *object) + { + wxNode *node = new wxNode(this, last_node, NULL, object); + if (!first_node) + first_node = node; + last_node = node; + n ++; + return node; + } + + // Insert at front of list + wxNode *Insert(CObject *object); + + // Insert before given node + wxNode *Insert(wxNode *position, CObject *object); + + // Keyed append + wxNode *Append(long key, CObject *object); + wxNode *Append(const char *key, CObject *object); + + BOOL DeleteNode(wxNode *node); + BOOL DeleteObject(CObject *object); // Finds object pointer and + // deletes node (and object if + // DeleteContents is on) + void Clear(void); // Delete all nodes + + inline wxNode *First(void) { return first_node; } + inline wxNode *Last(void) { return last_node; } + wxNode *Nth(int i); // nth node counting from 0 + + // Keyed search + wxNode *Find(long key); + wxNode *Find(const char *key); + + wxNode *Member(CObject *object); + + inline void DeleteContents(int destroy) { destroy_data = destroy; } + // Instruct it to destroy user data + // when deleting nodes + // this function allows the sorting of arbitrary lists by giving + // a function to compare two list elements. + void Sort(wxSortCompareFunction compfunc); + + CObject *FirstThat(int (*F)(CObject *O)); + void ForEach(void (*F)(CObject *O)); + //CObject *LastThat(int (*F)(CObject *O)); +}; + +// String list class. N.B. this always copies strings +// with Add and deletes them itself. +class wxStringList: public wxList +{ + DECLARE_DYNAMIC(wxStringList) + + public: + wxStringList(void); + wxStringList(char *first ...); + ~wxStringList(void); + + virtual wxNode *Add(const char *s); + virtual void Delete(const char *s); + virtual char **ListToArray(BOOL new_copies = FALSE); + virtual void Sort(void); + virtual BOOL Member(const char *s); +}; + +// Make a copy of this string using 'new' +extern char *copystring(const char *s); + +#endif // IN_CPROTO +#endif // wxb_listh diff --git a/CExpr/Y_TAB.C b/CExpr/Y_TAB.C new file mode 100644 index 0000000..03f7726 --- /dev/null +++ b/CExpr/Y_TAB.C @@ -0,0 +1,516 @@ +#ifndef lint +static char yysccsid[] = "@(#)yaccpar 1.7 (Berkeley) 09/09/90"; +#endif +#define YYBYACC 1 +#line 2 "parser.y" +#include "string.h" +#include "expr.h" + +#ifndef __EXTERN_C__ +#define __EXTERN_C__ 1 +#endif + +#if defined(__cplusplus) || defined(__STDC__) +#if defined(__cplusplus) && defined(__EXTERN_C__) +extern "C" { +#endif +#endif +int yylex(void); +int yylook(void); +int yywrap(void); +int yyback(int *, int); + +/* You may need to put /DLEX_SCANNER in your makefile + * if you're using LEX! + */ +#ifdef LEX_SCANNER +/* int yyoutput(int); */ +void yyoutput(int); +#else +void yyoutput(int); +#endif + +#if defined(__cplusplus) || defined(__STDC__) +#if defined(__cplusplus) && defined(__EXTERN_C__) +} +#endif +#endif +#line 36 "parser.y" +typedef union { + char *s; +/* struct pexpr *expr; */ +} YYSTYPE; +#line 44 "y_tab.c" +#define INTEGER 1 +#define WORD 2 +#define STRING 3 +#define PERIOD 13 +#define OPEN 4 +#define CLOSE 5 +#define COMMA 6 +#define NEWLINE 7 +#define ERROR 8 +#define OPEN_SQUARE 9 +#define CLOSE_SQUARE 10 +#define EQUALS 11 +#define EXP 14 +#define YYERRCODE 256 +short yylhs[] = { -1, + 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, + 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, +}; +short yylen[] = { 2, + 0, 2, 2, 2, 2, 4, 2, 3, 0, 1, + 3, 3, 1, 1, 1, 1, 3, 3, 5, 1, +}; +short yydefred[] = { 1, + 0, 0, 0, 0, 2, 0, 5, 3, 0, 0, + 0, 15, 7, 20, 0, 0, 13, 4, 0, 0, + 0, 0, 8, 0, 6, 0, 18, 0, 12, 11, + 0, 19, +}; +short yydgoto[] = { 1, + 5, 14, 15, 16, 17, +}; +short yysindex[] = { 0, + -2, 9, 2, 1, 0, 10, 0, 0, 11, -5, + 17, 0, 0, 0, 14, -1, 0, 0, 33, 38, + 41, 16, 0, 11, 0, 29, 0, 40, 0, 0, + 44, 0, +}; +short yyrindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 42, 21, + 24, 0, 0, 0, 0, 30, 0, 0, 0, 0, + 0, 0, 0, 31, 0, 27, 0, 24, 0, 0, + 0, 0, +}; +short yygindex[] = { 0, + 0, 45, -8, 0, 26, +}; +#define YYTABLESIZE 254 +short yytable[] = { 3, + 19, 10, 11, 12, 24, 9, 4, 20, 21, 4, + 13, 10, 11, 12, 8, 30, 10, 28, 12, 4, + 9, 7, 18, 23, 4, 16, 16, 22, 14, 14, + 16, 17, 17, 14, 10, 9, 17, 25, 26, 10, + 9, 27, 31, 9, 32, 6, 9, 29, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2, +}; +short yycheck[] = { 2, + 9, 1, 2, 3, 6, 4, 9, 13, 14, 9, + 10, 1, 2, 3, 13, 24, 1, 2, 3, 9, + 4, 13, 13, 10, 9, 5, 6, 11, 5, 6, + 10, 5, 6, 10, 5, 5, 10, 5, 1, 10, + 10, 1, 14, 4, 1, 1, 5, 22, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 256, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 14 +#if YYDEBUG +char *yyname[] = { +"end-of-file","INTEGER","WORD","STRING","OPEN","CLOSE","COMMA","NEWLINE", +"ERROR","OPEN_SQUARE","CLOSE_SQUARE","EQUALS",0,"PERIOD","EXP", +}; +char *yyrule[] = { +"$accept : commands", +"commands :", +"commands : commands command", +"command : WORD PERIOD", +"command : expr PERIOD", +"command : error PERIOD", +"expr : WORD OPEN arglist CLOSE", +"expr : OPEN_SQUARE CLOSE_SQUARE", +"expr : OPEN_SQUARE arglist CLOSE_SQUARE", +"arglist :", +"arglist : arg", +"arglist : arg COMMA arglist", +"arg : WORD EQUALS arg1", +"arg : arg1", +"arg1 : WORD", +"arg1 : STRING", +"arg1 : INTEGER", +"arg1 : INTEGER PERIOD INTEGER", +"arg1 : INTEGER EXP INTEGER", +"arg1 : INTEGER PERIOD INTEGER EXP INTEGER", +"arg1 : expr", +}; +#endif +#define yyclearin (yychar=(-1)) +#define yyerrok (yyerrflag=0) +#ifdef YYSTACKSIZE +#ifndef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#endif +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 600 +#define YYMAXDEPTH 600 +#endif +#endif +int yydebug; +int yynerrs; +int yyerrflag; +int yychar; +short *yyssp; +YYSTYPE *yyvsp; +YYSTYPE yyval; +YYSTYPE yylval; +short yyss[YYSTACKSIZE]; +YYSTYPE yyvs[YYSTACKSIZE]; +#define yystacksize YYSTACKSIZE +#line 118 "parser.y" + +#include "lex_yy.c" + +/* +void yyerror(s) +char *s; +{ + syntax_error(s); +} +*/ + +/* Ansi prototype. If this doesn't work for you... uncomment + the above instead. + */ + +void yyerror(char *s) +{ + syntax_error(s); +} + +/* + * Unfortunately, my DOS version of FLEX + * requires yywrap to be #def'ed, whereas + * the UNIX flex expects a proper function. + */ + +/* Not sure if __SC__ is the appropriate thing + * to test + */ + +#ifndef __SC__ +#ifdef USE_DEFINE +#ifndef yywrap +#define yywrap() 1 +#endif +#else +int yywrap() { return 1; } +#endif +#endif +#line 247 "y_tab.c" +#define YYABORT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +int +yyparse() +{ + register int yym, yyn, yystate; +#if YYDEBUG + register char *yys; + extern char *getenv(); + + if (yys = getenv("YYDEBUG")) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } +#endif + + yynerrs = 0; + yyerrflag = 0; + yychar = (-1); + + yyssp = yyss; + yyvsp = yyvs; + *yyssp = yystate = 0; + +yyloop: + if (yyn = yydefred[yystate]) goto yyreduce; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("yydebug: state %d, reading %d (%s)\n", yystate, + yychar, yys); + } +#endif + } + if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { +#if YYDEBUG + if (yydebug) + printf("yydebug: state %d, shifting to state %d\n", + yystate, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + yychar = (-1); + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; +#ifdef lint + goto yynewerror; +#endif +yynewerror: + yyerror("syntax error"); +#ifdef lint + goto yyerrlab; +#endif +yyerrlab: + ++yynerrs; +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("yydebug: state %d, error recovery shifting\ + to state %d\n", *yyssp, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("yydebug: error recovery discarding state %d\n", + *yyssp); +#endif + if (yyssp <= yyss) goto yyabort; + --yyssp; + --yyvsp; + } + } + } + else + { + if (yychar == 0) goto yyabort; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("yydebug: state %d, error recovery discards token %d (%s)\n", + yystate, yychar, yys); + } +#endif + yychar = (-1); + goto yyloop; + } +yyreduce: +#if YYDEBUG + if (yydebug) + printf("yydebug: state %d, reducing by rule %d (%s)\n", + yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + yyval = yyvsp[1-yym]; + switch (yyn) + { +case 3: +#line 68 "parser.y" +{process_command(cexpr_cons(make_word(yyvsp[-1].s), NULL)); free(yyvsp[-1].s);} +break; +case 4: +#line 70 "parser.y" +{process_command(yyvsp[-1].s);} +break; +case 5: +#line 72 "parser.y" +{syntax_error("Unrecognized command.");} +break; +case 6: +#line 76 "parser.y" +{yyval.s = cexpr_cons(make_word(yyvsp[-3].s), yyvsp[-1].s); free(yyvsp[-3].s);} +break; +case 7: +#line 78 "parser.y" +{yyval.s = cexpr_cons(NULL, NULL);} +break; +case 8: +#line 80 "parser.y" +{yyval.s = yyvsp[-1].s; } +break; +case 9: +#line 84 "parser.y" +{yyval.s = NULL;} +break; +case 10: +#line 86 "parser.y" +{yyval.s = cexpr_cons(yyvsp[0].s, NULL);} +break; +case 11: +#line 89 "parser.y" +{yyval.s = cexpr_cons(yyvsp[-2].s, yyvsp[0].s);} +break; +case 12: +#line 93 "parser.y" +{yyval.s = cexpr_cons(make_word("="), cexpr_cons(make_word(yyvsp[-2].s), cexpr_cons(yyvsp[0].s, NULL))); + free(yyvsp[-2].s); } +break; +case 13: +#line 96 "parser.y" +{yyval.s = yyvsp[0].s; } +break; +case 14: +#line 99 "parser.y" +{yyval.s = make_word(yyvsp[0].s); free(yyvsp[0].s);} +break; +case 15: +#line 101 "parser.y" +{yyval.s = make_string(yyvsp[0].s); free(yyvsp[0].s);} +break; +case 16: +#line 103 "parser.y" +{yyval.s = make_integer(yyvsp[0].s); free(yyvsp[0].s);} +break; +case 17: +#line 105 "parser.y" +{yyval.s = make_real(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); } +break; +case 18: +#line 107 "parser.y" +{yyval.s = make_exp(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); } +break; +case 19: +#line 110 "parser.y" +{yyval.s = make_exp2(yyvsp[-4].s, yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-4].s); free(yyvsp[-2].s); + free(yyvsp[0].s); } +break; +case 20: +#line 114 "parser.y" +{yyval.s = yyvsp[0].s;} +break; +#line 461 "y_tab.c" + } + yyssp -= yym; + yystate = *yyssp; + yyvsp -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("yydebug: after reduction, shifting from state 0 to\ + state %d\n", YYFINAL); +#endif + yystate = YYFINAL; + *++yyssp = YYFINAL; + *++yyvsp = yyval; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("yydebug: state %d, reading %d (%s)\n", + YYFINAL, yychar, yys); + } +#endif + } + if (yychar == 0) goto yyaccept; + goto yyloop; + } + if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("yydebug: after reduction, shifting from state %d \ +to state %d\n", *yyssp, yystate); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate; + *++yyvsp = yyval; + goto yyloop; +yyoverflow: + yyerror("yacc stack overflow"); +yyabort: + return (1); +yyaccept: + return (0); +} diff --git a/CExpr/old/DOSLEX.C b/CExpr/old/DOSLEX.C new file mode 100644 index 0000000..60a57fd --- /dev/null +++ b/CExpr/old/DOSLEX.C @@ -0,0 +1,1208 @@ +/* A lexical scanner generated by flex */ + +/* scanner skeleton version: + * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.16 90/08/03 14:09:36 vern Exp $ + */ + +#define FLEX_SCANNER + +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include +#include + +/* use prototypes in function declarations */ +#define YY_USE_PROTOS + +/* the "const" storage-class-modifier is valid */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#ifdef __STDC__ + +#ifdef __GNUC__ +#include +#else +#include +#endif /* __GNUC__ */ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + + +#ifdef __TURBOC__ +#define YY_USE_CONST +#endif + + +#ifndef YY_USE_CONST +#define const +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +/* we can't get here if it's an ANSI C compiler, or a C++ compiler, + * so it's got to be a K&R compiler, and therefore there's no standard + * place from which to include these definitions + */ +/* +char *malloc(); +int free(); +*/ + +int read(); +#endif + + +/* amount of stuff to slurp up with each read */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* returned upon end-of-file */ +#define YY_END_TOK 0 + +/* copy whatever the last rule matched to the standard output */ + +/* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */ +/* this used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite() + */ +#define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout ) + +/* gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#define YY_INPUT(buf,result,max_size) \ + if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "read() in flex scanner failed" ); +#define YY_NULL 0 + +/* no semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#define yyterminate() return ( YY_NULL ) + +/* report a fatal error */ + +/* The funky do-while is used to turn this macro definition into + * a single C statement (which needs a semi-colon terminator). + * This avoids problems with code like: + * + * if ( something_happens ) + * YY_FATAL_ERROR( "oops, the something happened" ); + * else + * everything_okay(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the YY_FATAL_ERROR() call. + */ + +#define YY_FATAL_ERROR(msg) \ + do \ + { \ + (void) fputs( msg, stderr ); \ + (void) putc( '\n', stderr ); \ + exit( 1 ); \ + } \ + while ( 0 ) + +/* default yywrap function - always treat EOF as an EOF */ +int yywrap(void) { return 1; } + + +/* enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN + */ +#define BEGIN yy_start = 1 + 2 * + +/* action number for EOF rule of a given start state */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* special action meaning "start processing a new file" */ +#define YY_NEW_FILE \ + do \ + { \ + yy_init_buffer( yy_current_buffer, yyin ); \ + yy_load_buffer_state(); \ + } \ + while ( 0 ) + +/* default declaration of generated scanner - a define so the user can + * easily add parameters + */ +#define YY_DECL int yylex YY_PROTO(( void )) + +/* code executed at the end of each rule */ +#define YY_BREAK break; + +#define YY_END_OF_BUFFER_CHAR 0 + +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */ +#endif + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +#define YY_CHAR unsigned char +# line 1 "lexer.l" +#define INITIAL 0 +# line 9 "lexer.l" +/* + * File: lexer.l + * Description: Lexical analyser for PROLOGIO; can be used with + * either lex and flex. + */ +#include + +/* +++steve162e: added, otherwise, CExpr_input will be undefined (at least under LINUX) + please check, if this is also TRUE under other UNIXes. + */ + +#if defined(FLEX_SCANNER) && defined(_LINUX) +#define CExpr_input my_input +#endif +/* ---steve162e */ + +#include "expr.h" +#ifdef wx_x +extern char *malloc(); +#endif +#define Return(x) return x; + +#if defined(VMS) && !defined(strdup) +#define strdup(s) (strcpy((char *)malloc(strlen(s)+1), s)); +#endif + +static size_t lex_buffer_length = 0; +static const char *lex_buffer = NULL; +static size_t lex_string_ptr = 0; +static int lex_read_from_string = 0; + +static int my_input(void); +static int my_unput(char); + +#ifdef FLEX_SCANNER +#undef YY_INPUT +# define YY_INPUT(buf,result,max_size) \ + if (lex_read_from_string) \ + { int c = my_input(); result = (c == 0) ? YY_NULL : ((buf)[0]=(c), 1); } \ + else \ + if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "read() in flex scanner failed" ); +#else +# undef unput +# define unput(_c) my_unput(_c) +#endif + +# line 58 "lexer.l" + +/* done after the current pattern has been matched and before the + * corresponding action - sets up yytext + */ +#define YY_DO_BEFORE_ACTION \ + yytext = yy_bp; \ + yyleng = yy_cp - yy_bp; \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* return all but the first 'n' matched characters back to the input stream */ +#define yyless(n) \ + do \ + { \ + /* undo effects of setting up yytext */ \ + *yy_cp = yy_hold_char; \ + yy_c_buf_p = yy_cp = yy_bp + n; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#undef unput +#define unput(c) yyunput( c, yytext ) + + +struct yy_buffer_state + { + FILE *yy_input_file; + + YY_CHAR *yy_ch_buf; /* input buffer */ + YY_CHAR *yy_buf_pos; /* current position in input buffer */ + + /* size of input buffer in bytes, not including room for EOB characters*/ + int yy_buf_size; + + /* number of characters read into yy_ch_buf, not including EOB characters */ + int yy_n_chars; + + int yy_eof_status; /* whether we've seen an EOF on this buffer */ +#define EOF_NOT_SEEN 0 + /* "pending" happens when the EOF has been seen but there's still + * some text process + */ +#define EOF_PENDING 1 +#define EOF_DONE 2 + }; + +static YY_BUFFER_STATE yy_current_buffer; + +/* we provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state" + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed */ +static YY_CHAR yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + + +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +#ifndef YY_USER_INIT +#define YY_USER_INIT +#endif + +extern YY_CHAR *yytext; +extern int yyleng; +extern FILE *yyin, *yyout; + +YY_CHAR *yytext; +int yyleng; + +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; + +#define YY_END_OF_BUFFER 18 +typedef int yy_state_type; +static const short int yy_accept[34] = + { 0, + 0, 0, 18, 16, 13, 14, 16, 16, 6, 7, + 16, 8, 12, 16, 1, 11, 3, 9, 10, 2, + 0, 5, 0, 0, 0, 4, 1, 15, 3, 5, + 0, 0, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 4, 1, 1, 1, 1, 5, 6, + 7, 8, 9, 10, 9, 11, 12, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 1, 1, 1, + 14, 1, 1, 1, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 16, 17, 18, 1, 15, 1, 15, 15, 15, 15, + + 19, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 1, 20, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static const YY_CHAR yy_meta[21] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 1, 2, 1, 3, 1, 2, 1 + } ; + +static const short int yy_base[37] = + { 0, + 0, 0, 48, 55, 55, 55, 17, 42, 55, 55, + 19, 55, 55, 23, 17, 55, 0, 55, 55, 0, + 18, 55, 19, 23, 21, 55, 12, 55, 0, 24, + 25, 29, 55, 49, 52, 22 + } ; + +static const short int yy_def[37] = + { 0, + 33, 1, 33, 33, 33, 33, 34, 35, 33, 33, + 33, 33, 33, 33, 33, 33, 36, 33, 33, 36, + 34, 33, 34, 34, 35, 33, 33, 33, 36, 34, + 34, 34, 0, 33, 33, 33 + } ; + +static const short int yy_nxt[76] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 4, 11, 12, + 13, 14, 15, 16, 17, 18, 4, 19, 20, 4, + 22, 22, 30, 29, 27, 26, 22, 22, 30, 27, + 28, 27, 30, 23, 23, 23, 24, 24, 24, 31, + 23, 32, 24, 24, 24, 23, 26, 33, 24, 21, + 21, 21, 25, 25, 3, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33 + } ; + +static const short int yy_chk[76] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 7, 21, 23, 36, 27, 25, 24, 30, 31, 15, + 14, 11, 32, 7, 21, 23, 7, 21, 23, 24, + 30, 31, 24, 30, 31, 32, 8, 3, 32, 34, + 34, 34, 35, 35, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33 + } ; + +static yy_state_type yy_last_accepting_state; +static YY_CHAR *yy_last_accepting_cpos; + +/* the intent behind this definition is that it'll catch + * any uses of REJECT which flex missed + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 + +/* these variables are all declared out here so that section 3 code can + * manipulate them + */ +/* points to current character in buffer */ +static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr )); +void yyrestart YY_PROTO(( FILE *input_file )); +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); + +#define yy_new_buffer yy_create_buffer + +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif + +YY_DECL + { + register yy_state_type yy_current_state; + register YY_CHAR *yy_cp, *yy_bp; + register int yy_act; + + + + + if ( yy_init ) + { + YY_USER_INIT; + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( yy_current_buffer ) + yy_init_buffer( yy_current_buffer, yyin ); + else + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + + yy_init = 0; + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* support of yytext */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of the + * current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[*yy_cp]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = yy_def[yy_current_state]; + if ( yy_current_state >= 34 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 33 ); + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + YY_USER_ACTION; + +do_action: /* this label is used only to access EOF actions */ + + + switch ( yy_act ) + { + case 0: /* must backtrack */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +# line 60 "lexer.l" +{yylval.s = strdup(yytext); Return(INTEGER);} + YY_BREAK +case 2: +# line 62 "lexer.l" +Return(EXP); + YY_BREAK +case 3: +# line 64 "lexer.l" +{yylval.s = strdup(yytext); Return(WORD);} + YY_BREAK +case 4: +# line 66 "lexer.l" +{int len = strlen(yytext); + yytext[len-1] = 0; + yylval.s = strdup(yytext+1); + Return(WORD);} + YY_BREAK +case 5: +# line 71 "lexer.l" +{yylval.s = strdup(yytext); Return(STRING);} + YY_BREAK +case 6: +# line 73 "lexer.l" +Return(OPEN); + YY_BREAK +case 7: +# line 75 "lexer.l" +Return(CLOSE); + YY_BREAK +case 8: +# line 77 "lexer.l" +Return(COMMA); + YY_BREAK +case 9: +# line 79 "lexer.l" +Return(OPEN_SQUARE); + YY_BREAK +case 10: +# line 81 "lexer.l" +Return(CLOSE_SQUARE); + YY_BREAK +case 11: +# line 83 "lexer.l" +Return(EQUALS); + YY_BREAK +case 12: +# line 85 "lexer.l" +Return(PERIOD); + YY_BREAK +case 13: +# line 87 "lexer.l" +; + YY_BREAK +case 14: +# line 89 "lexer.l" +; + YY_BREAK +case 15: +# line 91 "lexer.l" +{ loop: +#ifdef __cplusplus + while (yyinput() != '*'); + switch (yyinput()) +#else + while (input() != '*'); + switch (input()) +#endif + { + case '/': break; + case '*': unput('*'); + default: goto loop; + } + } + YY_BREAK +case 16: +# line 106 "lexer.l" +Return(ERROR); + YY_BREAK +case 17: +# line 108 "lexer.l" +ECHO; + YY_BREAK +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* amount of text matched not including the EOB char */ + int yy_amount_of_matched_text = yy_cp - yytext - 1; + + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + + /* note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the end- + * of-buffer state). Contrast this with the test in yyinput(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* this was really a NUL */ + { + yy_state_type yy_next_state; + + yy_c_buf_p = yytext + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* okay, we're now positioned to make the + * NUL transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we + * don't want to build jamming into it because + * then it will run more slowly) + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = yytext + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* consume the NUL */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* note: because we've taken care in + * yy_get_next_buffer() to have set up yytext, + * we can now set up yy_c_buf_p so that if some + * total hoser (like flex itself) wants + * to call the scanner after we return the + * YY_NULL, it'll still work - another YY_NULL + * will get returned. + */ + yy_c_buf_p = yytext + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF((yy_start - 1) / 2); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + } + break; + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: +#ifdef FLEX_DEBUG + printf( "action # %d\n", yy_act ); +#endif + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } + } + } + + +/* yy_get_next_buffer - try to read in a new buffer + * + * synopsis + * int yy_get_next_buffer(); + * + * returns a code representing an action + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ + +static int yy_get_next_buffer() + + { + register YY_CHAR *dest = yy_current_buffer->yy_ch_buf; + register YY_CHAR *source = yytext - 1; /* copy prev. char, too */ + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + /* try to read more data */ + + /* first move last chars to start of buffer */ + number_to_move = yy_c_buf_p - yytext; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_n_chars = 0; + + else + { + int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + else if ( num_to_read <= 0 ) + YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); + + /* read in more data */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == 1 ) + { + ret_val = EOB_ACT_END_OF_FILE; + yy_current_buffer->yy_eof_status = EOF_DONE; + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_eof_status = EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + /* yytext begins at the second character in yy_ch_buf; the first + * character is the one which preceded it before reading in the latest + * buffer; it needs to be kept around in case it's a newline, so + * yy_get_previous_state() will have with '^' rules active + */ + + yytext = &yy_current_buffer->yy_ch_buf[1]; + + return ( ret_val ); + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached + * + * synopsis + * yy_state_type yy_get_previous_state(); + */ + +static yy_state_type yy_get_previous_state() + + { + register yy_state_type yy_current_state; + register YY_CHAR *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = yy_def[yy_current_state]; + if ( yy_current_state >= 34 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return ( yy_current_state ); + } + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +register yy_state_type yy_current_state; +#endif + + { + register int yy_is_jam; + register YY_CHAR *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = yy_def[yy_current_state]; + if ( yy_current_state >= 34 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 33); + + return ( yy_is_jam ? 0 : yy_current_state ); + } + + +#ifdef YY_USE_PROTOS +static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp ) +#else +static void yyunput( c, yy_bp ) +YY_CHAR c; +register YY_CHAR *yy_bp; +#endif + + { + register YY_CHAR *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */ + register YY_CHAR *dest = + &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2]; + register YY_CHAR *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += dest - source; + yy_bp += dest - source; + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + if ( yy_cp > yy_bp && yy_cp[-1] == '\n' ) + yy_cp[-2] = '\n'; + + *--yy_cp = c; + + /* note: the formal parameter *must* be called "yy_bp" for this + * macro to now work correctly + */ + YY_DO_BEFORE_ACTION; /* set up yytext again */ + } + + +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + + { + int c; + YY_CHAR *yy_cp = yy_c_buf_p; + + *yy_cp = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* this was really a NUL */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + yytext = yy_c_buf_p; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + { + yy_c_buf_p = yytext + YY_MORE_ADJ; + return ( EOF ); + } + + YY_NEW_FILE; + +#ifdef __cplusplus + return ( yyinput() ); +#else + return ( input() ); +#endif + } + break; + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext + YY_MORE_ADJ; + break; + + case EOB_ACT_LAST_MATCH: +#ifdef __cplusplus + YY_FATAL_ERROR( "unexpected last match in yyinput()" ); +#else + YY_FATAL_ERROR( "unexpected last match in input()" ); +#endif + } + } + } + + c = *yy_c_buf_p; + yy_hold_char = *++yy_c_buf_p; + + return ( c ); + } + + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + + { + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* flush out information for old buffer */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* we don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) ); + + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) ); + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + yy_init_buffer( b, file ); + + return ( b ); + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + free( (char *) b->yy_ch_buf ); + free( (char *) b ); + } + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + { + b->yy_input_file = file; + + /* we put in the '\n' and start reading from [1] so that an + * initial match-at-newline will be true. + */ + + b->yy_ch_buf[0] = '\n'; + b->yy_n_chars = 1; + + /* we always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[1]; + + b->yy_eof_status = EOF_NOT_SEEN; + } +# line 108 "lexer.l" + + + +#ifdef FLEX_SCANNER +static int lex_input() { + return input(); +} +#else /* BSD/AT&T lex */ +#ifndef input +# error "Sorry, but need either flex or AT&T lex" +#endif +static int lex_input() { + return input(); +} +/* # undef unput +# define unput(_c) my_unput(_c) +*/ + +# undef input +# define input() my_input() +static int my_unput(char c) +{ + if (lex_read_from_string) { + /* Make sure we have something */ + if (lex_string_ptr) { + if (c == '\n') yylineno--; + lex_string_ptr--; + } + } else { + yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar; +/* unput(c); Causes infinite recursion! */ + } + return c; +} + +#endif + +/* Public */ +void LexFromFile(FILE *fd) +{ + lex_read_from_string = 0; + yyin = fd; + /* Don't know why this is necessary, but otherwise + * lex only works _once_! + */ +#ifdef FLEX_SCANNER + yy_init = 1; +#endif +} + +void LexFromString(char *buffer) +{ + lex_read_from_string = 1; + lex_buffer = buffer; + lex_buffer_length = strlen(buffer); + lex_string_ptr = 0; + /* Don't know why this is necessary, but otherwise + * lex only works _once_! + */ +#ifdef FLEX_SCANNER + yy_init = 1; +#endif +} + +static int my_input( void ) +{ + if (lex_read_from_string) { + if (lex_string_ptr == lex_buffer_length) + return 0; + else { + char c = lex_buffer[lex_string_ptr++]; +#ifndef FLEX_SCANNER + if (c == '\n') yylineno++; +#endif + return c; + } + } else { + return lex_input(); + } +} + diff --git a/CExpr/old/DOSYACC.C b/CExpr/old/DOSYACC.C new file mode 100644 index 0000000..03f7726 --- /dev/null +++ b/CExpr/old/DOSYACC.C @@ -0,0 +1,516 @@ +#ifndef lint +static char yysccsid[] = "@(#)yaccpar 1.7 (Berkeley) 09/09/90"; +#endif +#define YYBYACC 1 +#line 2 "parser.y" +#include "string.h" +#include "expr.h" + +#ifndef __EXTERN_C__ +#define __EXTERN_C__ 1 +#endif + +#if defined(__cplusplus) || defined(__STDC__) +#if defined(__cplusplus) && defined(__EXTERN_C__) +extern "C" { +#endif +#endif +int yylex(void); +int yylook(void); +int yywrap(void); +int yyback(int *, int); + +/* You may need to put /DLEX_SCANNER in your makefile + * if you're using LEX! + */ +#ifdef LEX_SCANNER +/* int yyoutput(int); */ +void yyoutput(int); +#else +void yyoutput(int); +#endif + +#if defined(__cplusplus) || defined(__STDC__) +#if defined(__cplusplus) && defined(__EXTERN_C__) +} +#endif +#endif +#line 36 "parser.y" +typedef union { + char *s; +/* struct pexpr *expr; */ +} YYSTYPE; +#line 44 "y_tab.c" +#define INTEGER 1 +#define WORD 2 +#define STRING 3 +#define PERIOD 13 +#define OPEN 4 +#define CLOSE 5 +#define COMMA 6 +#define NEWLINE 7 +#define ERROR 8 +#define OPEN_SQUARE 9 +#define CLOSE_SQUARE 10 +#define EQUALS 11 +#define EXP 14 +#define YYERRCODE 256 +short yylhs[] = { -1, + 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, + 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, +}; +short yylen[] = { 2, + 0, 2, 2, 2, 2, 4, 2, 3, 0, 1, + 3, 3, 1, 1, 1, 1, 3, 3, 5, 1, +}; +short yydefred[] = { 1, + 0, 0, 0, 0, 2, 0, 5, 3, 0, 0, + 0, 15, 7, 20, 0, 0, 13, 4, 0, 0, + 0, 0, 8, 0, 6, 0, 18, 0, 12, 11, + 0, 19, +}; +short yydgoto[] = { 1, + 5, 14, 15, 16, 17, +}; +short yysindex[] = { 0, + -2, 9, 2, 1, 0, 10, 0, 0, 11, -5, + 17, 0, 0, 0, 14, -1, 0, 0, 33, 38, + 41, 16, 0, 11, 0, 29, 0, 40, 0, 0, + 44, 0, +}; +short yyrindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 42, 21, + 24, 0, 0, 0, 0, 30, 0, 0, 0, 0, + 0, 0, 0, 31, 0, 27, 0, 24, 0, 0, + 0, 0, +}; +short yygindex[] = { 0, + 0, 45, -8, 0, 26, +}; +#define YYTABLESIZE 254 +short yytable[] = { 3, + 19, 10, 11, 12, 24, 9, 4, 20, 21, 4, + 13, 10, 11, 12, 8, 30, 10, 28, 12, 4, + 9, 7, 18, 23, 4, 16, 16, 22, 14, 14, + 16, 17, 17, 14, 10, 9, 17, 25, 26, 10, + 9, 27, 31, 9, 32, 6, 9, 29, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2, +}; +short yycheck[] = { 2, + 9, 1, 2, 3, 6, 4, 9, 13, 14, 9, + 10, 1, 2, 3, 13, 24, 1, 2, 3, 9, + 4, 13, 13, 10, 9, 5, 6, 11, 5, 6, + 10, 5, 6, 10, 5, 5, 10, 5, 1, 10, + 10, 1, 14, 4, 1, 1, 5, 22, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 256, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 14 +#if YYDEBUG +char *yyname[] = { +"end-of-file","INTEGER","WORD","STRING","OPEN","CLOSE","COMMA","NEWLINE", +"ERROR","OPEN_SQUARE","CLOSE_SQUARE","EQUALS",0,"PERIOD","EXP", +}; +char *yyrule[] = { +"$accept : commands", +"commands :", +"commands : commands command", +"command : WORD PERIOD", +"command : expr PERIOD", +"command : error PERIOD", +"expr : WORD OPEN arglist CLOSE", +"expr : OPEN_SQUARE CLOSE_SQUARE", +"expr : OPEN_SQUARE arglist CLOSE_SQUARE", +"arglist :", +"arglist : arg", +"arglist : arg COMMA arglist", +"arg : WORD EQUALS arg1", +"arg : arg1", +"arg1 : WORD", +"arg1 : STRING", +"arg1 : INTEGER", +"arg1 : INTEGER PERIOD INTEGER", +"arg1 : INTEGER EXP INTEGER", +"arg1 : INTEGER PERIOD INTEGER EXP INTEGER", +"arg1 : expr", +}; +#endif +#define yyclearin (yychar=(-1)) +#define yyerrok (yyerrflag=0) +#ifdef YYSTACKSIZE +#ifndef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#endif +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 600 +#define YYMAXDEPTH 600 +#endif +#endif +int yydebug; +int yynerrs; +int yyerrflag; +int yychar; +short *yyssp; +YYSTYPE *yyvsp; +YYSTYPE yyval; +YYSTYPE yylval; +short yyss[YYSTACKSIZE]; +YYSTYPE yyvs[YYSTACKSIZE]; +#define yystacksize YYSTACKSIZE +#line 118 "parser.y" + +#include "lex_yy.c" + +/* +void yyerror(s) +char *s; +{ + syntax_error(s); +} +*/ + +/* Ansi prototype. If this doesn't work for you... uncomment + the above instead. + */ + +void yyerror(char *s) +{ + syntax_error(s); +} + +/* + * Unfortunately, my DOS version of FLEX + * requires yywrap to be #def'ed, whereas + * the UNIX flex expects a proper function. + */ + +/* Not sure if __SC__ is the appropriate thing + * to test + */ + +#ifndef __SC__ +#ifdef USE_DEFINE +#ifndef yywrap +#define yywrap() 1 +#endif +#else +int yywrap() { return 1; } +#endif +#endif +#line 247 "y_tab.c" +#define YYABORT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +int +yyparse() +{ + register int yym, yyn, yystate; +#if YYDEBUG + register char *yys; + extern char *getenv(); + + if (yys = getenv("YYDEBUG")) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } +#endif + + yynerrs = 0; + yyerrflag = 0; + yychar = (-1); + + yyssp = yyss; + yyvsp = yyvs; + *yyssp = yystate = 0; + +yyloop: + if (yyn = yydefred[yystate]) goto yyreduce; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("yydebug: state %d, reading %d (%s)\n", yystate, + yychar, yys); + } +#endif + } + if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { +#if YYDEBUG + if (yydebug) + printf("yydebug: state %d, shifting to state %d\n", + yystate, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + yychar = (-1); + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; +#ifdef lint + goto yynewerror; +#endif +yynewerror: + yyerror("syntax error"); +#ifdef lint + goto yyerrlab; +#endif +yyerrlab: + ++yynerrs; +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("yydebug: state %d, error recovery shifting\ + to state %d\n", *yyssp, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("yydebug: error recovery discarding state %d\n", + *yyssp); +#endif + if (yyssp <= yyss) goto yyabort; + --yyssp; + --yyvsp; + } + } + } + else + { + if (yychar == 0) goto yyabort; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("yydebug: state %d, error recovery discards token %d (%s)\n", + yystate, yychar, yys); + } +#endif + yychar = (-1); + goto yyloop; + } +yyreduce: +#if YYDEBUG + if (yydebug) + printf("yydebug: state %d, reducing by rule %d (%s)\n", + yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + yyval = yyvsp[1-yym]; + switch (yyn) + { +case 3: +#line 68 "parser.y" +{process_command(cexpr_cons(make_word(yyvsp[-1].s), NULL)); free(yyvsp[-1].s);} +break; +case 4: +#line 70 "parser.y" +{process_command(yyvsp[-1].s);} +break; +case 5: +#line 72 "parser.y" +{syntax_error("Unrecognized command.");} +break; +case 6: +#line 76 "parser.y" +{yyval.s = cexpr_cons(make_word(yyvsp[-3].s), yyvsp[-1].s); free(yyvsp[-3].s);} +break; +case 7: +#line 78 "parser.y" +{yyval.s = cexpr_cons(NULL, NULL);} +break; +case 8: +#line 80 "parser.y" +{yyval.s = yyvsp[-1].s; } +break; +case 9: +#line 84 "parser.y" +{yyval.s = NULL;} +break; +case 10: +#line 86 "parser.y" +{yyval.s = cexpr_cons(yyvsp[0].s, NULL);} +break; +case 11: +#line 89 "parser.y" +{yyval.s = cexpr_cons(yyvsp[-2].s, yyvsp[0].s);} +break; +case 12: +#line 93 "parser.y" +{yyval.s = cexpr_cons(make_word("="), cexpr_cons(make_word(yyvsp[-2].s), cexpr_cons(yyvsp[0].s, NULL))); + free(yyvsp[-2].s); } +break; +case 13: +#line 96 "parser.y" +{yyval.s = yyvsp[0].s; } +break; +case 14: +#line 99 "parser.y" +{yyval.s = make_word(yyvsp[0].s); free(yyvsp[0].s);} +break; +case 15: +#line 101 "parser.y" +{yyval.s = make_string(yyvsp[0].s); free(yyvsp[0].s);} +break; +case 16: +#line 103 "parser.y" +{yyval.s = make_integer(yyvsp[0].s); free(yyvsp[0].s);} +break; +case 17: +#line 105 "parser.y" +{yyval.s = make_real(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); } +break; +case 18: +#line 107 "parser.y" +{yyval.s = make_exp(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); } +break; +case 19: +#line 110 "parser.y" +{yyval.s = make_exp2(yyvsp[-4].s, yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-4].s); free(yyvsp[-2].s); + free(yyvsp[0].s); } +break; +case 20: +#line 114 "parser.y" +{yyval.s = yyvsp[0].s;} +break; +#line 461 "y_tab.c" + } + yyssp -= yym; + yystate = *yyssp; + yyvsp -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("yydebug: after reduction, shifting from state 0 to\ + state %d\n", YYFINAL); +#endif + yystate = YYFINAL; + *++yyssp = YYFINAL; + *++yyvsp = yyval; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("yydebug: state %d, reading %d (%s)\n", + YYFINAL, yychar, yys); + } +#endif + } + if (yychar == 0) goto yyaccept; + goto yyloop; + } + if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("yydebug: after reduction, shifting from state %d \ +to state %d\n", *yyssp, yystate); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate; + *++yyvsp = yyval; + goto yyloop; +yyoverflow: + yyerror("yacc stack overflow"); +yyabort: + return (1); +yyaccept: + return (0); +} diff --git a/CExpr/old/LEXER.L b/CExpr/old/LEXER.L new file mode 100644 index 0000000..8635661 --- /dev/null +++ b/CExpr/old/LEXER.L @@ -0,0 +1,193 @@ +SIGN [+-] +DIGIT [0-9] +ALPHA [a-zA-Z_] +ALPHADIGIT [a-zA-Z_0-9] +STRINGCHAR [^"\\] +WORDCHAR [^'\\] + +%{ +/* + * File: lexer.l + * Description: Lexical analyser for PROLOGIO; can be used with + * either lex and flex. + */ +#include + +/* +++steve162e: added, otherwise, CExpr_input will be undefined (at least under LINUX) + please check, if this is also TRUE under other UNIXes. + */ + +#if defined(FLEX_SCANNER) && defined(_LINUX) +#define CExpr_input my_input +#endif +/* ---steve162e */ + +#include "expr.h" +#ifdef wx_x +extern char *malloc(); +#endif +#define Return(x) return x; + +#if defined(VMS) && !defined(strdup) +#define strdup(s) (strcpy((char *)malloc(strlen(s)+1), s)); +#endif + +static size_t lex_buffer_length = 0; +static const char *lex_buffer = NULL; +static size_t lex_string_ptr = 0; +static int lex_read_from_string = 0; + +static int my_input(void); +static int my_unput(char); + +#ifdef FLEX_SCANNER +#undef YY_INPUT +# define YY_INPUT(buf,result,max_size) \ + if (lex_read_from_string) \ + { int c = my_input(); result = (c == 0) ? YY_NULL : ((buf)[0]=(c), 1); } \ + else \ + if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "read() in flex scanner failed" ); +#else +# undef unput +# define unput(_c) my_unput(_c) +#endif + +%} + +%% + +{SIGN}?{DIGIT}+ {yylval.s = strdup(yytext); Return(INTEGER);} + +"e" Return(EXP); + +{ALPHA}{ALPHADIGIT}* {yylval.s = strdup(yytext); Return(WORD);} + +"'"{WORDCHAR}*"'" {int len = strlen(yytext); + yytext[len-1] = 0; + yylval.s = strdup(yytext+1); + Return(WORD);} + +\"({STRINGCHAR}|\\\"|\|\\\\|\\)*\" {yylval.s = strdup(yytext); Return(STRING);} + +"(" Return(OPEN); + +")" Return(CLOSE); + +"," Return(COMMA); + +"[" Return(OPEN_SQUARE); + +"]" Return(CLOSE_SQUARE); + +"=" Return(EQUALS); + +"." Return(PERIOD); + +[ \t] ; + +\n ; + +"/*" { loop: +#ifdef __cplusplus + while (yyinput() != '*'); + switch (yyinput()) +#else + while (input() != '*'); + switch (input()) +#endif + { + case '/': break; + case '*': unput('*'); + default: goto loop; + } + } + +. Return(ERROR); + +%% + + +#ifdef FLEX_SCANNER +static int lex_input() { + return input(); +} +#else /* BSD/AT&T lex */ +#ifndef input +# error "Sorry, but need either flex or AT&T lex" +#endif +static int lex_input() { + return input(); +} +/* # undef unput +# define unput(_c) my_unput(_c) +*/ + +# undef input +# define input() my_input() +static int my_unput(char c) +{ + if (lex_read_from_string) { + /* Make sure we have something */ + if (lex_string_ptr) { + if (c == '\n') yylineno--; + lex_string_ptr--; + } + } else { + yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar; +/* unput(c); Causes infinite recursion! */ + } + return c; +} + +#endif + +/* Public */ +void LexFromFile(FILE *fd) +{ + lex_read_from_string = 0; + yyin = fd; + /* Don't know why this is necessary, but otherwise + * lex only works _once_! + */ +#ifdef FLEX_SCANNER + yy_init = 1; +#endif +} + +void LexFromString(char *buffer) +{ + lex_read_from_string = 1; + lex_buffer = buffer; + lex_buffer_length = strlen(buffer); + lex_string_ptr = 0; + /* Don't know why this is necessary, but otherwise + * lex only works _once_! + */ +#ifdef FLEX_SCANNER + yy_init = 1; +#endif +} + +static int my_input( void ) +{ + if (lex_read_from_string) { + if (lex_string_ptr == lex_buffer_length) + return 0; + else { + char c = lex_buffer[lex_string_ptr++]; +#ifndef FLEX_SCANNER + if (c == '\n') yylineno++; +#endif + return c; + } + } else { + return lex_input(); + } +} + +void CExprCleanUp() +{ + if (yy_current_buffer) + yy_delete_buffer(yy_current_buffer); +} diff --git a/CExpr/old/LEX_YY.C b/CExpr/old/LEX_YY.C new file mode 100644 index 0000000..7cb9405 --- /dev/null +++ b/CExpr/old/LEX_YY.C @@ -0,0 +1,1213 @@ +/* A lexical scanner generated by flex */ + +/* scanner skeleton version: + * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.16 90/08/03 14:09:36 vern Exp $ + */ + +#define FLEX_SCANNER + +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include +#include + +/* use prototypes in function declarations */ +#define YY_USE_PROTOS + +/* the "const" storage-class-modifier is valid */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#ifdef __STDC__ + +#ifdef __GNUC__ +#include +#else +#include +#endif /* __GNUC__ */ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + + +#ifdef __TURBOC__ +#define YY_USE_CONST +#endif + + +#ifndef YY_USE_CONST +#define const +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +/* we can't get here if it's an ANSI C compiler, or a C++ compiler, + * so it's got to be a K&R compiler, and therefore there's no standard + * place from which to include these definitions + */ +/* +char *malloc(); +int free(); +*/ + +int read(); +#endif + + +/* amount of stuff to slurp up with each read */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* returned upon end-of-file */ +#define YY_END_TOK 0 + +/* copy whatever the last rule matched to the standard output */ + +/* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */ +/* this used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite() + */ +#define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout ) + +/* gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#define YY_INPUT(buf,result,max_size) \ + if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "read() in flex scanner failed" ); +#define YY_NULL 0 + +/* no semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#define yyterminate() return ( YY_NULL ) + +/* report a fatal error */ + +/* The funky do-while is used to turn this macro definition into + * a single C statement (which needs a semi-colon terminator). + * This avoids problems with code like: + * + * if ( something_happens ) + * YY_FATAL_ERROR( "oops, the something happened" ); + * else + * everything_okay(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the YY_FATAL_ERROR() call. + */ + +#define YY_FATAL_ERROR(msg) \ + do \ + { \ + (void) fputs( msg, stderr ); \ + (void) putc( '\n', stderr ); \ + exit( 1 ); \ + } \ + while ( 0 ) + +/* default yywrap function - always treat EOF as an EOF */ +int yywrap(void) { return 1; } + + +/* enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN + */ +#define BEGIN yy_start = 1 + 2 * + +/* action number for EOF rule of a given start state */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* special action meaning "start processing a new file" */ +#define YY_NEW_FILE \ + do \ + { \ + yy_init_buffer( yy_current_buffer, yyin ); \ + yy_load_buffer_state(); \ + } \ + while ( 0 ) + +/* default declaration of generated scanner - a define so the user can + * easily add parameters + */ +#define YY_DECL int yylex YY_PROTO(( void )) + +/* code executed at the end of each rule */ +#define YY_BREAK break; + +#define YY_END_OF_BUFFER_CHAR 0 + +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */ +#endif + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +#define YY_CHAR unsigned char +# line 1 "lexer.l" +#define INITIAL 0 +# line 9 "lexer.l" +/* + * File: lexer.l + * Description: Lexical analyser for PROLOGIO; can be used with + * either lex and flex. + */ +#include + +/* +++steve162e: added, otherwise, CExpr_input will be undefined (at least under LINUX) + please check, if this is also TRUE under other UNIXes. + */ + +#if defined(FLEX_SCANNER) && defined(_LINUX) +#define CExpr_input my_input +#endif +/* ---steve162e */ + +#include "expr.h" +#ifdef wx_x +extern char *malloc(); +#endif +#define Return(x) return x; + +#if defined(VMS) && !defined(strdup) +#define strdup(s) (strcpy((char *)malloc(strlen(s)+1), s)); +#endif + +static size_t lex_buffer_length = 0; +static const char *lex_buffer = NULL; +static size_t lex_string_ptr = 0; +static int lex_read_from_string = 0; + +static int my_input(void); +static int my_unput(char); + +#ifdef FLEX_SCANNER +#undef YY_INPUT +# define YY_INPUT(buf,result,max_size) \ + if (lex_read_from_string) \ + { int c = my_input(); result = (c == 0) ? YY_NULL : ((buf)[0]=(c), 1); } \ + else \ + if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "read() in flex scanner failed" ); +#else +# undef unput +# define unput(_c) my_unput(_c) +#endif + +# line 58 "lexer.l" + +/* done after the current pattern has been matched and before the + * corresponding action - sets up yytext + */ +#define YY_DO_BEFORE_ACTION \ + yytext = yy_bp; \ + yyleng = yy_cp - yy_bp; \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* return all but the first 'n' matched characters back to the input stream */ +#define yyless(n) \ + do \ + { \ + /* undo effects of setting up yytext */ \ + *yy_cp = yy_hold_char; \ + yy_c_buf_p = yy_cp = yy_bp + n; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#undef unput +#define unput(c) yyunput( c, yytext ) + + +struct yy_buffer_state + { + FILE *yy_input_file; + + YY_CHAR *yy_ch_buf; /* input buffer */ + YY_CHAR *yy_buf_pos; /* current position in input buffer */ + + /* size of input buffer in bytes, not including room for EOB characters*/ + int yy_buf_size; + + /* number of characters read into yy_ch_buf, not including EOB characters */ + int yy_n_chars; + + int yy_eof_status; /* whether we've seen an EOF on this buffer */ +#define EOF_NOT_SEEN 0 + /* "pending" happens when the EOF has been seen but there's still + * some text process + */ +#define EOF_PENDING 1 +#define EOF_DONE 2 + }; + +static YY_BUFFER_STATE yy_current_buffer; + +/* we provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state" + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed */ +static YY_CHAR yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + + +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +#ifndef YY_USER_INIT +#define YY_USER_INIT +#endif + +extern YY_CHAR *yytext; +extern int yyleng; +extern FILE *yyin, *yyout; + +YY_CHAR *yytext; +int yyleng; + +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; + +#define YY_END_OF_BUFFER 18 +typedef int yy_state_type; +static const short int yy_accept[34] = + { 0, + 0, 0, 18, 16, 13, 14, 16, 16, 6, 7, + 16, 8, 12, 16, 1, 11, 3, 9, 10, 2, + 0, 5, 0, 0, 0, 4, 1, 15, 3, 5, + 0, 0, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 4, 1, 1, 1, 1, 5, 6, + 7, 8, 9, 10, 9, 11, 12, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 1, 1, 1, + 14, 1, 1, 1, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 16, 17, 18, 1, 15, 1, 15, 15, 15, 15, + + 19, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 1, 20, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static const YY_CHAR yy_meta[21] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 1, 2, 1, 3, 1, 2, 1 + } ; + +static const short int yy_base[37] = + { 0, + 0, 0, 48, 55, 55, 55, 17, 42, 55, 55, + 19, 55, 55, 23, 17, 55, 0, 55, 55, 0, + 18, 55, 19, 23, 21, 55, 12, 55, 0, 24, + 25, 29, 55, 49, 52, 22 + } ; + +static const short int yy_def[37] = + { 0, + 33, 1, 33, 33, 33, 33, 34, 35, 33, 33, + 33, 33, 33, 33, 33, 33, 36, 33, 33, 36, + 34, 33, 34, 34, 35, 33, 33, 33, 36, 34, + 34, 34, 0, 33, 33, 33 + } ; + +static const short int yy_nxt[76] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 4, 11, 12, + 13, 14, 15, 16, 17, 18, 4, 19, 20, 4, + 22, 22, 30, 29, 27, 26, 22, 22, 30, 27, + 28, 27, 30, 23, 23, 23, 24, 24, 24, 31, + 23, 32, 24, 24, 24, 23, 26, 33, 24, 21, + 21, 21, 25, 25, 3, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33 + } ; + +static const short int yy_chk[76] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 7, 21, 23, 36, 27, 25, 24, 30, 31, 15, + 14, 11, 32, 7, 21, 23, 7, 21, 23, 24, + 30, 31, 24, 30, 31, 32, 8, 3, 32, 34, + 34, 34, 35, 35, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33 + } ; + +static yy_state_type yy_last_accepting_state; +static YY_CHAR *yy_last_accepting_cpos; + +/* the intent behind this definition is that it'll catch + * any uses of REJECT which flex missed + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 + +/* these variables are all declared out here so that section 3 code can + * manipulate them + */ +/* points to current character in buffer */ +static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr )); +void yyrestart YY_PROTO(( FILE *input_file )); +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); + +#define yy_new_buffer yy_create_buffer + +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif + +YY_DECL + { + register yy_state_type yy_current_state; + register YY_CHAR *yy_cp, *yy_bp; + register int yy_act; + + + + + if ( yy_init ) + { + YY_USER_INIT; + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( yy_current_buffer ) + yy_init_buffer( yy_current_buffer, yyin ); + else + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + + yy_init = 0; + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* support of yytext */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of the + * current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[*yy_cp]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = yy_def[yy_current_state]; + if ( yy_current_state >= 34 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 33 ); + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + YY_USER_ACTION; + +do_action: /* this label is used only to access EOF actions */ + + + switch ( yy_act ) + { + case 0: /* must backtrack */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +# line 60 "lexer.l" +{yylval.s = strdup(yytext); Return(INTEGER);} + YY_BREAK +case 2: +# line 62 "lexer.l" +Return(EXP); + YY_BREAK +case 3: +# line 64 "lexer.l" +{yylval.s = strdup(yytext); Return(WORD);} + YY_BREAK +case 4: +# line 66 "lexer.l" +{int len = strlen(yytext); + yytext[len-1] = 0; + yylval.s = strdup(yytext+1); + Return(WORD);} + YY_BREAK +case 5: +# line 71 "lexer.l" +{yylval.s = strdup(yytext); Return(STRING);} + YY_BREAK +case 6: +# line 73 "lexer.l" +Return(OPEN); + YY_BREAK +case 7: +# line 75 "lexer.l" +Return(CLOSE); + YY_BREAK +case 8: +# line 77 "lexer.l" +Return(COMMA); + YY_BREAK +case 9: +# line 79 "lexer.l" +Return(OPEN_SQUARE); + YY_BREAK +case 10: +# line 81 "lexer.l" +Return(CLOSE_SQUARE); + YY_BREAK +case 11: +# line 83 "lexer.l" +Return(EQUALS); + YY_BREAK +case 12: +# line 85 "lexer.l" +Return(PERIOD); + YY_BREAK +case 13: +# line 87 "lexer.l" +; + YY_BREAK +case 14: +# line 89 "lexer.l" +; + YY_BREAK +case 15: +# line 91 "lexer.l" +{ loop: +#ifdef __cplusplus + while (yyinput() != '*'); + switch (yyinput()) +#else + while (input() != '*'); + switch (input()) +#endif + { + case '/': break; + case '*': unput('*'); + default: goto loop; + } + } + YY_BREAK +case 16: +# line 106 "lexer.l" +Return(ERROR); + YY_BREAK +case 17: +# line 108 "lexer.l" +ECHO; + YY_BREAK +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* amount of text matched not including the EOB char */ + int yy_amount_of_matched_text = yy_cp - yytext - 1; + + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + + /* note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the end- + * of-buffer state). Contrast this with the test in yyinput(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* this was really a NUL */ + { + yy_state_type yy_next_state; + + yy_c_buf_p = yytext + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* okay, we're now positioned to make the + * NUL transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we + * don't want to build jamming into it because + * then it will run more slowly) + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = yytext + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* consume the NUL */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* note: because we've taken care in + * yy_get_next_buffer() to have set up yytext, + * we can now set up yy_c_buf_p so that if some + * total hoser (like flex itself) wants + * to call the scanner after we return the + * YY_NULL, it'll still work - another YY_NULL + * will get returned. + */ + yy_c_buf_p = yytext + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF((yy_start - 1) / 2); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + } + break; + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: +#ifdef FLEX_DEBUG + printf( "action # %d\n", yy_act ); +#endif + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } + } + } + + +/* yy_get_next_buffer - try to read in a new buffer + * + * synopsis + * int yy_get_next_buffer(); + * + * returns a code representing an action + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ + +static int yy_get_next_buffer() + + { + register YY_CHAR *dest = yy_current_buffer->yy_ch_buf; + register YY_CHAR *source = yytext - 1; /* copy prev. char, too */ + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + /* try to read more data */ + + /* first move last chars to start of buffer */ + number_to_move = yy_c_buf_p - yytext; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_n_chars = 0; + + else + { + int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + else if ( num_to_read <= 0 ) + YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); + + /* read in more data */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == 1 ) + { + ret_val = EOB_ACT_END_OF_FILE; + yy_current_buffer->yy_eof_status = EOF_DONE; + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_eof_status = EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + /* yytext begins at the second character in yy_ch_buf; the first + * character is the one which preceded it before reading in the latest + * buffer; it needs to be kept around in case it's a newline, so + * yy_get_previous_state() will have with '^' rules active + */ + + yytext = &yy_current_buffer->yy_ch_buf[1]; + + return ( ret_val ); + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached + * + * synopsis + * yy_state_type yy_get_previous_state(); + */ + +static yy_state_type yy_get_previous_state() + + { + register yy_state_type yy_current_state; + register YY_CHAR *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = yy_def[yy_current_state]; + if ( yy_current_state >= 34 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return ( yy_current_state ); + } + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +register yy_state_type yy_current_state; +#endif + + { + register int yy_is_jam; + register YY_CHAR *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = yy_def[yy_current_state]; + if ( yy_current_state >= 34 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 33); + + return ( yy_is_jam ? 0 : yy_current_state ); + } + + +#ifdef YY_USE_PROTOS +static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp ) +#else +static void yyunput( c, yy_bp ) +YY_CHAR c; +register YY_CHAR *yy_bp; +#endif + + { + register YY_CHAR *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */ + register YY_CHAR *dest = + &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2]; + register YY_CHAR *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += dest - source; + yy_bp += dest - source; + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + if ( yy_cp > yy_bp && yy_cp[-1] == '\n' ) + yy_cp[-2] = '\n'; + + *--yy_cp = c; + + /* note: the formal parameter *must* be called "yy_bp" for this + * macro to now work correctly + */ + YY_DO_BEFORE_ACTION; /* set up yytext again */ + } + + +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + + { + int c; + YY_CHAR *yy_cp = yy_c_buf_p; + + *yy_cp = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* this was really a NUL */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + yytext = yy_c_buf_p; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + { + yy_c_buf_p = yytext + YY_MORE_ADJ; + return ( EOF ); + } + + YY_NEW_FILE; + +#ifdef __cplusplus + return ( yyinput() ); +#else + return ( input() ); +#endif + } + break; + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext + YY_MORE_ADJ; + break; + + case EOB_ACT_LAST_MATCH: +#ifdef __cplusplus + YY_FATAL_ERROR( "unexpected last match in yyinput()" ); +#else + YY_FATAL_ERROR( "unexpected last match in input()" ); +#endif + } + } + } + + c = *yy_c_buf_p; + yy_hold_char = *++yy_c_buf_p; + + return ( c ); + } + + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + + { + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* flush out information for old buffer */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* we don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) ); + + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) ); + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + yy_init_buffer( b, file ); + + return ( b ); + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + free( (char *) b->yy_ch_buf ); + free( (char *) b ); + } + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + { + b->yy_input_file = file; + + /* we put in the '\n' and start reading from [1] so that an + * initial match-at-newline will be true. + */ + + b->yy_ch_buf[0] = '\n'; + b->yy_n_chars = 1; + + /* we always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[1]; + + b->yy_eof_status = EOF_NOT_SEEN; + } +# line 108 "lexer.l" + + + +#ifdef FLEX_SCANNER +static int lex_input() { + return input(); +} +#else /* BSD/AT&T lex */ +#ifndef input +# error "Sorry, but need either flex or AT&T lex" +#endif +static int lex_input() { + return input(); +} +/* # undef unput +# define unput(_c) my_unput(_c) +*/ + +# undef input +# define input() my_input() +static int my_unput(char c) +{ + if (lex_read_from_string) { + /* Make sure we have something */ + if (lex_string_ptr) { + if (c == '\n') yylineno--; + lex_string_ptr--; + } + } else { + yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar; +/* unput(c); Causes infinite recursion! */ + } + return c; +} + +#endif + +/* Public */ +void LexFromFile(FILE *fd) +{ + lex_read_from_string = 0; + yyin = fd; + /* Don't know why this is necessary, but otherwise + * lex only works _once_! + */ +#ifdef FLEX_SCANNER + yy_init = 1; +#endif +} + +void LexFromString(char *buffer) +{ + lex_read_from_string = 1; + lex_buffer = buffer; + lex_buffer_length = strlen(buffer); + lex_string_ptr = 0; + /* Don't know why this is necessary, but otherwise + * lex only works _once_! + */ +#ifdef FLEX_SCANNER + yy_init = 1; +#endif +} + +static int my_input( void ) +{ + if (lex_read_from_string) { + if (lex_string_ptr == lex_buffer_length) + return 0; + else { + char c = lex_buffer[lex_string_ptr++]; +#ifndef FLEX_SCANNER + if (c == '\n') yylineno++; +#endif + return c; + } + } else { + return lex_input(); + } +} + +void CExprCleanUp() +{ + if (yy_current_buffer) + yy_delete_buffer(yy_current_buffer); +} diff --git a/CExpr/old/PARSER.Y b/CExpr/old/PARSER.Y new file mode 100644 index 0000000..7ede7ec --- /dev/null +++ b/CExpr/old/PARSER.Y @@ -0,0 +1,157 @@ + %{ +#include "string.h" +#include "expr.h" + +#ifndef __EXTERN_C__ +#define __EXTERN_C__ 1 +#endif + +#if defined(__cplusplus) || defined(__STDC__) +#if defined(__cplusplus) && defined(__EXTERN_C__) +extern "C" { +#endif +#endif +int yylex(void); +int yylook(void); +int yywrap(void); +int yyback(int *, int); +void yyerror(char *); + +/* You may need to put /DLEX_SCANNER in your makefile + * if you're using LEX! + */ +#ifdef LEX_SCANNER +/* int yyoutput(int); */ +void yyoutput(int); +#else +void yyoutput(int); +#endif + +#if defined(__cplusplus) || defined(__STDC__) +#if defined(__cplusplus) && defined(__EXTERN_C__) +} +#endif +#endif +%} + +%union { + char *s; +/* struct pexpr *expr; */ +} + + +%start commands + +%token INTEGER 1 +%token WORD 2 +%token STRING 3 +%token PERIOD 13 +%token OPEN 4 +%token CLOSE 5 +%token COMMA 6 +%token NEWLINE 7 +%token ERROR 8 +%token OPEN_SQUARE 9 +%token CLOSE_SQUARE 10 +%token EQUALS 11 +%token EXP 14 + +/* %type command expr arglist arg arg1 */ +%type command expr arglist arg arg1 + +%% + +commands : /* empty */ + | commands command + ; + +command : WORD PERIOD + {process_command(cexpr_cons(make_word($1), NULL)); free($1);} + | expr PERIOD + {process_command($1);} + | error PERIOD + {syntax_error("Unrecognized command.");} + ; + +expr : WORD OPEN arglist CLOSE + {$$ = cexpr_cons(make_word($1), $3); free($1);} + | OPEN_SQUARE CLOSE_SQUARE + {$$ = cexpr_cons(NULL, NULL);} + | OPEN_SQUARE arglist CLOSE_SQUARE + {$$ = $2; } + ; + +arglist : + {$$ = NULL;} + | arg + {$$ = cexpr_cons($1, NULL);} + | + arg COMMA arglist + {$$ = cexpr_cons($1, $3);} + ; + +arg : WORD EQUALS arg1 + {$$ = cexpr_cons(make_word("="), cexpr_cons(make_word($1), cexpr_cons($3, NULL))); + free($1); } + | arg1 + {$$ = $1; } + +arg1 : WORD + {$$ = make_word($1); free($1);} + | STRING + {$$ = make_string($1); free($1);} + | INTEGER + {$$ = make_integer($1); free($1);} + | INTEGER PERIOD INTEGER + {$$ = make_real($1, $3); free($1); free($3); } + | INTEGER EXP INTEGER + {$$ = make_exp($1, $3); free($1); free($3); } + | + INTEGER PERIOD INTEGER EXP INTEGER + {$$ = make_exp2($1, $3, $5); free($1); free($3); + free($5); } + + | expr + {$$ = $1;} + ; + +%% + +#include "lex_yy.c" + +/* +void yyerror(s) +char *s; +{ + syntax_error(s); +} +*/ + +/* Ansi prototype. If this doesn't work for you... uncomment + the above instead. + */ + +void yyerror(char *s) +{ + syntax_error(s); +} + +/* + * Unfortunately, my DOS version of FLEX + * requires yywrap to be #def'ed, whereas + * the UNIX flex expects a proper function. + */ + +/* Not sure if __SC__ is the appropriate thing + * to test + */ + +#ifndef __SC__ +#ifdef USE_DEFINE +#ifndef yywrap +#define yywrap() 1 +#endif +#else if !defined(__alpha) && !defined(__ultrix) +int yywrap() { return 1; } +#endif +#endif diff --git a/CExpr/old/Y_TAB.C b/CExpr/old/Y_TAB.C new file mode 100644 index 0000000..03f7726 --- /dev/null +++ b/CExpr/old/Y_TAB.C @@ -0,0 +1,516 @@ +#ifndef lint +static char yysccsid[] = "@(#)yaccpar 1.7 (Berkeley) 09/09/90"; +#endif +#define YYBYACC 1 +#line 2 "parser.y" +#include "string.h" +#include "expr.h" + +#ifndef __EXTERN_C__ +#define __EXTERN_C__ 1 +#endif + +#if defined(__cplusplus) || defined(__STDC__) +#if defined(__cplusplus) && defined(__EXTERN_C__) +extern "C" { +#endif +#endif +int yylex(void); +int yylook(void); +int yywrap(void); +int yyback(int *, int); + +/* You may need to put /DLEX_SCANNER in your makefile + * if you're using LEX! + */ +#ifdef LEX_SCANNER +/* int yyoutput(int); */ +void yyoutput(int); +#else +void yyoutput(int); +#endif + +#if defined(__cplusplus) || defined(__STDC__) +#if defined(__cplusplus) && defined(__EXTERN_C__) +} +#endif +#endif +#line 36 "parser.y" +typedef union { + char *s; +/* struct pexpr *expr; */ +} YYSTYPE; +#line 44 "y_tab.c" +#define INTEGER 1 +#define WORD 2 +#define STRING 3 +#define PERIOD 13 +#define OPEN 4 +#define CLOSE 5 +#define COMMA 6 +#define NEWLINE 7 +#define ERROR 8 +#define OPEN_SQUARE 9 +#define CLOSE_SQUARE 10 +#define EQUALS 11 +#define EXP 14 +#define YYERRCODE 256 +short yylhs[] = { -1, + 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, + 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, +}; +short yylen[] = { 2, + 0, 2, 2, 2, 2, 4, 2, 3, 0, 1, + 3, 3, 1, 1, 1, 1, 3, 3, 5, 1, +}; +short yydefred[] = { 1, + 0, 0, 0, 0, 2, 0, 5, 3, 0, 0, + 0, 15, 7, 20, 0, 0, 13, 4, 0, 0, + 0, 0, 8, 0, 6, 0, 18, 0, 12, 11, + 0, 19, +}; +short yydgoto[] = { 1, + 5, 14, 15, 16, 17, +}; +short yysindex[] = { 0, + -2, 9, 2, 1, 0, 10, 0, 0, 11, -5, + 17, 0, 0, 0, 14, -1, 0, 0, 33, 38, + 41, 16, 0, 11, 0, 29, 0, 40, 0, 0, + 44, 0, +}; +short yyrindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 42, 21, + 24, 0, 0, 0, 0, 30, 0, 0, 0, 0, + 0, 0, 0, 31, 0, 27, 0, 24, 0, 0, + 0, 0, +}; +short yygindex[] = { 0, + 0, 45, -8, 0, 26, +}; +#define YYTABLESIZE 254 +short yytable[] = { 3, + 19, 10, 11, 12, 24, 9, 4, 20, 21, 4, + 13, 10, 11, 12, 8, 30, 10, 28, 12, 4, + 9, 7, 18, 23, 4, 16, 16, 22, 14, 14, + 16, 17, 17, 14, 10, 9, 17, 25, 26, 10, + 9, 27, 31, 9, 32, 6, 9, 29, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2, +}; +short yycheck[] = { 2, + 9, 1, 2, 3, 6, 4, 9, 13, 14, 9, + 10, 1, 2, 3, 13, 24, 1, 2, 3, 9, + 4, 13, 13, 10, 9, 5, 6, 11, 5, 6, + 10, 5, 6, 10, 5, 5, 10, 5, 1, 10, + 10, 1, 14, 4, 1, 1, 5, 22, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 256, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 14 +#if YYDEBUG +char *yyname[] = { +"end-of-file","INTEGER","WORD","STRING","OPEN","CLOSE","COMMA","NEWLINE", +"ERROR","OPEN_SQUARE","CLOSE_SQUARE","EQUALS",0,"PERIOD","EXP", +}; +char *yyrule[] = { +"$accept : commands", +"commands :", +"commands : commands command", +"command : WORD PERIOD", +"command : expr PERIOD", +"command : error PERIOD", +"expr : WORD OPEN arglist CLOSE", +"expr : OPEN_SQUARE CLOSE_SQUARE", +"expr : OPEN_SQUARE arglist CLOSE_SQUARE", +"arglist :", +"arglist : arg", +"arglist : arg COMMA arglist", +"arg : WORD EQUALS arg1", +"arg : arg1", +"arg1 : WORD", +"arg1 : STRING", +"arg1 : INTEGER", +"arg1 : INTEGER PERIOD INTEGER", +"arg1 : INTEGER EXP INTEGER", +"arg1 : INTEGER PERIOD INTEGER EXP INTEGER", +"arg1 : expr", +}; +#endif +#define yyclearin (yychar=(-1)) +#define yyerrok (yyerrflag=0) +#ifdef YYSTACKSIZE +#ifndef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#endif +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 600 +#define YYMAXDEPTH 600 +#endif +#endif +int yydebug; +int yynerrs; +int yyerrflag; +int yychar; +short *yyssp; +YYSTYPE *yyvsp; +YYSTYPE yyval; +YYSTYPE yylval; +short yyss[YYSTACKSIZE]; +YYSTYPE yyvs[YYSTACKSIZE]; +#define yystacksize YYSTACKSIZE +#line 118 "parser.y" + +#include "lex_yy.c" + +/* +void yyerror(s) +char *s; +{ + syntax_error(s); +} +*/ + +/* Ansi prototype. If this doesn't work for you... uncomment + the above instead. + */ + +void yyerror(char *s) +{ + syntax_error(s); +} + +/* + * Unfortunately, my DOS version of FLEX + * requires yywrap to be #def'ed, whereas + * the UNIX flex expects a proper function. + */ + +/* Not sure if __SC__ is the appropriate thing + * to test + */ + +#ifndef __SC__ +#ifdef USE_DEFINE +#ifndef yywrap +#define yywrap() 1 +#endif +#else +int yywrap() { return 1; } +#endif +#endif +#line 247 "y_tab.c" +#define YYABORT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +int +yyparse() +{ + register int yym, yyn, yystate; +#if YYDEBUG + register char *yys; + extern char *getenv(); + + if (yys = getenv("YYDEBUG")) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } +#endif + + yynerrs = 0; + yyerrflag = 0; + yychar = (-1); + + yyssp = yyss; + yyvsp = yyvs; + *yyssp = yystate = 0; + +yyloop: + if (yyn = yydefred[yystate]) goto yyreduce; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("yydebug: state %d, reading %d (%s)\n", yystate, + yychar, yys); + } +#endif + } + if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { +#if YYDEBUG + if (yydebug) + printf("yydebug: state %d, shifting to state %d\n", + yystate, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + yychar = (-1); + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; +#ifdef lint + goto yynewerror; +#endif +yynewerror: + yyerror("syntax error"); +#ifdef lint + goto yyerrlab; +#endif +yyerrlab: + ++yynerrs; +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("yydebug: state %d, error recovery shifting\ + to state %d\n", *yyssp, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("yydebug: error recovery discarding state %d\n", + *yyssp); +#endif + if (yyssp <= yyss) goto yyabort; + --yyssp; + --yyvsp; + } + } + } + else + { + if (yychar == 0) goto yyabort; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("yydebug: state %d, error recovery discards token %d (%s)\n", + yystate, yychar, yys); + } +#endif + yychar = (-1); + goto yyloop; + } +yyreduce: +#if YYDEBUG + if (yydebug) + printf("yydebug: state %d, reducing by rule %d (%s)\n", + yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + yyval = yyvsp[1-yym]; + switch (yyn) + { +case 3: +#line 68 "parser.y" +{process_command(cexpr_cons(make_word(yyvsp[-1].s), NULL)); free(yyvsp[-1].s);} +break; +case 4: +#line 70 "parser.y" +{process_command(yyvsp[-1].s);} +break; +case 5: +#line 72 "parser.y" +{syntax_error("Unrecognized command.");} +break; +case 6: +#line 76 "parser.y" +{yyval.s = cexpr_cons(make_word(yyvsp[-3].s), yyvsp[-1].s); free(yyvsp[-3].s);} +break; +case 7: +#line 78 "parser.y" +{yyval.s = cexpr_cons(NULL, NULL);} +break; +case 8: +#line 80 "parser.y" +{yyval.s = yyvsp[-1].s; } +break; +case 9: +#line 84 "parser.y" +{yyval.s = NULL;} +break; +case 10: +#line 86 "parser.y" +{yyval.s = cexpr_cons(yyvsp[0].s, NULL);} +break; +case 11: +#line 89 "parser.y" +{yyval.s = cexpr_cons(yyvsp[-2].s, yyvsp[0].s);} +break; +case 12: +#line 93 "parser.y" +{yyval.s = cexpr_cons(make_word("="), cexpr_cons(make_word(yyvsp[-2].s), cexpr_cons(yyvsp[0].s, NULL))); + free(yyvsp[-2].s); } +break; +case 13: +#line 96 "parser.y" +{yyval.s = yyvsp[0].s; } +break; +case 14: +#line 99 "parser.y" +{yyval.s = make_word(yyvsp[0].s); free(yyvsp[0].s);} +break; +case 15: +#line 101 "parser.y" +{yyval.s = make_string(yyvsp[0].s); free(yyvsp[0].s);} +break; +case 16: +#line 103 "parser.y" +{yyval.s = make_integer(yyvsp[0].s); free(yyvsp[0].s);} +break; +case 17: +#line 105 "parser.y" +{yyval.s = make_real(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); } +break; +case 18: +#line 107 "parser.y" +{yyval.s = make_exp(yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-2].s); free(yyvsp[0].s); } +break; +case 19: +#line 110 "parser.y" +{yyval.s = make_exp2(yyvsp[-4].s, yyvsp[-2].s, yyvsp[0].s); free(yyvsp[-4].s); free(yyvsp[-2].s); + free(yyvsp[0].s); } +break; +case 20: +#line 114 "parser.y" +{yyval.s = yyvsp[0].s;} +break; +#line 461 "y_tab.c" + } + yyssp -= yym; + yystate = *yyssp; + yyvsp -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("yydebug: after reduction, shifting from state 0 to\ + state %d\n", YYFINAL); +#endif + yystate = YYFINAL; + *++yyssp = YYFINAL; + *++yyvsp = yyval; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("yydebug: state %d, reading %d (%s)\n", + YYFINAL, yychar, yys); + } +#endif + } + if (yychar == 0) goto yyaccept; + goto yyloop; + } + if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("yydebug: after reduction, shifting from state %d \ +to state %d\n", *yyssp, yystate); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate; + *++yyvsp = yyval; + goto yyloop; +yyoverflow: + yyerror("yacc stack overflow"); +yyabort: + return (1); +yyaccept: + return (0); +}