-Subproject commit 73e512953c2ed551b6ac9d5e33ffa37d27b6e24e
+Subproject commit 2fc4293edf8a695e0de35ac875753db7b7308b2d
# Id
foo = bar
-foo.bar = bar
+#foo.bar = bar
# Map
-foo = {
- $foo : 1 + 1,
- $bar : 2 + 2,
- $stuff : 3 + 3
-}
+#foo = {
+# $foo : 1 + 1,
+# $bar : 2 + 2,
+# $stuff : 3 + 3
+#}
# Vector
foo = []
if (1==1)
{
- 1 + 1
+ print(1 + 1)
}{
-
+ print(2 + 2)
}
if (1 == 1)
{
-
+ print(1 + 1)
}
#------------------------------------------------------------------------------
# Delayed Evaluation
#------------------------------------------------------------------------------
-% delay [ (Expression) : make_promise({ $1 }) ]
-% force [ (Expression) : $1 ]
-
-foo = delay 1 + 1
-foo = force foo
+#% delay [
+# (Expression) : make_promise({ $1 })
+#]
+#
+#% force [
+# (Expression) : $1
+#]
+#
+#foo = delay 1 + 1
+#foo = force foo
{ '.', MEMB },
};
+DLLexer::DLLexer(std::istream& in) : ILexer(in)
+{
+}
+
bool DLLexer::isWhiteSpace(void)
{
return (current == ' ') ||
Token DLLexer::next(void)
{
Token ret;
- while ( (!input->eof()) && (ret.type() == EOF) )
+ while ( !eof() && (ret.type() == EOF) )
{
if (isWhiteSpace())
{
class DLLexer : public ILexer {
public:
+ DLLexer(std::istream& in);
bool isWhiteSpace(void);
bool isLetter(void);
bool isDigit(void);
#include "exception.h"
#include "common.h"
-DLParser::DLParser() : BTParser(_new DLLexer())
+DLParser::DLParser() : BTParser()
{
pattern_types.insert( std::pair<std::string,PatternType_T>( "Map", MAP_TYP ));
pattern_types.insert( std::pair<std::string,PatternType_T>( "Vector", VECT_TYP ));
{
}
-AST* DLParser::parse(void)
+void DLParser::parse(void)
{
- return Program();
+ result = Program();
}
bool DLParser::isMacro( Token& token )
public:
DLParser();
~DLParser();
- AST* parse(void);
+ void parse(void);
bool isMacro(Token& token);
bool speculate_GroupExpr(void);
bool speculate_MapLiteral(void);
#include <sstream>
#include <fstream>
#include "dlparser.h"
-#include "astprinter.h"
#include "scheme.h"
#include "common.h"
#include "macro.h"
{
string input_fname(argv[1]);
string temp_fname = createTempFileName( input_fname );
+ ifstream input(input_fname.c_str());
DLParser parser;
- ASTPrinter* visitor = NULL;
+ Scheme printer;
+ parser.input(new DLLexer(input));
+ parser.parse();
+ parser.process( printer );
- // Open the input and output files
- ifstream input(input_fname.c_str());
+ //string input_fname(argv[1]);
+ //string temp_fname = createTempFileName( input_fname );
+ //ASTPrinter* visitor = NULL;
- // Parse the file
- parser.setInput(&input);
+ //// Open the input and output files
+ //ifstream input(input_fname.c_str());
- // Translate the AST
- visitor = _new ASTPrinter( parser.parse() );
- visitor->visit();
+ //// Parse the file
+ //parser.setInput(&input);
- // Write output to screen
- cout << visitor->str();
+ //// Translate the AST
+ //visitor = _new ASTPrinter( parser.parse() );
+ //visitor->visit();
- delete visitor;
+ //// Write output to screen
+ //cout << visitor->str();
}
else
{
using namespace std;
-Scheme::Scheme(AST* root) : IVisitor(root) {
+Scheme::Scheme() : IVisitor() {
ifstream input("res/environment.scm");
if (input.is_open())
{
{
string line;
getline(input,line);
- stream << line << endl;
+ cout << line << endl;
}
}
input.close();
}
-string Scheme::str()
-{
- return stream.str();
-}
-
string Scheme::typeToString(ASTNodeType type)
{
ostringstream ret;
void Scheme::afterVisit(AST* cur, int depth)
{
- stream << endl;
+ cout << endl;
}
void Scheme::beforeChildren(AST* cur, int depth)
}
else
{
- stream << "(" << typeToString( cur->type() ) << cur->text();
+ cout << "(" << typeToString( cur->type() ) << cur->text();
}
}
{
if( !isDatatype( cur->type() ) )
{
- stream << ")";
+ cout << ")";
}
}
void Scheme::beforeChild(AST* cur, int depth)
{
- stream << endl;
+ cout << endl;
for(int i = 0; i< depth; i++)
{
- stream << " ";
+ cout << " ";
}
}
switch(cur->type())
{
case ID:
- stream << "dl/" << cur->text();
+ cout << "dl/" << cur->text();
break;
case NUM:
- stream << cur->text();
+ cout << cur->text();
break;
case CHAR:
charToString( cur->text() );
break;
case STRING:
- stream << '"' << cur->text() << '"';
+ cout << '"' << cur->text() << '"';
break;
case SYMBOL:
- stream << '\'' << cur->text();
+ cout << '\'' << cur->text();
break;
default:
break;
switch(ch.at(0))
{
case ' ':
- stream << "#\\space";
+ cout << "#\\space";
break;
case '\n':
- stream << "#\\newline";
+ cout << "#\\newline";
break;
case '\r':
- stream << "#\\return";
+ cout << "#\\return";
break;
default:
- stream << "#\\" << ch;
+ cout << "#\\" << ch;
}
}
#include "dllexer.h"
class Scheme : public IVisitor {
- protected:
- ostringstream stream;
public:
- Scheme(AST* root);
- string str();
+ Scheme();
string typeToString(ASTNodeType type);
bool isDatatype(ASTNodeType type);
void printDatatype(AST* cur);