Skip to content

Commit

Permalink
Adds libLexer and libParser
Browse files Browse the repository at this point in the history
  • Loading branch information
psde committed Jan 17, 2013
1 parent 0fd9ef4 commit c320390
Show file tree
Hide file tree
Showing 23 changed files with 82 additions and 65 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
codepeiler
*.sublime-workspace
*.code
bin/*
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
NAME = codepeiler
LIBRARIES = Buffer
LIBRARIES = Buffer Lexer Parser

BINARIES = $(LIBARIES:%=lib%.a) $(NAME)
BINPATHS = $(BINARIES:%=bin/%)
SRCPATHS = $(LIBRARIES:%=src/lib%/) src/$(NAME)/

all: release

.PHONY: release
.PHONY: release debug clean
release:
$(foreach project, $(SRCPATHS), $(MAKE) -C $(project) release;)
cp bin/$(NAME) .

.PHONY: debug
debug:
$(foreach project, $(SRCPATHS), $(MAKE) -C $(project) release;)
cp bin/$(NAME) .

.PHONY: clean
clean:
$(foreach project, $(SRCPATHS), $(MAKE) -C $(project) clean;)
$(foreach project, $(SRCPATHS), $(MAKE) -C $(project) clean;)
rm -f $(NAME)
24 changes: 24 additions & 0 deletions src/binary.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generic makefile
include ../common.mk
ROOT = ../..
OUTDIR = $(ROOT)/$(BINDIR)
OUTNAME= $(OUTDIR)/$(NAME)
SRCS = $(wildcard *.cpp)
OBJS = $(SRCS:.cpp=.o)
DEPS = $(OBJS:.o=.d)

release:
$(MAKE) CXXFLAGS="$(RELEASEFLAGS)" $(OUTNAME)

debug:
$(MAKE) CXXFLAGS="$(DEBUGFLAGS)" $(OUTNAME)

%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<

$(OUTNAME): $(OBJS)
$(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(LIBS)

.PHONY: clean
clean:
$(RM) $(OUTNAME) $(OBJS) $(DEPS)
28 changes: 3 additions & 25 deletions src/codepeiler/Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,6 @@
# Project config
NAME = codepeiler
LIBS = -lBuffer
LIBS = -lBuffer -lLexer -lParser

# Generic makefile
include ../common.mk
ROOT = ../..
OUTDIR = $(ROOT)/$(BINDIR)
OUTNAME= $(OUTDIR)/$(NAME)
SRCS = $(wildcard *.cpp)
OBJS = $(SRCS:.cpp=.o)
DEPS = $(OBJS:.o=.d)

release:
$(MAKE) CXXFLAGS="$(RELEASEFLAGS)" $(OUTNAME)

debug:
$(MAKE) CXXFLAGS="$(DEBUGFLAGS)" $(OUTNAME)

%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<

$(OUTNAME): $(OBJS)
$(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(LIBS)

.PHONY: clean
clean:
$(RM) $(OUTNAME) $(OBJS) $(DEPS)
# Include binary.mk
include ../binary.mk
9 changes: 4 additions & 5 deletions src/codepeiler/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
#include <libStd/String.hpp>
#include <libBuffer/BufferReader.hpp>
#include <libBuffer/BufferWriter.hpp>

#include "Token.hpp"
#include "Lexer.hpp"
#include "Symtable.hpp"
#include "Parser.hpp"
#include <libLexer/Token.hpp>
#include <libLexer/Lexer.hpp>
#include <libLexer/Symtable.hpp>
#include <libParser/Parser.hpp>

int main(int argc, char *argv[])
{
Expand Down
26 changes: 2 additions & 24 deletions src/libBuffer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,5 @@
NAME = Buffer
LIBS =

# Generic library makefile
include ../common.mk
ROOT = ../..
OUTDIR = $(ROOT)/$(BINDIR)
OUTNAME = $(OUTDIR)/lib$(NAME).a
SRCS = $(wildcard *.cpp)
OBJS = $(SRCS:.cpp=.o)
DEPS = $(OBJS:.o=.d)

release:
$(MAKE) CXXFLAGS="$(RELEASEFLAGS)" $(OUTNAME)

debug:
$(MAKE) CXXFLAGS="$(DEBUGFLAGS)" $(OUTNAME)

%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<

$(OUTNAME): $(OBJS)
ar rs $@ $(OBJS)

.PHONY: clean
clean:
$(RM) $(OUTNAME) $(OBJS) $(DEPS)
# Include library.mk
include ../library.mk
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions src/libLexer/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Project config
NAME = Lexer
LIBS =

# Include library.mk
include ../library.mk
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions src/libParser/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Project config
NAME = Parser
LIBS = -lLexer

# Include library.mk
include ../library.mk
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include <libStd/String.hpp>
#include <libStd/Vector.hpp>
#include <libLexer/Token.hpp>

#include "ParserRule.hpp"
#include "Token.hpp"

class ParseTree
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion src/codepeiler/Parser.cpp → src/libParser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#endif

#include "Parser.hpp"
#include <iostream>

Parser::Parser(Lexer *lexer)
: lexer(lexer)
Expand Down
7 changes: 4 additions & 3 deletions src/codepeiler/Parser.hpp → src/libParser/Parser.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#pragma once

#include <exception>
#include <iostream>

#include <libStd/String.hpp>
#include <libStd/List.hpp>
#include <libLexer/Token.hpp>
#include <libLexer/Lexer.hpp>
#include <libLexer/Token.hpp>

#include "ParserRule.hpp"
#include "Token.hpp"
#include "Lexer.hpp"
#include "ParseTree.hpp"
#include "Token.hpp"

class ParserError : public std::exception
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <libStd/String.hpp>
#include "Token.hpp"
#include <libLexer/Token.hpp>

struct ParserRule {
String name;
Expand Down
24 changes: 24 additions & 0 deletions src/library.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generic library makefile
include ../common.mk
ROOT = ../..
OUTDIR = $(ROOT)/$(BINDIR)
OUTNAME = $(OUTDIR)/lib$(NAME).a
SRCS = $(wildcard *.cpp)
OBJS = $(SRCS:.cpp=.o)
DEPS = $(OBJS:.o=.d)

release:
$(MAKE) CXXFLAGS="$(RELEASEFLAGS)" $(OUTNAME)

debug:
$(MAKE) CXXFLAGS="$(DEBUGFLAGS)" $(OUTNAME)

%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<

$(OUTNAME): $(OBJS)
ar rs $@ $(OBJS)

.PHONY: clean
clean:
$(RM) $(OUTNAME) $(OBJS) $(DEPS)

0 comments on commit c320390

Please sign in to comment.