Initial commit

This commit is contained in:
Keith Winstein
2010-12-28 18:05:50 -05:00
commit 52f527891c
7 changed files with 160 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
source = parse.cpp parserstate.cpp
objects = parserstate.o
executables = parse
CPP = g++
CPPFLAGS = -g --std=c++0x -pedantic -Werror -Wall -Wextra -Weffc++ -fno-implicit-templates -pipe -D_FILE_OFFSET_BITS=64 -D_XOPEN_SOURCE=500 -D_GNU_SOURCE
LIBS =
all: $(executables)
parse: parse.o $(objects)
$(CPP) $(CPPFLAGS) -o $@ $+ $(LIBS)
%.o: %.cpp
$(CPP) $(CPPFLAGS) -c -o $@ $<
include depend
depend: $(source)
$(CPP) $(INCLUDES) -MM $(source) > depend
.PHONY: clean
clean:
-rm -f $(executables) depend *.o *.rpo
+8
View File
@@ -0,0 +1,8 @@
#include "parser.hpp"
int main( void )
{
Parser::Parser parser;
return 0;
}
+24
View File
@@ -0,0 +1,24 @@
#ifndef PARSE_HPP
#define PARSE_HPP
#include <wchar.h>
#include "parsertransition.hpp"
#include "parseraction.hpp"
#include "parserstate.hpp"
namespace Parser {
class Parser {
private:
State *state;
public:
Parser() : state( NULL ) {}
Parser( const Parser & );
bool operator=( const Parser & );
void input( wchar_t c ); /* should return list of actions */
~Parser() {}
};
}
#endif
+27
View File
@@ -0,0 +1,27 @@
#ifndef PARSERACTION_HPP
#define PARSERACTION_HPP
namespace Parser {
class Action
{
public:
virtual ~Action();
};
class Ignore : public Action {};
class Print : public Action {};
class Execute : public Action {};
class Clear : public Action {};
class Collect : public Action {};
class Param : public Action {};
class ESC_Dispatch : public Action {};
class CSI_Dispatch : public Action {};
class Hook : public Action {};
class Put : public Action {};
class Unhook : public Action {};
class OSC_Start : public Action {};
class OSC_Put : public Action {};
class OSC_End : public Action {};
}
#endif
+1
View File
@@ -0,0 +1 @@
#include "parserstate.hpp"
+42
View File
@@ -0,0 +1,42 @@
#ifndef PARSERSTATE_HPP
#define PARSERSTATE_HPP
#include "parsertransition.hpp"
namespace Parser {
class State
{
private:
virtual Action enter( void ) { return Ignore(); };
virtual Action leave( void ) { return Ignore(); };
virtual Transition input( wchar_t ch __attribute__ ((unused)) ) {
return IgnoreTransition();
}
static Transition anywhere( wchar_t ch );
public:
virtual ~State();
};
class Ground : public State {};
class Esc : public State {};
class Esc_Intermediate : public State {};
class CSI_Entry : public State {};
class CSI_Param : public State {};
class CSI_Intermediate : public State {};
class CSI_Ignore : public State {};
class DCS_Entry : public State {};
class DCS_Param : public State {};
class DCS_Intermediate : public State {};
class DCS_Passthrough : public State {};
class DCS_Ignore : public State {};
class OCS_String : public State {};
class SOS_PM_APC_String : public State {};
}
#endif
+34
View File
@@ -0,0 +1,34 @@
#ifndef PARSERTRANSITION_HPP
#define PARSERTRANSITION_HPP
#include <stdlib.h>
#include "parseraction.hpp"
class State;
namespace Parser {
class Transition
{
public:
Action action;
State *next_state;
Transition();
Transition( const Transition & );
bool operator=( const Transition & );
virtual ~Transition();
};
class IgnoreTransition : public Transition
{
public:
IgnoreTransition()
{
action = Ignore();
next_state = NULL;
}
};
}
#endif