From 417ea404303c365a53ab2e1db23925cb24b9b6ce Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Tue, 17 May 2005 21:18:30 +0000 Subject: [PATCH] more sane test --- Makefile | 147 ------------------------------------------------------ input.txt | 13 +++-- parser.y | 18 ++++++- src.pro | 3 +- 4 files changed, 24 insertions(+), 157 deletions(-) delete mode 100644 Makefile diff --git a/Makefile b/Makefile deleted file mode 100644 index 0e6852d..0000000 --- a/Makefile +++ /dev/null @@ -1,147 +0,0 @@ -############################################################################# -# Makefile for building: planner -# Generated by qmake (1.07a) (Qt 3.3.4) on: Mon May 9 12:42:54 2005 -# Project: src.pro -# Template: app -# Command: $(QMAKE) -o Makefile src.pro -############################################################################# - -####### Compiler, tools and options - -CC = gcc -CXX = g++ -LEX = flex -YACC = yacc -CFLAGS = -pipe -Wall -W -g -CXXFLAGS = -pipe -Wall -W -g -LEXFLAGS = -YACCFLAGS= -d -INCPATH = -I/usr/qt/3/mkspecs/linux-g++ -I. -I. -LINK = g++ -LFLAGS = -LIBS = $(SUBLIBS) -AR = ar cqs -RANLIB = -MOC = $(QTDIR)/bin/moc -UIC = $(QTDIR)/bin/uic -QMAKE = qmake -TAR = tar -cf -GZIP = gzip -9f -COPY = cp -f -COPY_FILE= $(COPY) -COPY_DIR = $(COPY) -r -INSTALL_FILE= $(COPY_FILE) -INSTALL_DIR = $(COPY_DIR) -DEL_FILE = rm -f -SYMLINK = ln -sf -DEL_DIR = rmdir -MOVE = mv -f -CHK_DIR_EXISTS= test -d -MKDIR = mkdir -p - -####### Output directory - -OBJECTS_DIR = ./ - -####### Files - -HEADERS = action.h \ - node.h \ - planner.h -SOURCES = action.cpp \ - main.cpp \ - node.cpp \ - planner.cpp -OBJECTS = action.o \ - main.o \ - node.o \ - planner.o -FORMS = -UICDECLS = -UICIMPLS = -SRCMOC = -OBJMOC = -DIST = src.pro -QMAKE_TARGET = planner -DESTDIR = -TARGET = planner - -first: all -####### Implicit rules - -.SUFFIXES: .c .o .cpp .cc .cxx .C - -.cpp.o: - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< - -.cc.o: - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< - -.cxx.o: - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< - -.C.o: - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< - -.c.o: - $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< - -####### Build rules - -all: Makefile $(TARGET) - -$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) - $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(OBJCOMP) $(LIBS) - -mocables: $(SRCMOC) -uicables: $(UICDECLS) $(UICIMPLS) - -$(MOC): - ( cd $(QTDIR)/src/moc && $(MAKE) ) - -Makefile: src.pro /usr/qt/3/mkspecs/linux-g++/qmake.conf - $(QMAKE) -o Makefile src.pro -qmake: - @$(QMAKE) -o Makefile src.pro - -dist: - @mkdir -p .tmp/planner && $(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) .tmp/planner/ && ( cd `dirname .tmp/planner` && $(TAR) planner.tar planner && $(GZIP) planner.tar ) && $(MOVE) `dirname .tmp/planner`/planner.tar.gz . && $(DEL_FILE) -r .tmp/planner - -mocclean: -uiclean: - -yaccclean: -lexclean: -clean: - -$(DEL_FILE) $(OBJECTS) - -$(DEL_FILE) *~ core *.core - - -####### Sub-libraries - -distclean: clean - -$(DEL_FILE) $(TARGET) $(TARGET) - - -FORCE: - -####### Compile - -action.o: action.cpp action.h - -main.o: main.cpp planner.h \ - action.h - -node.o: node.cpp node.h \ - action.h - -planner.o: planner.cpp planner.h \ - node.h \ - action.h - -####### Install - -install: - -uninstall: - diff --git a/input.txt b/input.txt index f54b31a..96e8683 100644 --- a/input.txt +++ b/input.txt @@ -1,17 +1,16 @@ # kommenatar apache -a, b, ?c, d, e +NET httpd.sh -1: q, w, r, t, y # kommentar +0: HTPPD # kommentar # # fds sfd #32 #dasdssad -test -b, ce, de, ee -"testar.sh -foo bar" -99: uu, ve # kommentar -88: uu +eth0 +"" +"ifconfig up eth0" +0: NET # kommentar diff --git a/parser.y b/parser.y index d39a88a..663442a 100644 --- a/parser.y +++ b/parser.y @@ -8,6 +8,7 @@ #include #include "action.h" + #include "planner.h" using namespace std; @@ -55,7 +56,7 @@ action : id preconds '\n' exec effects '\n' { cout << "id: " << *$1 << endl; // Precondition flags: - cout << "a: " << (*$2)["a"] << endl; + cout << "a: " << (*$2)["NET"] << endl; cout << "b: " << (*$2)["b"] << endl; cout << "c: " << (*$2)["c"] << endl; cout << "d: " << (*$2)["d"] << endl; @@ -64,7 +65,7 @@ action : id preconds '\n' exec effects '\n' { cout << "exe: " << *$4 << endl; // Print number of effects - cout << "1: " << (*$5)[1].size() << endl; + cout << "1: " << (*$5)[0].size() << endl; cout << "99: " << (*$5)[99].size() << endl; cout << "88: " << (*$5)[88].size() << endl; @@ -195,6 +196,16 @@ yyerror (char const *s) cerr << "Parse error : " << s; } +vector stringToVector(string str){ + vector strings; + + istringstream ist(str); + while (ist >> str){ + strings.push_back(str); + } + + return strings; +} int main (int argc, char** argv) @@ -219,4 +230,7 @@ main (int argc, char** argv) actions = new vector(); yyparse(); + + Planner p(*actions, stringToVector(argv[2]), stringToVector(argv[3])); + p.execute(); } diff --git a/src.pro b/src.pro index e8c02b9..67eb5f7 100644 --- a/src.pro +++ b/src.pro @@ -11,4 +11,5 @@ TARGET = planner # Input HEADERS += action.h node.h planner.h -SOURCES += action.cpp main.cpp node.cpp planner.cpp +SOURCES += action.cpp node.cpp planner.cpp +YACCSOURCES += parser.y -- 2.39.2