Permalink
Browse files

merged with 1.1

  • Loading branch information...
1 parent 3d14756 commit 6adb1fe19ad2a95b947be78d34554331f6445005 d00mas committed Nov 30, 2003
View
@@ -1 +1,2 @@
Manuel Astudillo <d00mas@efd.lth.se>
+Pablo Garcia Gonzalez <pgarcia@web.de>
View
13 INSTALL
@@ -2,23 +2,30 @@
UNIX Instructions
-----------------
-i) On Linux and FreeBSD
+i) On GCC based environments
Be sure that you have a gcc version >= 3.0.
You will also need GNU make.
-then type: make -f gcc-linux.mak
+then type: make -f Makefile.gcc
And it will compile the library in directory ./lib
ii) On HPUX
-type: make -f acc-hpux.mak
+type: make -f Makefile.acc
the compiled library will be created on ./lib
+The examples contained in ./examples can be
+compiled separately in the same way as the
+library.
WINDOWS
-------
Go to the projfiles directory and load the desired
Visual Studio project.
+Add in the tools->directories>include the path to the
+include directory in the cpp-gpengine directory.
+
+Project files are also provided for the examples.
File renamed without changes.
@@ -1,7 +1,7 @@
# Project: cpp-gpengine
# Makefile created by Pablo Garcia Ganzalez
# Date: 19.10.2003
-# CVS-ID: $Id: gcc-linux.mak,v 1.3 2003/11/07 00:18:23 xtremox Exp $
+# CVS-ID: $Id: Makefile.gcc,v 1.1.2.1 2003/11/30 12:55:29 d00mas Exp $
CPP = g++
OBJ = src/ASTCreator.o src/ASTNode.o src/CGTFile.o src/CharacterSetTable.o src/DFA.o src/DFAStateTable.o src/ErrorReporter.o src/ErrorTable.o src/GrammarInfo.o src/LALR.o src/LALRStateTable.o src/NonTerminal.o src/RuleTable.o src/Symbol.o src/SymbolTable.o src/Terminal.o src/Token.o
View
30 README
@@ -1,30 +0,0 @@
-
- Gold Parser Engine (c) 2002 Manuel Astudillo
- --------------------------------------------
-
- This is a C++ implementation of the gold parser
- engine.
- At this moment the only documentation available
- are the sources and a simple test program.
-
- Project files for .NET and VC6 are provided, and the
- sources can be compiled under linux without any problems,
- but complete Makefiles are not provided yet.
-
- The use is though pretty simple and looking at the
- sources should be enought to understand how it works.
-
- For any questions e-mail me at:
-
- d00mas@efd.lth.se
-
-
- Check my webpage for this and other projects:
-
- www.efd.lth.se/~d00mas/
-
-
- 26th June 2002,
-
- Manuel Astudillo.
-
View
@@ -1,6 +1,13 @@
History
-------
+version 1.0.6 2003/11/29
+------------------------
++ Added 3 examples to show how to use the engine.
++ Exchange a lot of wchar_t* strings to the more reliable wstring
+- Fixed a buffer overflow bug in the DFA
+- A few more clean ups
+
version 1.0.4 2003/11/11
------------------------
+ UNIX support. The engine compiles and runs on UNIX-based operating
File renamed without changes.
File renamed without changes.
View
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
// If there are errors report them
if (myErrors->errors.size() > 0) {
- for (int i=0; i < myErrors->errors.size(); i++) {
+ for (unsigned int i=0; i < myErrors->errors.size(); i++) {
cout << filename << ":";
cout << myReporter.composeErrorMsg (*myErrors->errors[i]) << endl;
}
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
myErrors = lalr->getErrors();
if (myErrors->errors.size() != 0) {
- for (int i=0; i < myErrors->errors.size(); i++) {
+ for (unsigned int i=0; i < myErrors->errors.size(); i++) {
cout << filename << ":";
cout << myReporter.composeErrorMsg (*myErrors->errors[i]) << endl;
}
View
@@ -1,6 +1,6 @@
<?xml version="1.0" standalone="no"?>
<svg width="5cm" height="4cm"
- xmlns="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg">
<desc>Four separate rectangles
</desc>
<rect x="0.5cm" y="0.5cm" width="2cm" height="1cm"/>
File renamed without changes.
@@ -0,0 +1,26 @@
+# Project: cpp-gpengine
+# Makefile created by Pablo Garcia Gonzalez
+# Date: 11.11.2003
+
+CPP = g++
+OBJ = logic.o LogicASTCreator.o
+LIBS = -L"/usr/lib" -L"../../lib" ../../lib/cpp-gpengine-1.0.4.a
+CXXINCS = -I"../../include/" -I"/usr/include"
+BIN = logic
+CXXFLAGS = $(CXXINCS)
+
+all: logic
+
+clean:
+ rm -f $(OBJ) $(BIN)
+
+$(BIN): $(OBJ)
+ $(CPP) $(OBJ) -o "logic" $(LIBS)
+
+logic.o: logic.cpp
+ $(CPP) -c -Wall logic.cpp -o logic.o $(CXXFLAGS)
+
+LogicASTCreator.o: LogicASTCreator.cpp
+ $(CPP) -c -Wall LogicASTCreator.cpp -o LogicASTCreator.o $(CXXFLAGS)
+
+
@@ -0,0 +1,24 @@
+# Project: cpp-gpengine
+# Makefile created by Pablo Garcia Ganzalez
+# Date: 10.11.2003
+
+CPP = aCC
+OBJ = simple.o
+GPENGINELIB = ../../lib/cpp-gpengine-1.0.4.sl
+LIBS = -L"../../lib"
+CXXINCS = -I"../../include/" -I"/usr/include"
+BIN = simple
+CXXFLAGS = -AA -D_XOPEN_SOURCE=500 $(CXXINCS)
+
+all: simple
+
+clean:
+ rm -f $(OBJ) $(BIN)
+
+$(BIN): $(OBJ)
+ $(CPP) $(OBJ) $(GPENGINELIB) -AA -o "simple" $(LIBS)
+
+simple.o: simple.cpp
+ $(CPP) -c simple.cpp -o simple.o $(CXXFLAGS)
+
+
File renamed without changes.
View
@@ -1,11 +1,11 @@
/***************************************************************************
- simple.cpp
+ simple.cpp
-------------------
begin : Fri May 31 00:53:11 CEST 2002
copyright : (C) 2002-2003 by Manuel Astudillo
email : d00mas@efd.lth.se
***************************************************************************/
-
+
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
@@ -14,7 +14,7 @@
* License, or (at your option) any later version. *
* *
***************************************************************************/
-
+
#include <iostream>
#include <stdlib.h>
@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
SimpleErrorRep myReporter;
// Load grammar file
- if (cgtFile.load ("simple.cgt")) {
+ if (cgtFile.load ("simple.cgt")) {
wprintf (L"%s\n", "Grammar loaded succesfully");
cgtFile.printInfo ();
} else {
@@ -66,9 +66,9 @@ int main(int argc, char *argv[])
// If there are errors report them
if (myErrors->errors.size() > 0) {
- for (int i=0; i < myErrors->errors.size(); i++) {
- cout << filename << ":";
- cout << myReporter.composeErrorMsg (*myErrors->errors[i]) << endl;
+ for (unsigned int i=0; i < myErrors->errors.size(); i++) {
+ cout << filename << ":";
+ cout << myReporter.composeErrorMsg (*myErrors->errors[i]) << endl;
}
return -1;
}
@@ -85,7 +85,7 @@ int main(int argc, char *argv[])
myErrors = lalr->getErrors();
if (myErrors->errors.size() != 0) {
- for (int i=0; i < myErrors->errors.size(); i++) {
+ for (unsigned int i=0; i < myErrors->errors.size(); i++) {
cout << filename << ":";
cout << myReporter.composeErrorMsg (*myErrors->errors[i]) << endl;
}
View
@@ -1,8 +1,8 @@
/***************************************************************************
ASTCreator.h
- This class works as a framework for the
- creation of an abstract syntax tree specific
- for a grammar
+ This class works as a framework for the
+ creation of an abstract syntax tree specific
+ for a grammar
-------------------
begin : Sun Jun 2 2002
copyright : (C) 2002 by Manuel Astudillo
@@ -27,11 +27,7 @@
using namespace std;
#if defined (WIN32) && defined (_USRDLL)
- class __declspec(dllexport) ASTCreator;
-#endif
-
-#ifndef CREATE_NODE
- #define CREATE_NODE(X,x) X *x = new X(); x->init(*reduction); x->setParent(parent);
+class __declspec(dllexport) ASTCreator;
#endif
class ASTCreator {
View
@@ -38,19 +38,19 @@
class ASTNode {
protected:
- std::wstring symbol;
- std::wstring image;
+ std::wstring m_symbol;
+ std::wstring m_image;
- unsigned short line, col;
+ ASTNode *m_parent;
+ unsigned short m_line, m_col;
std::vector <ASTNode*> children;
- ASTNode *parent;
-
+
public:
- ASTNode ();
virtual ~ASTNode ();
- void init (const Symbol &s);
+ void init (const Symbol *s, ASTNode *parent);
+
void setImage (wstring image);
void setSymbol (wstring symbol);
std::wstring getImage ();
View
@@ -55,7 +55,7 @@ class ErrorReporter {
string composeLineCol (const GPError &err);
public:
ErrorReporter ();
- ~ErrorReporter ();
+ virtual ~ErrorReporter ();
string composeErrorMsg (const GPError &err);
wstring composeErrorMsgU (const GPError &err);
View
@@ -1,8 +1,8 @@
/***************************************************************************
ASTCreator.cpp
- This class works as a framework for the
- creation of an abstract syntax tree specific
- for a grammar
+ This class works as a framework for the
+ creation of an abstract syntax tree specific
+ for a grammar
-------------------
begin : Sun Jun 2 2002
copyright : (C) 2002 by Manuel Astudillo
@@ -36,7 +36,8 @@
the nodes that are not equivalent.
*/
- vector <ASTNode*> *children = NULL;
+
+ vector <ASTNode*> *children= NULL;
wstring sym = reduction->symbol;
deque <Symbol*> rdcChildren;
@@ -65,7 +66,8 @@
<Start> ::= <ConstList> <DefsList> <StatementList>
if ( sym == L"Start" ) {
- CREATE_NODE (Start, start); // Check this macro definition for more details
+ Start *start = new Start ();
+ start->init (reduction, parent);
start->addChild (getASTNode(rdcChildren[1], start));
start->addChild (getASTNode(rdcChildren[3], start));
@@ -83,7 +85,8 @@
<StatementList> ::= <Statement>*
if (sym == L"StatementList") {
- CREATE_NODE (StatementList, statementList);
+ StatementList *statementList = new StatementList ();
+ statementList->init (reduction, parent);
if (rdcChildren.size() == 3) {
statementList->addChild (getASTNode (rdcChildren[0], stmtList));
@@ -95,32 +98,31 @@
return stmtList;
}
*/
-
/*
- If the symbol constants are included it is possible to use a switch-case
- for all the rules:
-
- switch (reduction->symbolIndex) {
+ If the symbol constants are included it is possible to do it in the possible way:
// <If Statement> ::= if <Expression> then <StatementList> end
- case RULE_IF_THEN_END_STATEMENT:
- CREATE_NODE (IfStatement, ifStmt);
+ if (sym == RULE_IF_THEN_END_STATEMENT) {
+ IfStatement *ifStatement = new IfStatement ();
+ ifStatement->init (reduction, parent);
ifStmt->addChild (getASTNode(rdcChildren[1], ifStmt));
ifStmt->addChild (getASTNode(rdcChildren[3], ifStmt));
return ifStmt;
+ }
// <If Statement> ::= if <Expression> then <StatementList> else <StatementList> end
- case RULE_IF_THEN_END_ELSE_STATEMENT:
- CREATE_NODE (IfStatement, ifStatement);
+ if ( sym == RULE_IF_THEN_END_ELSE_STATEMENT) {
+ IfStatement *ifStatement = new IfStatement ();
+ ifStatement->init (reduction, parent);
ifStmt->addChild (getASTNode(rdcChildren[1], ifStmt));
ifStmt->addChild (getASTNode(rdcChildren[3], ifStmt));
ifStmt->addChild (getASTNode(rdcChildren[5], ifStmt));
return ifStmt;
- default: return searchEquivNode( rdcChildren, parent);
- }
+ }
+
*/
Oops, something went wrong.

0 comments on commit 6adb1fe

Please sign in to comment.