Initial commit

This commit is contained in:
Max Brunsfeld 2013-11-05 22:15:19 -08:00
commit 84c5bceb81
12 changed files with 968 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
spec/run.out*
TreeSitter.xcodeproj/project.xcworkspace
TreeSitter.xcodeproj/xcuserdata

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "spec/externals/igloo"]
path = spec/externals/igloo
url = https://github.com/joakimkarlsson/igloo.git

10
.vimrc Normal file
View file

@ -0,0 +1,10 @@
set wildignore+=spec/externals
set wildignore+=TreeSitter.xcodeproj/*
set shiftwidth=4
set softtabstop=4
set tabstop=4
let g:syntastic_cpp_compiler = 'clang'
let g:syntastic_cpp_auto_refresh_includes = 1
let g:syntastic_cpp_include_dirs = [ './core/include', './spec/externals/igloo', './spec', './src' ]
let g:syntastic_cpp_compiler_options = '-std=gnu99 -fnested-functions -DRUBY_MISSING_H'

55
Makefile Normal file
View file

@ -0,0 +1,55 @@
.PHONY: all clean install install-dev test test-c test-scm valgrind
### install configuration ###
CPP = c++
RM ?= rm -f
INSTALL ?= install
MKDIR ?= $(INSTALL) -d
SYMLINK ?= ln -s
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
LIBDIR ?= $(PREFIX)/lib
SOLIBDIR ?= $(PREFIX)/lib
INCDIR ?= $(PREFIX)/include
MODDIR ?= $(PREFIX)/share
BINMODDIR ?= $(PREFIX)/lib
MANDIR ?= $(PREFIX)/share/man/man1
### library configuration ###
LIB_NAME = tree_sitter
DIR = $(shell pwd)
HEADERS = $(wildcard include/*.h)
SOURCES = $(wildcard src/*.cpp)
TESTS = $(wildcard spec/*.cpp)
OBJECTS = $(foreach file, $(C_SOURCES), $(basename $(file)).o)
LIB_FILE = lib$(LIB_NAME)$(SO)
TEST_BIN = spec/run.out
### build configuration ###
CFLAGS ?= -Wall -std=c++11 -stdlib=libc++ -g -m64
### targets ###
all: $(LIB_FILE)
src/%.o: src/%.cpp
$(CPP) $(CFLAGS) -c $< -o $@
test: $(TEST_BIN)
./$<
$(TEST_BIN): $(TESTS) $(SOURCES)
$(CPP) $(CFLAGS) -Ispec/externals/igloo -Isrc -L. $^ -o $@
# $(TEST_BIN): $(LIB_FILE) $(C_TESTS)
# $(CPP) $(CFLAGS) -Ispec/externals/igloo -Isrc -L. -l$(LIB_NAME) test/c/_runner.cc -o $@
debug: $(TEST_BIN)
gdb $<
valgrind: $(TEST_BIN)
valgrind --track-origins=yes $(TEST_BIN)
clean:
$(RM) $(OBJECTS) $(LIB_FILE) $(TEST_BIN)

View file

@ -0,0 +1,556 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
1214930E181E200B008E9BDA /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 121492E9181E200B008E9BDA /* main.cpp */; };
1214930F181E200B008E9BDA /* rules_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 121492EA181E200B008E9BDA /* rules_spec.cpp */; };
12E71853181D081C0051A649 /* rule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12E71851181D081C0051A649 /* rule.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
12E71792181D02A80051A649 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
121306011829FAED00FCF928 /* spec_helper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = spec_helper.h; sourceTree = SOURCE_ROOT; };
12149265181E200B008E9BDA /* igloo-tests_CXX_prefix.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = "igloo-tests_CXX_prefix.hxx"; sourceTree = "<group>"; };
12149266181E200B008E9BDA /* igloo-tests_CXX_prefix.hxx.gch */ = {isa = PBXFileReference; lastKnownFileType = file; path = "igloo-tests_CXX_prefix.hxx.gch"; sourceTree = "<group>"; };
12149267181E200B008E9BDA /* snowhouse-tests_CXX_prefix.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = "snowhouse-tests_CXX_prefix.hxx"; sourceTree = "<group>"; };
12149268181E200B008E9BDA /* snowhouse-tests_CXX_prefix.hxx.gch */ = {isa = PBXFileReference; lastKnownFileType = file; path = "snowhouse-tests_CXX_prefix.hxx.gch"; sourceTree = "<group>"; };
1214926B181E200B008E9BDA /* alternativeregistrationaliases.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = alternativeregistrationaliases.h; sourceTree = "<group>"; };
1214926C181E200B008E9BDA /* context.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = context.h; sourceTree = "<group>"; };
1214926D181E200B008E9BDA /* contextbase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = contextbase.h; sourceTree = "<group>"; };
1214926E181E200B008E9BDA /* contextprovider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = contextprovider.h; sourceTree = "<group>"; };
1214926F181E200B008E9BDA /* contextregistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = contextregistry.h; sourceTree = "<group>"; };
12149270181E200B008E9BDA /* contextrunner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = contextrunner.h; sourceTree = "<group>"; };
12149271181E200B008E9BDA /* core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = core.h; sourceTree = "<group>"; };
12149272181E200B008E9BDA /* defaultregistrationaliases.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = defaultregistrationaliases.h; sourceTree = "<group>"; };
12149274181E200B008E9BDA /* coloredconsoletestresultsoutput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = coloredconsoletestresultsoutput.h; sourceTree = "<group>"; };
12149275181E200B008E9BDA /* consoleoutputcolors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = consoleoutputcolors.h; sourceTree = "<group>"; };
12149276181E200B008E9BDA /* defaulttestresultsoutput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = defaulttestresultsoutput.h; sourceTree = "<group>"; };
12149277181E200B008E9BDA /* outputters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = outputters.h; sourceTree = "<group>"; };
12149278181E200B008E9BDA /* testresultsoutput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testresultsoutput.h; sourceTree = "<group>"; };
12149279181E200B008E9BDA /* visualstudiooutput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = visualstudiooutput.h; sourceTree = "<group>"; };
1214927A181E200B008E9BDA /* xmlwriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xmlwriter.h; sourceTree = "<group>"; };
1214927B181E200B008E9BDA /* xunitoutput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xunitoutput.h; sourceTree = "<group>"; };
1214927C181E200B008E9BDA /* registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = registration.h; sourceTree = "<group>"; };
1214927D181E200B008E9BDA /* testlistener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testlistener.h; sourceTree = "<group>"; };
1214927E181E200B008E9BDA /* testlisteneraggregator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testlisteneraggregator.h; sourceTree = "<group>"; };
12149280181E200B008E9BDA /* minimalprogresstestlistener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = minimalprogresstestlistener.h; sourceTree = "<group>"; };
12149281181E200B008E9BDA /* testlisteners.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testlisteners.h; sourceTree = "<group>"; };
12149282181E200B008E9BDA /* testresult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testresult.h; sourceTree = "<group>"; };
12149283181E200B008E9BDA /* testresultfactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testresultfactory.h; sourceTree = "<group>"; };
12149284181E200B008E9BDA /* testresults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testresults.h; sourceTree = "<group>"; };
12149285181E200B008E9BDA /* testrunner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testrunner.h; sourceTree = "<group>"; };
12149288181E200B008E9BDA /* choices.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = choices.h; sourceTree = "<group>"; };
1214928B181E200B008E9BDA /* assert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = assert.h; sourceTree = "<group>"; };
1214928C181E200B008E9BDA /* assertionexception.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = assertionexception.h; sourceTree = "<group>"; };
1214928D181E200B008E9BDA /* assertmacro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = assertmacro.h; sourceTree = "<group>"; };
1214928F181E200B008E9BDA /* constraints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = constraints.h; sourceTree = "<group>"; };
12149290181E200B008E9BDA /* containsconstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = containsconstraint.h; sourceTree = "<group>"; };
12149291181E200B008E9BDA /* endswithconstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = endswithconstraint.h; sourceTree = "<group>"; };
12149292181E200B008E9BDA /* equalsconstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = equalsconstraint.h; sourceTree = "<group>"; };
12149293181E200B008E9BDA /* equalscontainerconstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = equalscontainerconstraint.h; sourceTree = "<group>"; };
12149294181E200B008E9BDA /* equalswithdeltaconstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = equalswithdeltaconstraint.h; sourceTree = "<group>"; };
12149296181E200B008E9BDA /* andexpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = andexpression.h; sourceTree = "<group>"; };
12149297181E200B008E9BDA /* expression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = expression.h; sourceTree = "<group>"; };
12149298181E200B008E9BDA /* expression_fwd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = expression_fwd.h; sourceTree = "<group>"; };
12149299181E200B008E9BDA /* notexpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = notexpression.h; sourceTree = "<group>"; };
1214929A181E200B008E9BDA /* orexpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = orexpression.h; sourceTree = "<group>"; };
1214929B181E200B008E9BDA /* fulfillsconstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fulfillsconstraint.h; sourceTree = "<group>"; };
1214929C181E200B008E9BDA /* haslengthconstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = haslengthconstraint.h; sourceTree = "<group>"; };
1214929D181E200B008E9BDA /* isgreaterthanconstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = isgreaterthanconstraint.h; sourceTree = "<group>"; };
1214929E181E200B008E9BDA /* islessthanconstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = islessthanconstraint.h; sourceTree = "<group>"; };
1214929F181E200B008E9BDA /* startswithconstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = startswithconstraint.h; sourceTree = "<group>"; };
121492A0181E200B008E9BDA /* exceptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = exceptions.h; sourceTree = "<group>"; };
121492A2181E200B008E9BDA /* constraintadapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = constraintadapter.h; sourceTree = "<group>"; };
121492A3181E200B008E9BDA /* constraintlist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = constraintlist.h; sourceTree = "<group>"; };
121492A4181E200B008E9BDA /* expressionbuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = expressionbuilder.h; sourceTree = "<group>"; };
121492A5181E200B008E9BDA /* fluent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fluent.h; sourceTree = "<group>"; };
121492A7181E200B008E9BDA /* andoperator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = andoperator.h; sourceTree = "<group>"; };
121492A9181E200B008E9BDA /* alloperator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = alloperator.h; sourceTree = "<group>"; };
121492AA181E200B008E9BDA /* atleastoperator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = atleastoperator.h; sourceTree = "<group>"; };
121492AB181E200B008E9BDA /* atmostoperator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = atmostoperator.h; sourceTree = "<group>"; };
121492AC181E200B008E9BDA /* collectionconstraintevaluator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = collectionconstraintevaluator.h; sourceTree = "<group>"; };
121492AD181E200B008E9BDA /* collectionoperator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = collectionoperator.h; sourceTree = "<group>"; };
121492AE181E200B008E9BDA /* exactlyoperator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = exactlyoperator.h; sourceTree = "<group>"; };
121492AF181E200B008E9BDA /* noneoperator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = noneoperator.h; sourceTree = "<group>"; };
121492B0181E200B008E9BDA /* constraintoperator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = constraintoperator.h; sourceTree = "<group>"; };
121492B1181E200B008E9BDA /* notoperator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = notoperator.h; sourceTree = "<group>"; };
121492B2181E200B008E9BDA /* oroperator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = oroperator.h; sourceTree = "<group>"; };
121492B3181E200B008E9BDA /* snowhouse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = snowhouse.h; sourceTree = "<group>"; };
121492B4181E200B008E9BDA /* stringize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stringize.h; sourceTree = "<group>"; };
121492B5181E200B008E9BDA /* stringizers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stringizers.h; sourceTree = "<group>"; };
121492C4181E200B008E9BDA /* igloo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = igloo.h; sourceTree = "<group>"; };
121492C5181E200B008E9BDA /* igloo_alt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = igloo_alt.h; sourceTree = "<group>"; };
121492C6181E200B008E9BDA /* igloo_framework.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = igloo_framework.h; sourceTree = "<group>"; };
121492E9181E200B008E9BDA /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = spec/main.cpp; sourceTree = SOURCE_ROOT; };
121492EA181E200B008E9BDA /* rules_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rules_spec.cpp; path = spec/rules_spec.cpp; sourceTree = SOURCE_ROOT; };
12C344421822F27700B07BE3 /* transition_map.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = transition_map.h; sourceTree = "<group>"; };
12E71794181D02A80051A649 /* specs */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = specs; sourceTree = BUILT_PRODUCTS_DIR; };
12E71851181D081C0051A649 /* rule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rule.cpp; sourceTree = "<group>"; };
12E71852181D081C0051A649 /* rule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rule.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
12E71791181D02A80051A649 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
1214925C181E200B008E9BDA /* externals */ = {
isa = PBXGroup;
children = (
1214925D181E200B008E9BDA /* igloo */,
);
name = externals;
path = spec/externals;
sourceTree = SOURCE_ROOT;
};
1214925D181E200B008E9BDA /* igloo */ = {
isa = PBXGroup;
children = (
12149264181E200B008E9BDA /* cotire */,
12149269181E200B008E9BDA /* igloo */,
);
path = igloo;
sourceTree = "<group>";
};
12149264181E200B008E9BDA /* cotire */ = {
isa = PBXGroup;
children = (
12149265181E200B008E9BDA /* igloo-tests_CXX_prefix.hxx */,
12149266181E200B008E9BDA /* igloo-tests_CXX_prefix.hxx.gch */,
12149267181E200B008E9BDA /* snowhouse-tests_CXX_prefix.hxx */,
12149268181E200B008E9BDA /* snowhouse-tests_CXX_prefix.hxx.gch */,
);
path = cotire;
sourceTree = "<group>";
};
12149269181E200B008E9BDA /* igloo */ = {
isa = PBXGroup;
children = (
1214926A181E200B008E9BDA /* core */,
12149286181E200B008E9BDA /* external */,
121492C4181E200B008E9BDA /* igloo.h */,
121492C5181E200B008E9BDA /* igloo_alt.h */,
121492C6181E200B008E9BDA /* igloo_framework.h */,
);
path = igloo;
sourceTree = "<group>";
};
1214926A181E200B008E9BDA /* core */ = {
isa = PBXGroup;
children = (
1214926B181E200B008E9BDA /* alternativeregistrationaliases.h */,
1214926C181E200B008E9BDA /* context.h */,
1214926D181E200B008E9BDA /* contextbase.h */,
1214926E181E200B008E9BDA /* contextprovider.h */,
1214926F181E200B008E9BDA /* contextregistry.h */,
12149270181E200B008E9BDA /* contextrunner.h */,
12149271181E200B008E9BDA /* core.h */,
12149272181E200B008E9BDA /* defaultregistrationaliases.h */,
12149273181E200B008E9BDA /* outputters */,
1214927C181E200B008E9BDA /* registration.h */,
1214927D181E200B008E9BDA /* testlistener.h */,
1214927E181E200B008E9BDA /* testlisteneraggregator.h */,
1214927F181E200B008E9BDA /* testlisteners */,
12149282181E200B008E9BDA /* testresult.h */,
12149283181E200B008E9BDA /* testresultfactory.h */,
12149284181E200B008E9BDA /* testresults.h */,
12149285181E200B008E9BDA /* testrunner.h */,
);
path = core;
sourceTree = "<group>";
};
12149273181E200B008E9BDA /* outputters */ = {
isa = PBXGroup;
children = (
12149274181E200B008E9BDA /* coloredconsoletestresultsoutput.h */,
12149275181E200B008E9BDA /* consoleoutputcolors.h */,
12149276181E200B008E9BDA /* defaulttestresultsoutput.h */,
12149277181E200B008E9BDA /* outputters.h */,
12149278181E200B008E9BDA /* testresultsoutput.h */,
12149279181E200B008E9BDA /* visualstudiooutput.h */,
1214927A181E200B008E9BDA /* xmlwriter.h */,
1214927B181E200B008E9BDA /* xunitoutput.h */,
);
path = outputters;
sourceTree = "<group>";
};
1214927F181E200B008E9BDA /* testlisteners */ = {
isa = PBXGroup;
children = (
12149280181E200B008E9BDA /* minimalprogresstestlistener.h */,
12149281181E200B008E9BDA /* testlisteners.h */,
);
path = testlisteners;
sourceTree = "<group>";
};
12149286181E200B008E9BDA /* external */ = {
isa = PBXGroup;
children = (
12149287181E200B008E9BDA /* choices */,
12149289181E200B008E9BDA /* snowhouse */,
);
path = external;
sourceTree = "<group>";
};
12149287181E200B008E9BDA /* choices */ = {
isa = PBXGroup;
children = (
12149288181E200B008E9BDA /* choices.h */,
);
path = choices;
sourceTree = "<group>";
};
12149289181E200B008E9BDA /* snowhouse */ = {
isa = PBXGroup;
children = (
1214928A181E200B008E9BDA /* snowhouse */,
);
path = snowhouse;
sourceTree = "<group>";
};
1214928A181E200B008E9BDA /* snowhouse */ = {
isa = PBXGroup;
children = (
1214928B181E200B008E9BDA /* assert.h */,
1214928C181E200B008E9BDA /* assertionexception.h */,
1214928D181E200B008E9BDA /* assertmacro.h */,
1214928E181E200B008E9BDA /* constraints */,
121492A0181E200B008E9BDA /* exceptions.h */,
121492A1181E200B008E9BDA /* fluent */,
121492B3181E200B008E9BDA /* snowhouse.h */,
121492B4181E200B008E9BDA /* stringize.h */,
121492B5181E200B008E9BDA /* stringizers.h */,
);
path = snowhouse;
sourceTree = "<group>";
};
1214928E181E200B008E9BDA /* constraints */ = {
isa = PBXGroup;
children = (
1214928F181E200B008E9BDA /* constraints.h */,
12149290181E200B008E9BDA /* containsconstraint.h */,
12149291181E200B008E9BDA /* endswithconstraint.h */,
12149292181E200B008E9BDA /* equalsconstraint.h */,
12149293181E200B008E9BDA /* equalscontainerconstraint.h */,
12149294181E200B008E9BDA /* equalswithdeltaconstraint.h */,
12149295181E200B008E9BDA /* expressions */,
1214929B181E200B008E9BDA /* fulfillsconstraint.h */,
1214929C181E200B008E9BDA /* haslengthconstraint.h */,
1214929D181E200B008E9BDA /* isgreaterthanconstraint.h */,
1214929E181E200B008E9BDA /* islessthanconstraint.h */,
1214929F181E200B008E9BDA /* startswithconstraint.h */,
);
path = constraints;
sourceTree = "<group>";
};
12149295181E200B008E9BDA /* expressions */ = {
isa = PBXGroup;
children = (
12149296181E200B008E9BDA /* andexpression.h */,
12149297181E200B008E9BDA /* expression.h */,
12149298181E200B008E9BDA /* expression_fwd.h */,
12149299181E200B008E9BDA /* notexpression.h */,
1214929A181E200B008E9BDA /* orexpression.h */,
);
path = expressions;
sourceTree = "<group>";
};
121492A1181E200B008E9BDA /* fluent */ = {
isa = PBXGroup;
children = (
121492A2181E200B008E9BDA /* constraintadapter.h */,
121492A3181E200B008E9BDA /* constraintlist.h */,
121492A4181E200B008E9BDA /* expressionbuilder.h */,
121492A5181E200B008E9BDA /* fluent.h */,
121492A6181E200B008E9BDA /* operators */,
);
path = fluent;
sourceTree = "<group>";
};
121492A6181E200B008E9BDA /* operators */ = {
isa = PBXGroup;
children = (
121492A7181E200B008E9BDA /* andoperator.h */,
121492A8181E200B008E9BDA /* collections */,
121492B0181E200B008E9BDA /* constraintoperator.h */,
121492B1181E200B008E9BDA /* notoperator.h */,
121492B2181E200B008E9BDA /* oroperator.h */,
);
path = operators;
sourceTree = "<group>";
};
121492A8181E200B008E9BDA /* collections */ = {
isa = PBXGroup;
children = (
121492A9181E200B008E9BDA /* alloperator.h */,
121492AA181E200B008E9BDA /* atleastoperator.h */,
121492AB181E200B008E9BDA /* atmostoperator.h */,
121492AC181E200B008E9BDA /* collectionconstraintevaluator.h */,
121492AD181E200B008E9BDA /* collectionoperator.h */,
121492AE181E200B008E9BDA /* exactlyoperator.h */,
121492AF181E200B008E9BDA /* noneoperator.h */,
);
path = collections;
sourceTree = "<group>";
};
12E716F9181D010E0051A649 = {
isa = PBXGroup;
children = (
12E71701181D01890051A649 /* src */,
12E71796181D02A80051A649 /* spec */,
12E71795181D02A80051A649 /* Products */,
);
sourceTree = "<group>";
};
12E71701181D01890051A649 /* src */ = {
isa = PBXGroup;
children = (
12E71850181D07EA0051A649 /* rules */,
);
path = src;
sourceTree = "<group>";
};
12E71795181D02A80051A649 /* Products */ = {
isa = PBXGroup;
children = (
12E71794181D02A80051A649 /* specs */,
);
name = Products;
sourceTree = "<group>";
};
12E71796181D02A80051A649 /* spec */ = {
isa = PBXGroup;
children = (
1214925C181E200B008E9BDA /* externals */,
121492E9181E200B008E9BDA /* main.cpp */,
121492EA181E200B008E9BDA /* rules_spec.cpp */,
121306011829FAED00FCF928 /* spec_helper.h */,
);
name = spec;
path = Specs;
sourceTree = "<group>";
};
12E71850181D07EA0051A649 /* rules */ = {
isa = PBXGroup;
children = (
12E71851181D081C0051A649 /* rule.cpp */,
12E71852181D081C0051A649 /* rule.h */,
12C344421822F27700B07BE3 /* transition_map.h */,
);
path = rules;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
12E71793181D02A80051A649 /* specs */ = {
isa = PBXNativeTarget;
buildConfigurationList = 12E7179B181D02A80051A649 /* Build configuration list for PBXNativeTarget "specs" */;
buildPhases = (
12E71790181D02A80051A649 /* Sources */,
12E71791181D02A80051A649 /* Frameworks */,
12E71792181D02A80051A649 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = specs;
productName = Specs;
productReference = 12E71794181D02A80051A649 /* specs */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
12E716FA181D010E0051A649 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0500;
};
buildConfigurationList = 12E716FD181D010E0051A649 /* Build configuration list for PBXProject "TreeSitter" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 12E716F9181D010E0051A649;
productRefGroup = 12E71795181D02A80051A649 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
12E71793181D02A80051A649 /* specs */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
12E71790181D02A80051A649 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
12E71853181D081C0051A649 /* rule.cpp in Sources */,
1214930F181E200B008E9BDA /* rules_spec.cpp in Sources */,
1214930E181E200B008E9BDA /* main.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
12E716FE181D010E0051A649 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
spec/externals/igloo,
src/externals/boost,
);
USER_HEADER_SEARCH_PATHS = "src/externals/boost spec/externals/igloo";
};
name = Debug;
};
12E716FF181D010E0051A649 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
spec/externals/igloo,
src/externals/boost,
);
USER_HEADER_SEARCH_PATHS = "src/externals/boost spec/externals/igloo";
};
name = Release;
};
12E7179C181D02A80051A649 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
spec/externals/igloo,
);
MACOSX_DEPLOYMENT_TARGET = 10.8;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
USER_HEADER_SEARCH_PATHS = "";
};
name = Debug;
};
12E7179D181D02A80051A649 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
spec/externals/igloo,
);
MACOSX_DEPLOYMENT_TARGET = 10.8;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
USER_HEADER_SEARCH_PATHS = "";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
12E716FD181D010E0051A649 /* Build configuration list for PBXProject "TreeSitter" */ = {
isa = XCConfigurationList;
buildConfigurations = (
12E716FE181D010E0051A649 /* Debug */,
12E716FF181D010E0051A649 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
12E7179B181D02A80051A649 /* Build configuration list for PBXNativeTarget "specs" */ = {
isa = XCConfigurationList;
buildConfigurations = (
12E7179C181D02A80051A649 /* Debug */,
12E7179D181D02A80051A649 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 12E716FA181D010E0051A649 /* Project object */;
}

1
spec/externals/igloo vendored Submodule

@ -0,0 +1 @@
Subproject commit d8c6aa24de88740c6f1783281249eb18f858deaf

8
spec/main.cpp Normal file
View file

@ -0,0 +1,8 @@
#include <igloo/igloo_alt.h>
using namespace igloo;
int main(int argc, char *argv[])
{
return TestRunner::RunAllTests(argc, argv);
}

53
spec/rules_spec.cpp Normal file
View file

@ -0,0 +1,53 @@
#include "rule.h"
#include "transition_map.h"
#include <igloo/igloo_alt.h>
using namespace std;
using namespace igloo;
using namespace tree_sitter::rules;
Describe(Rules) {
Describe(transitions) {
Symbol symbol1 = Symbol(1);
Symbol symbol2 = Symbol(2);
Symbol symbol3 = Symbol(3);
It(handles_symbols) {
AssertThat(
symbol1.transitions(),
EqualsContainer(TransitionMap<Rule>(
{ symbol1.copy() },
{ new Blank() }
), TransitionMap<Rule>::elements_equal));
}
It(handles_choices) {
AssertThat(
Choice(symbol1, symbol2).transitions(),
EqualsContainer(TransitionMap<Rule>(
{ symbol1.copy(), symbol2.copy() },
{ new Blank(), new Blank() }
), TransitionMap<Rule>::elements_equal));
}
It(handles_sequences) {
AssertThat(
Seq(symbol1, symbol2).transitions(),
EqualsContainer(TransitionMap<Rule>(
{ symbol1.copy() },
{ symbol2.copy() }
), TransitionMap<Rule>::elements_equal));
}
It(handles_choices_with_common_starting_symbols) {
AssertThat(
Choice(
Seq(symbol1, symbol2),
Seq(symbol1, symbol3)).transitions(),
EqualsContainer(TransitionMap<Rule>(
{ symbol1.copy() },
{ new Choice(symbol2, symbol3) }
), TransitionMap<Rule>::elements_equal));
}
};
};

22
spec_helper.h Normal file
View file

@ -0,0 +1,22 @@
#ifndef TreeSitter_SpecHelper_h
#define TreeSitter_SpecHelper_h
#include "igloo/igloo_alt.h"
#include "transition_map.h"
#include "rule.h"
namespace snowhouse {
template<>
std::string Stringize(const tree_sitter::rules::TransitionMap<tree_sitter::rules::Rule> &map) {
std::string result("[");
bool started = false;
for (auto pair : map) {
if (started) result += ", ";
result += (pair.first->to_string() + " => " + pair.second->to_string());
started = true;
}
return result + "]";
}
}
#endif

95
src/rules/rule.cpp Normal file
View file

@ -0,0 +1,95 @@
#include "rule.h"
#include "spec_helper.h"
#include "transition_map.h"
using namespace std;
namespace tree_sitter {
namespace rules {
// Constructors
Blank::Blank() {}
Symbol::Symbol(int id) : id(id) {};
Seq::Seq(const Rule &left, const Rule &right) : left(left.copy()), right(right.copy()) {};
Seq::Seq(const Rule *left, const Rule *right) : left(left), right(right) {};
Seq::Seq(shared_ptr<const Rule> left, shared_ptr<const Rule> right) : left(left), right(right) {};
Choice::Choice(const Rule &left, const Rule &right) : left(left.copy()), right(right.copy()) {};
Choice::Choice(const Rule *left, const Rule *right) : left(left), right(right) {};
Choice::Choice(shared_ptr<const Rule> left, shared_ptr<const Rule> right) : left(left), right(right) {};
// Transitions
TransitionMap<Rule> Blank::transitions() const {
return TransitionMap<Rule>();
}
TransitionMap<Rule> Symbol::transitions() const {
return TransitionMap<Rule>({ copy() }, { new Blank() });
}
TransitionMap<Rule> Choice::transitions() const {
auto result = left->transitions();
result.merge(right->transitions(), [&](const Rule &left, const Rule &right) {
return new Choice(left, right);
});
return result;
}
TransitionMap<Rule> Seq::transitions() const {
return TransitionMap<Rule>({ left->copy() }, { right->copy() });
}
// Equality
bool Blank::operator==(const Rule &rule) const {
return dynamic_cast<const Blank *>(&rule) != NULL;
}
bool Symbol::operator==(const Rule &rule) const {
const Symbol *other = dynamic_cast<const Symbol *>(&rule);
return (other != NULL) && (other->id == id);
}
bool Choice::operator==(const Rule &rule) const {
const Choice *other = dynamic_cast<const Choice *>(&rule);
return (other != NULL) && (*other->left == *left) && (*other->right == *right);
}
bool Seq::operator==(const Rule &rule) const {
const Seq *other = dynamic_cast<const Seq *>(&rule);
return (other != NULL) && (*other->left == *left) && (*other->right == *right);
}
// Copying
Blank * Blank::copy() const {
return new Blank();
}
Symbol * Symbol::copy() const {
return new Symbol(id);
}
Choice * Choice::copy() const {
return new Choice(left, right);
}
Seq * Seq::copy() const {
return new Seq(left, right);
}
// Description
string Blank::to_string() const {
return "blank";
}
string Symbol::to_string() const {
return string(std::to_string(id));
}
string Choice::to_string() const {
return string("(choice ") + left->to_string() + " " + right->to_string() + ")";
}
string Seq::to_string() const {
return string("(seq ") + left->to_string() + " " + right->to_string() + ")";
}
}
}

68
src/rules/rule.h Normal file
View file

@ -0,0 +1,68 @@
#ifndef __TreeSitter__Rule__
#define __TreeSitter__Rule__
#include <string>
namespace tree_sitter {
namespace rules {
template<class value> class TransitionMap;
class Rule {
public:
virtual TransitionMap<Rule> transitions() const = 0;
virtual Rule * copy() const = 0;
virtual bool operator==(const Rule& other) const = 0;
virtual std::string to_string() const = 0;
};
class Blank : public Rule {
public:
Blank();
TransitionMap<Rule> transitions() const;
Blank * copy() const;
bool operator==(const Rule& other) const;
std::string to_string() const;
};
class Symbol : public Rule {
public:
Symbol(int id);
TransitionMap<Rule> transitions() const;
Symbol * copy() const;
bool operator==(const Rule& other) const;
std::string to_string() const;
private:
int id;
};
class Choice : public Rule {
public:
Choice(const Rule &left, const Rule &right);
Choice(const Rule *left, const Rule *right);
Choice(std::shared_ptr<const Rule> left, std::shared_ptr<const Rule> right);
TransitionMap<Rule> transitions() const;
Choice * copy() const;
bool operator==(const Rule& other) const;
std::string to_string() const;
private:
std::shared_ptr<const Rule> left;
std::shared_ptr<const Rule> right;
};
class Seq : public Rule {
public:
Seq(const Rule &left, const Rule &right);
Seq(const Rule *left, const Rule *right);
Seq(std::shared_ptr<const Rule> left, std::shared_ptr<const Rule> right);
TransitionMap<Rule> transitions() const;
Seq * copy() const;
bool operator==(const Rule& other) const;
std::string to_string() const;
private:
std::shared_ptr<const Rule> left;
std::shared_ptr<const Rule> right;
};
}
}
#endif

View file

@ -0,0 +1,94 @@
#ifndef __TreeSitter__TransitionSet__
#define __TreeSitter__TransitionSet__
#include <vector>
#include <functional>
#include "rule.h"
namespace tree_sitter {
namespace rules {
class Rule;
template<typename MappedType>
class TransitionMap {
public:
typedef std::shared_ptr<const Rule> rule_ptr;
typedef std::shared_ptr<const MappedType> mapped_ptr;
typedef std::pair<rule_ptr, mapped_ptr> pair_type;
typedef std::vector<pair_type> contents_type;
static bool elements_equal(const pair_type &left, const pair_type &right) {
return (*left.first == *right.first) && (*left.second == *right.second);
}
TransitionMap() : contents(contents_type()) {};
TransitionMap(std::initializer_list<Rule *> keys, std::initializer_list<MappedType *> values) : TransitionMap() {
auto value_iter(values.begin());
for (auto key_iter(keys.begin()); key_iter != keys.end(); ++key_iter) {
add(*key_iter, *value_iter);
++value_iter;
}
}
typedef typename contents_type::const_iterator const_iterator;
typedef typename contents_type::iterator iterator;
iterator begin() { return contents.begin(); }
iterator end() { return contents.end(); }
const_iterator begin() const { return contents.begin(); }
const_iterator end() const { return contents.end(); }
void add(const Rule *on_rule, const MappedType *to_value) {
rule_ptr key(on_rule);
mapped_ptr value(to_value);
contents.push_back(pair_type(key, value));
}
void add(rule_ptr on_rule, mapped_ptr to_value) {
rule_ptr key(on_rule);
mapped_ptr value(to_value);
contents.push_back(pair_type(key, value));
}
size_t size() const {
return contents.size();
}
mapped_ptr operator[](Rule const &on_rule) const {
pair_type *pair = pair_for_key(on_rule);
if (pair)
return pair->second;
else
return NULL;
}
mapped_ptr operator[](int i) const {
return contents[i].second;
}
void merge(const TransitionMap<MappedType> &other, std::function<const MappedType *(const MappedType &, const MappedType &)> merge_fn) {
for (pair_type other_pair : other) {
pair_type *current_pair = pair_for_key(*other_pair.first);
if (current_pair)
current_pair->second = mapped_ptr(merge_fn(*current_pair->second, *other_pair.second));
else
add(other_pair.first, other_pair.second);
}
}
private:
pair_type * pair_for_key(Rule const &key) {
for (int i = 0; i < contents.size(); i++) {
pair_type *pair = &contents[i];
if (*pair->first == key) return pair;
}
return NULL;
}
contents_type contents;
};
}
}
#endif