Add runtime specs
This commit is contained in:
parent
9618efd12a
commit
3417ad5adb
11 changed files with 542 additions and 294 deletions
|
|
@ -14,23 +14,45 @@
|
|||
12130614182C3A1700FCF928 /* seq.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130612182C3A1700FCF928 /* seq.cpp */; };
|
||||
12130617182C3D2900FCF928 /* string.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130615182C3D2900FCF928 /* string.cpp */; };
|
||||
1213061B182C84DF00FCF928 /* item.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130619182C84DF00FCF928 /* item.cpp */; };
|
||||
1213061F182C857100FCF928 /* item_set_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1213061D182C857100FCF928 /* item_set_spec.cpp */; };
|
||||
12130622182C85D300FCF928 /* item_set.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130620182C85D300FCF928 /* item_set.cpp */; };
|
||||
1214930E181E200B008E9BDA /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 121492E9181E200B008E9BDA /* main.cpp */; };
|
||||
1214930F181E200B008E9BDA /* rules_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 121492EA181E200B008E9BDA /* rules_spec.cpp */; };
|
||||
12512093182F307C00C9B56A /* parse_table_builder_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12512092182F307C00C9B56A /* parse_table_builder_spec.cpp */; };
|
||||
1251209B1830145300C9B56A /* rule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1251209A1830145300C9B56A /* rule.cpp */; };
|
||||
125120A018307DEC00C9B56A /* parse_table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1251209E18307DEC00C9B56A /* parse_table.cpp */; };
|
||||
125120A4183083BD00C9B56A /* arithmetic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 125120A3183083BD00C9B56A /* arithmetic.cpp */; };
|
||||
129D242C183EB1EB00FE9F71 /* parse_table_builder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 129D242A183EB1EB00FE9F71 /* parse_table_builder.cpp */; };
|
||||
12D1369D18328C5A005F3369 /* item_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12D1369C18328C5A005F3369 /* item_spec.cpp */; };
|
||||
12D136A1183570F5005F3369 /* pattern_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12D136A0183570F5005F3369 /* pattern_spec.cpp */; };
|
||||
12D136A4183678A2005F3369 /* repeat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12D136A2183678A2005F3369 /* repeat.cpp */; };
|
||||
12F8BE8E183C79B2006CCF99 /* char_class.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12F8BE8C183C79B2006CCF99 /* char_class.cpp */; };
|
||||
12F9A64E182DD5FD00FAF50C /* spec_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12F9A64C182DD5FD00FAF50C /* spec_helper.cpp */; };
|
||||
12F9A651182DD6BC00FAF50C /* grammar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12F9A64F182DD6BC00FAF50C /* grammar.cpp */; };
|
||||
12FD4061185E68470041A84E /* c_code.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD405F185E68470041A84E /* c_code.cpp */; };
|
||||
12FD4064185E75290041A84E /* generate_parsers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD4063185E75290041A84E /* generate_parsers.cpp */; };
|
||||
12FD40B3185EEB5E0041A84E /* seq.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130612182C3A1700FCF928 /* seq.cpp */; };
|
||||
12FD40B4185EEB5E0041A84E /* parse_table_builder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 129D242A183EB1EB00FE9F71 /* parse_table_builder.cpp */; };
|
||||
12FD40B6185EEB5E0041A84E /* arithmetic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 125120A3183083BD00C9B56A /* arithmetic.cpp */; };
|
||||
12FD40B8185EEB5E0041A84E /* item.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130619182C84DF00FCF928 /* item.cpp */; };
|
||||
12FD40B9185EEB5E0041A84E /* string.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130615182C3D2900FCF928 /* string.cpp */; };
|
||||
12FD40BA185EEB5E0041A84E /* char_class.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12F8BE8C183C79B2006CCF99 /* char_class.cpp */; };
|
||||
12FD40BB185EEB5E0041A84E /* blank.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1213060F182C3A1100FCF928 /* blank.cpp */; };
|
||||
12FD40BD185EEB5E0041A84E /* choice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1213060C182C398300FCF928 /* choice.cpp */; };
|
||||
12FD40BF185EEB5E0041A84E /* c_code.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD405F185E68470041A84E /* c_code.cpp */; };
|
||||
12FD40C0185EEB5E0041A84E /* parse_table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1251209E18307DEC00C9B56A /* parse_table.cpp */; };
|
||||
12FD40C2185EEB5E0041A84E /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 121492E9181E200B008E9BDA /* main.cpp */; };
|
||||
12FD40C3185EEB5E0041A84E /* grammar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12F9A64F182DD6BC00FAF50C /* grammar.cpp */; };
|
||||
12FD40C6185EEB5E0041A84E /* repeat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12D136A2183678A2005F3369 /* repeat.cpp */; };
|
||||
12FD40C7185EEB5E0041A84E /* item_set.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130620182C85D300FCF928 /* item_set.cpp */; };
|
||||
12FD40C8185EEB5E0041A84E /* char.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130603182C348F00FCF928 /* char.cpp */; };
|
||||
12FD40C9185EEB5E0041A84E /* symbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12130609182C389100FCF928 /* symbol.cpp */; };
|
||||
12FD40CA185EEB5E0041A84E /* rule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1251209A1830145300C9B56A /* rule.cpp */; };
|
||||
12FD40CB185EEB5E0041A84E /* pattern.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27A340F3EEB184C040521323 /* pattern.cpp */; };
|
||||
12FD40D2185EEB970041A84E /* arithmetic.c in Sources */ = {isa = PBXBuildFile; fileRef = 12FD4065185E7C2F0041A84E /* arithmetic.c */; };
|
||||
12FD40D5185FEEDB0041A84E /* item_set_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1213061D182C857100FCF928 /* item_set_spec.cpp */; };
|
||||
12FD40D6185FEEDB0041A84E /* parse_table_builder_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12512092182F307C00C9B56A /* parse_table_builder_spec.cpp */; };
|
||||
12FD40D7185FEEDB0041A84E /* item_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12D1369C18328C5A005F3369 /* item_spec.cpp */; };
|
||||
12FD40D8185FEEDF0041A84E /* rules_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 121492EA181E200B008E9BDA /* rules_spec.cpp */; };
|
||||
12FD40D9185FEEDF0041A84E /* pattern_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12D136A0183570F5005F3369 /* pattern_spec.cpp */; };
|
||||
12FD40DB185FEF0D0041A84E /* arithmetic_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12FD40DA185FEF0D0041A84E /* arithmetic_spec.cpp */; };
|
||||
12FD40DD185FF12C0041A84E /* parser.c in Sources */ = {isa = PBXBuildFile; fileRef = 12FD40DC185FF12C0041A84E /* parser.c */; };
|
||||
12FD40DF1860064C0041A84E /* tree.c in Sources */ = {isa = PBXBuildFile; fileRef = 12FD40DE1860064C0041A84E /* tree.c */; };
|
||||
27A343CA69E17E0F9EBEDF1C /* pattern.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27A340F3EEB184C040521323 /* pattern.cpp */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
|
|
@ -44,6 +66,15 @@
|
|||
);
|
||||
runOnlyForDeploymentPostprocessing = 1;
|
||||
};
|
||||
12FD40CD185EEB5E0041A84E /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = /usr/share/man/man1/;
|
||||
dstSubfolderSpec = 0;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 1;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
|
|
@ -85,14 +116,19 @@
|
|||
12E71852181D081C0051A649 /* rules.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = rules.h; path = src/compiler/rules/rules.h; sourceTree = SOURCE_ROOT; };
|
||||
12F8BE8C183C79B2006CCF99 /* char_class.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = char_class.cpp; sourceTree = "<group>"; };
|
||||
12F8BE8D183C79B2006CCF99 /* char_class.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = char_class.h; sourceTree = "<group>"; };
|
||||
12F9A64C182DD5FD00FAF50C /* spec_helper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = spec_helper.cpp; path = spec/spec_helper.cpp; sourceTree = SOURCE_ROOT; };
|
||||
12F9A64D182DD5FD00FAF50C /* spec_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = spec_helper.h; path = spec/spec_helper.h; sourceTree = SOURCE_ROOT; };
|
||||
12F9A64C182DD5FD00FAF50C /* spec_helper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = spec_helper.cpp; path = spec/compiler/spec_helper.cpp; sourceTree = SOURCE_ROOT; };
|
||||
12F9A64D182DD5FD00FAF50C /* spec_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = spec_helper.h; path = spec/compiler/spec_helper.h; sourceTree = SOURCE_ROOT; };
|
||||
12F9A64F182DD6BC00FAF50C /* grammar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = grammar.cpp; sourceTree = "<group>"; };
|
||||
12F9A650182DD6BC00FAF50C /* grammar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = grammar.h; sourceTree = "<group>"; };
|
||||
12FD405F185E68470041A84E /* c_code.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = c_code.cpp; path = src/compiler/code_gen/c_code.cpp; sourceTree = SOURCE_ROOT; };
|
||||
12FD4060185E68470041A84E /* c_code.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = c_code.h; path = src/compiler/code_gen/c_code.h; sourceTree = SOURCE_ROOT; };
|
||||
12FD4063185E75290041A84E /* generate_parsers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = generate_parsers.cpp; path = spec/compiler/generate_parsers.cpp; sourceTree = SOURCE_ROOT; };
|
||||
12FD4065185E7C2F0041A84E /* arithmetic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = arithmetic.c; path = spec/fixtures/parsers/arithmetic.c; sourceTree = SOURCE_ROOT; };
|
||||
12FD40D1185EEB5E0041A84E /* runtime_specs */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = runtime_specs; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
12FD40D4185FED9A0041A84E /* runtime.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = runtime.h; sourceTree = "<group>"; };
|
||||
12FD40DA185FEF0D0041A84E /* arithmetic_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = arithmetic_spec.cpp; sourceTree = "<group>"; };
|
||||
12FD40DC185FF12C0041A84E /* parser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = parser.c; sourceTree = "<group>"; };
|
||||
12FD40DE1860064C0041A84E /* tree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tree.c; sourceTree = "<group>"; };
|
||||
27A340F3EEB184C040521323 /* pattern.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pattern.cpp; sourceTree = "<group>"; };
|
||||
27A3438C4FA59A3882E8493B /* pattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pattern.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
|
@ -105,6 +141,13 @@
|
|||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
12FD40CC185EEB5E0041A84E /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
|
|
@ -185,6 +228,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
12D1369E18342088005F3369 /* todo.md */,
|
||||
12FD40D3185FED630041A84E /* include */,
|
||||
12E71701181D01890051A649 /* src */,
|
||||
12E71796181D02A80051A649 /* spec */,
|
||||
12E71795181D02A80051A649 /* Products */,
|
||||
|
|
@ -204,6 +248,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
12E71794181D02A80051A649 /* specs */,
|
||||
12FD40D1185EEB5E0041A84E /* runtime_specs */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -215,8 +260,6 @@
|
|||
12FD40AF185EE81D0041A84E /* fixtures */,
|
||||
121492E9181E200B008E9BDA /* main.cpp */,
|
||||
12FD40B0185EE97E0041A84E /* runtime */,
|
||||
12F9A64C182DD5FD00FAF50C /* spec_helper.cpp */,
|
||||
12F9A64D182DD5FD00FAF50C /* spec_helper.h */,
|
||||
);
|
||||
path = spec;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -254,6 +297,8 @@
|
|||
12FD40AD185EE5440041A84E /* runtime */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
12FD40DC185FF12C0041A84E /* parser.c */,
|
||||
12FD40DE1860064C0041A84E /* tree.c */,
|
||||
);
|
||||
path = runtime;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -261,9 +306,11 @@
|
|||
12FD40AE185EE6610041A84E /* compiler */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
12D1369F18357066005F3369 /* rules */,
|
||||
1213061C182C854F00FCF928 /* lr */,
|
||||
12FD4063185E75290041A84E /* generate_parsers.cpp */,
|
||||
1213061C182C854F00FCF928 /* lr */,
|
||||
12D1369F18357066005F3369 /* rules */,
|
||||
12F9A64C182DD5FD00FAF50C /* spec_helper.cpp */,
|
||||
12F9A64D182DD5FD00FAF50C /* spec_helper.h */,
|
||||
);
|
||||
name = compiler;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -280,16 +327,25 @@
|
|||
12FD40B0185EE97E0041A84E /* runtime */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
12FD40DA185FEF0D0041A84E /* arithmetic_spec.cpp */,
|
||||
);
|
||||
name = runtime;
|
||||
path = runtime;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
12FD40D3185FED630041A84E /* include */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
12FD40D4185FED9A0041A84E /* runtime.h */,
|
||||
);
|
||||
path = include;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
12E71793181D02A80051A649 /* specs */ = {
|
||||
12E71793181D02A80051A649 /* compiler_specs */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 12E7179B181D02A80051A649 /* Build configuration list for PBXNativeTarget "specs" */;
|
||||
buildConfigurationList = 12E7179B181D02A80051A649 /* Build configuration list for PBXNativeTarget "compiler_specs" */;
|
||||
buildPhases = (
|
||||
12E71790181D02A80051A649 /* Sources */,
|
||||
12E71791181D02A80051A649 /* Frameworks */,
|
||||
|
|
@ -299,11 +355,28 @@
|
|||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = specs;
|
||||
name = compiler_specs;
|
||||
productName = Specs;
|
||||
productReference = 12E71794181D02A80051A649 /* specs */;
|
||||
productType = "com.apple.product-type.tool";
|
||||
};
|
||||
12FD40B1185EEB5E0041A84E /* runtime_specs */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 12FD40CE185EEB5E0041A84E /* Build configuration list for PBXNativeTarget "runtime_specs" */;
|
||||
buildPhases = (
|
||||
12FD40B2185EEB5E0041A84E /* Sources */,
|
||||
12FD40CC185EEB5E0041A84E /* Frameworks */,
|
||||
12FD40CD185EEB5E0041A84E /* CopyFiles */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = runtime_specs;
|
||||
productName = Specs;
|
||||
productReference = 12FD40D1185EEB5E0041A84E /* runtime_specs */;
|
||||
productType = "com.apple.product-type.tool";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
|
|
@ -324,7 +397,8 @@
|
|||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
12E71793181D02A80051A649 /* specs */,
|
||||
12E71793181D02A80051A649 /* compiler_specs */,
|
||||
12FD40B1185EEB5E0041A84E /* runtime_specs */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
|
@ -334,25 +408,25 @@
|
|||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
12FD40D7185FEEDB0041A84E /* item_spec.cpp in Sources */,
|
||||
12FD40D5185FEEDB0041A84E /* item_set_spec.cpp in Sources */,
|
||||
12130614182C3A1700FCF928 /* seq.cpp in Sources */,
|
||||
129D242C183EB1EB00FE9F71 /* parse_table_builder.cpp in Sources */,
|
||||
12D136A1183570F5005F3369 /* pattern_spec.cpp in Sources */,
|
||||
125120A4183083BD00C9B56A /* arithmetic.cpp in Sources */,
|
||||
1214930F181E200B008E9BDA /* rules_spec.cpp in Sources */,
|
||||
1213061B182C84DF00FCF928 /* item.cpp in Sources */,
|
||||
12FD40D9185FEEDF0041A84E /* pattern_spec.cpp in Sources */,
|
||||
12130617182C3D2900FCF928 /* string.cpp in Sources */,
|
||||
12F8BE8E183C79B2006CCF99 /* char_class.cpp in Sources */,
|
||||
12130611182C3A1100FCF928 /* blank.cpp in Sources */,
|
||||
12D1369D18328C5A005F3369 /* item_spec.cpp in Sources */,
|
||||
1213060E182C398300FCF928 /* choice.cpp in Sources */,
|
||||
12F9A64E182DD5FD00FAF50C /* spec_helper.cpp in Sources */,
|
||||
12FD4061185E68470041A84E /* c_code.cpp in Sources */,
|
||||
12FD40D8185FEEDF0041A84E /* rules_spec.cpp in Sources */,
|
||||
125120A018307DEC00C9B56A /* parse_table.cpp in Sources */,
|
||||
12FD4064185E75290041A84E /* generate_parsers.cpp in Sources */,
|
||||
1214930E181E200B008E9BDA /* main.cpp in Sources */,
|
||||
12F9A651182DD6BC00FAF50C /* grammar.cpp in Sources */,
|
||||
12512093182F307C00C9B56A /* parse_table_builder_spec.cpp in Sources */,
|
||||
1213061F182C857100FCF928 /* item_set_spec.cpp in Sources */,
|
||||
12FD40D6185FEEDB0041A84E /* parse_table_builder_spec.cpp in Sources */,
|
||||
12D136A4183678A2005F3369 /* repeat.cpp in Sources */,
|
||||
12130622182C85D300FCF928 /* item_set.cpp in Sources */,
|
||||
12130605182C348F00FCF928 /* char.cpp in Sources */,
|
||||
|
|
@ -362,6 +436,35 @@
|
|||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
12FD40B2185EEB5E0041A84E /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
12FD40B3185EEB5E0041A84E /* seq.cpp in Sources */,
|
||||
12FD40B4185EEB5E0041A84E /* parse_table_builder.cpp in Sources */,
|
||||
12FD40B6185EEB5E0041A84E /* arithmetic.cpp in Sources */,
|
||||
12FD40DD185FF12C0041A84E /* parser.c in Sources */,
|
||||
12FD40B8185EEB5E0041A84E /* item.cpp in Sources */,
|
||||
12FD40B9185EEB5E0041A84E /* string.cpp in Sources */,
|
||||
12FD40BA185EEB5E0041A84E /* char_class.cpp in Sources */,
|
||||
12FD40BB185EEB5E0041A84E /* blank.cpp in Sources */,
|
||||
12FD40BD185EEB5E0041A84E /* choice.cpp in Sources */,
|
||||
12FD40DF1860064C0041A84E /* tree.c in Sources */,
|
||||
12FD40BF185EEB5E0041A84E /* c_code.cpp in Sources */,
|
||||
12FD40D2185EEB970041A84E /* arithmetic.c in Sources */,
|
||||
12FD40DB185FEF0D0041A84E /* arithmetic_spec.cpp in Sources */,
|
||||
12FD40C0185EEB5E0041A84E /* parse_table.cpp in Sources */,
|
||||
12FD40C2185EEB5E0041A84E /* main.cpp in Sources */,
|
||||
12FD40C3185EEB5E0041A84E /* grammar.cpp in Sources */,
|
||||
12FD40C6185EEB5E0041A84E /* repeat.cpp in Sources */,
|
||||
12FD40C7185EEB5E0041A84E /* item_set.cpp in Sources */,
|
||||
12FD40C8185EEB5E0041A84E /* char.cpp in Sources */,
|
||||
12FD40C9185EEB5E0041A84E /* symbol.cpp in Sources */,
|
||||
12FD40CA185EEB5E0041A84E /* rule.cpp in Sources */,
|
||||
12FD40CB185EEB5E0041A84E /* pattern.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
|
|
@ -477,6 +580,90 @@
|
|||
};
|
||||
name = Release;
|
||||
};
|
||||
12FD40CF185EEB5E0041A84E /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++11";
|
||||
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,
|
||||
externals/igloo,
|
||||
include,
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.8;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_NAME = runtime_specs;
|
||||
SDKROOT = macosx;
|
||||
USER_HEADER_SEARCH_PATHS = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
12FD40D0185EEB5E0041A84E /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++11";
|
||||
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,
|
||||
externals/igloo,
|
||||
include,
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.8;
|
||||
PRODUCT_NAME = runtime_specs;
|
||||
SDKROOT = macosx;
|
||||
USER_HEADER_SEARCH_PATHS = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
|
|
@ -489,7 +676,7 @@
|
|||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
12E7179B181D02A80051A649 /* Build configuration list for PBXNativeTarget "specs" */ = {
|
||||
12E7179B181D02A80051A649 /* Build configuration list for PBXNativeTarget "compiler_specs" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
12E7179C181D02A80051A649 /* Debug */,
|
||||
|
|
@ -498,6 +685,15 @@
|
|||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
12FD40CE185EEB5E0041A84E /* Build configuration list for PBXNativeTarget "runtime_specs" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
12FD40CF185EEB5E0041A84E /* Debug */,
|
||||
12FD40D0185EEB5E0041A84E /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 12E716FA181D010E0051A649 /* Project object */;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "12E71793181D02A80051A649"
|
||||
BuildableName = "specs"
|
||||
BlueprintName = "specs"
|
||||
BlueprintName = "compiler_specs"
|
||||
ReferencedContainer = "container:TreeSitter.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "12E71793181D02A80051A649"
|
||||
BuildableName = "specs"
|
||||
BlueprintName = "specs"
|
||||
BlueprintName = "compiler_specs"
|
||||
ReferencedContainer = "container:TreeSitter.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
|
|
@ -53,7 +53,7 @@
|
|||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "12E71793181D02A80051A649"
|
||||
BuildableName = "specs"
|
||||
BlueprintName = "specs"
|
||||
BlueprintName = "compiler_specs"
|
||||
ReferencedContainer = "container:TreeSitter.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
|
|
@ -78,7 +78,7 @@
|
|||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "12E71793181D02A80051A649"
|
||||
BuildableName = "specs"
|
||||
BlueprintName = "specs"
|
||||
BlueprintName = "compiler_specs"
|
||||
ReferencedContainer = "container:TreeSitter.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0500"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "12FD40B1185EEB5E0041A84E"
|
||||
BuildableName = "specs copy"
|
||||
BlueprintName = "runtime_specs"
|
||||
ReferencedContainer = "container:TreeSitter.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "12FD40B1185EEB5E0041A84E"
|
||||
BuildableName = "specs copy"
|
||||
BlueprintName = "runtime_specs"
|
||||
ReferencedContainer = "container:TreeSitter.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "12FD40B1185EEB5E0041A84E"
|
||||
BuildableName = "specs copy"
|
||||
BlueprintName = "runtime_specs"
|
||||
ReferencedContainer = "container:TreeSitter.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "12FD40B1185EEB5E0041A84E"
|
||||
BuildableName = "specs copy"
|
||||
BlueprintName = "runtime_specs"
|
||||
ReferencedContainer = "container:TreeSitter.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
71
include/runtime.h
Normal file
71
include/runtime.h
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
#ifndef tree_sitter_runtime_h
|
||||
#define tree_sitter_runtime_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#pragma mark - Tree
|
||||
|
||||
typedef struct {
|
||||
} TSTree;
|
||||
|
||||
TSTree TSTreeMake();
|
||||
|
||||
#pragma mark - Parser
|
||||
|
||||
typedef size_t TSSymbol;
|
||||
typedef int TSState;
|
||||
|
||||
typedef struct {
|
||||
TSTree tree;
|
||||
const char *input;
|
||||
size_t position;
|
||||
TSState *state_stack;
|
||||
TSSymbol *symbol_stack;
|
||||
size_t state_count;
|
||||
size_t symbol_count;
|
||||
} TSParser;
|
||||
|
||||
TSParser TSParserMake(const char *input);
|
||||
void TSParserShift(TSParser *parser, TSState state);
|
||||
void TSParserReduce(TSParser *parser, TSSymbol symbol, int child_count);
|
||||
void TSParserError(TSParser *parser);
|
||||
TSState TSParserState(const TSParser *parser);
|
||||
TSSymbol TSParserLookahead(const TSParser *parser);
|
||||
|
||||
#pragma mark - DSL
|
||||
|
||||
#define START_PARSER() \
|
||||
TSParser parser = TSParserMake(input); \
|
||||
start:
|
||||
|
||||
#define LOOKAHEAD() \
|
||||
TSParserLookahead(&parser)
|
||||
|
||||
#define PARSE_STATE() \
|
||||
TSParserState(&parser)
|
||||
|
||||
#define SHIFT(number) \
|
||||
{ TSParserShift(&parser, number); break; }
|
||||
|
||||
#define ACCEPT() \
|
||||
{ goto done; }
|
||||
|
||||
#define REDUCE(symbol, child_count) \
|
||||
{ TSParserReduce(&parser, symbol, child_count); break; }
|
||||
|
||||
#define ERROR() \
|
||||
TSParserError(&parser)
|
||||
|
||||
#define FINISH_PARSER() \
|
||||
done: \
|
||||
return parser.tree;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
#include "parse_table.h"
|
||||
#include "parse_table_builder.h"
|
||||
|
||||
#include "fixtures/grammars/arithmetic.h"
|
||||
#include "../fixtures/grammars/arithmetic.h"
|
||||
|
||||
|
||||
using namespace tree_sitter;
|
||||
343
spec/fixtures/parsers/arithmetic.c
vendored
343
spec/fixtures/parsers/arithmetic.c
vendored
|
|
@ -1,4 +1,4 @@
|
|||
#include <tree_sitter/runtime.h>
|
||||
#include "runtime.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
|
@ -16,354 +16,193 @@ typedef enum {
|
|||
} ts_symbol_type;
|
||||
|
||||
|
||||
TSTree * ts_parse_arithmetic() {
|
||||
SETUP_PARSER()
|
||||
start:
|
||||
TSTree ts_parse_arithmetic(const char *input) {
|
||||
START_PARSER();
|
||||
switch (PARSE_STATE()) {
|
||||
case 0: {
|
||||
case 0:
|
||||
switch (LOOKAHEAD()) {
|
||||
case ts_symbol_type_left_paren: {
|
||||
case ts_symbol_type_left_paren:
|
||||
SHIFT(9);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_variable: {
|
||||
case ts_symbol_type_variable:
|
||||
SHIFT(8);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_factor: {
|
||||
case ts_symbol_type_factor:
|
||||
SHIFT(5);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_number: {
|
||||
case ts_symbol_type_number:
|
||||
SHIFT(8);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_term: {
|
||||
case ts_symbol_type_term:
|
||||
SHIFT(2);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_expression: {
|
||||
case ts_symbol_type_expression:
|
||||
SHIFT(1);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
ERROR();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
case 1:
|
||||
switch (LOOKAHEAD()) {
|
||||
case ts_symbol_type___END__: {
|
||||
case ts_symbol_type___END__:
|
||||
ACCEPT();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
ERROR();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
case 2:
|
||||
switch (LOOKAHEAD()) {
|
||||
case ts_symbol_type_plus: {
|
||||
case ts_symbol_type_plus:
|
||||
SHIFT(3);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
ERROR();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
case 3:
|
||||
switch (LOOKAHEAD()) {
|
||||
case ts_symbol_type_variable: {
|
||||
case ts_symbol_type_variable:
|
||||
SHIFT(8);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_factor: {
|
||||
case ts_symbol_type_factor:
|
||||
SHIFT(5);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_left_paren: {
|
||||
case ts_symbol_type_left_paren:
|
||||
SHIFT(9);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_number: {
|
||||
case ts_symbol_type_number:
|
||||
SHIFT(8);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_term: {
|
||||
case ts_symbol_type_term:
|
||||
SHIFT(4);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
ERROR();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
case 4:
|
||||
switch (LOOKAHEAD()) {
|
||||
case ts_symbol_type_expression: {
|
||||
case ts_symbol_type_expression:
|
||||
REDUCE(ts_symbol_type_expression, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_term: {
|
||||
case ts_symbol_type_term:
|
||||
REDUCE(ts_symbol_type_expression, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_right_paren: {
|
||||
case ts_symbol_type_right_paren:
|
||||
REDUCE(ts_symbol_type_expression, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_number: {
|
||||
case ts_symbol_type_number:
|
||||
REDUCE(ts_symbol_type_expression, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_factor: {
|
||||
case ts_symbol_type_factor:
|
||||
REDUCE(ts_symbol_type_expression, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_variable: {
|
||||
case ts_symbol_type_variable:
|
||||
REDUCE(ts_symbol_type_expression, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_times: {
|
||||
case ts_symbol_type_times:
|
||||
REDUCE(ts_symbol_type_expression, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_plus: {
|
||||
case ts_symbol_type_plus:
|
||||
REDUCE(ts_symbol_type_expression, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_left_paren: {
|
||||
case ts_symbol_type_left_paren:
|
||||
REDUCE(ts_symbol_type_expression, 3);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
ERROR();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
case 5:
|
||||
switch (LOOKAHEAD()) {
|
||||
case ts_symbol_type_times: {
|
||||
case ts_symbol_type_times:
|
||||
SHIFT(6);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
ERROR();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
case 6:
|
||||
switch (LOOKAHEAD()) {
|
||||
case ts_symbol_type_left_paren: {
|
||||
case ts_symbol_type_left_paren:
|
||||
SHIFT(9);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_number: {
|
||||
case ts_symbol_type_number:
|
||||
SHIFT(8);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_variable: {
|
||||
case ts_symbol_type_variable:
|
||||
SHIFT(8);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_factor: {
|
||||
case ts_symbol_type_factor:
|
||||
SHIFT(7);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
ERROR();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
case 7:
|
||||
switch (LOOKAHEAD()) {
|
||||
case ts_symbol_type_expression: {
|
||||
case ts_symbol_type_expression:
|
||||
REDUCE(ts_symbol_type_term, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_term: {
|
||||
case ts_symbol_type_term:
|
||||
REDUCE(ts_symbol_type_term, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_right_paren: {
|
||||
case ts_symbol_type_right_paren:
|
||||
REDUCE(ts_symbol_type_term, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_number: {
|
||||
case ts_symbol_type_number:
|
||||
REDUCE(ts_symbol_type_term, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_factor: {
|
||||
case ts_symbol_type_factor:
|
||||
REDUCE(ts_symbol_type_term, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_variable: {
|
||||
case ts_symbol_type_variable:
|
||||
REDUCE(ts_symbol_type_term, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_times: {
|
||||
case ts_symbol_type_times:
|
||||
REDUCE(ts_symbol_type_term, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_plus: {
|
||||
case ts_symbol_type_plus:
|
||||
REDUCE(ts_symbol_type_term, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_left_paren: {
|
||||
case ts_symbol_type_left_paren:
|
||||
REDUCE(ts_symbol_type_term, 3);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
ERROR();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
case 8:
|
||||
switch (LOOKAHEAD()) {
|
||||
case ts_symbol_type_expression: {
|
||||
case ts_symbol_type_expression:
|
||||
REDUCE(ts_symbol_type_factor, 1);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_term: {
|
||||
case ts_symbol_type_term:
|
||||
REDUCE(ts_symbol_type_factor, 1);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_right_paren: {
|
||||
case ts_symbol_type_right_paren:
|
||||
REDUCE(ts_symbol_type_factor, 1);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_number: {
|
||||
case ts_symbol_type_number:
|
||||
REDUCE(ts_symbol_type_factor, 1);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_factor: {
|
||||
case ts_symbol_type_factor:
|
||||
REDUCE(ts_symbol_type_factor, 1);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_variable: {
|
||||
case ts_symbol_type_variable:
|
||||
REDUCE(ts_symbol_type_factor, 1);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_times: {
|
||||
case ts_symbol_type_times:
|
||||
REDUCE(ts_symbol_type_factor, 1);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_plus: {
|
||||
case ts_symbol_type_plus:
|
||||
REDUCE(ts_symbol_type_factor, 1);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_left_paren: {
|
||||
case ts_symbol_type_left_paren:
|
||||
REDUCE(ts_symbol_type_factor, 1);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
ERROR();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 9: {
|
||||
case 9:
|
||||
switch (LOOKAHEAD()) {
|
||||
case ts_symbol_type_left_paren: {
|
||||
case ts_symbol_type_left_paren:
|
||||
SHIFT(9);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_variable: {
|
||||
case ts_symbol_type_variable:
|
||||
SHIFT(8);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_factor: {
|
||||
case ts_symbol_type_factor:
|
||||
SHIFT(5);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_number: {
|
||||
case ts_symbol_type_number:
|
||||
SHIFT(8);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_term: {
|
||||
case ts_symbol_type_term:
|
||||
SHIFT(2);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_expression: {
|
||||
case ts_symbol_type_expression:
|
||||
SHIFT(10);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
ERROR();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 10: {
|
||||
case 10:
|
||||
switch (LOOKAHEAD()) {
|
||||
case ts_symbol_type_right_paren: {
|
||||
case ts_symbol_type_right_paren:
|
||||
SHIFT(11);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
ERROR();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 11: {
|
||||
case 11:
|
||||
switch (LOOKAHEAD()) {
|
||||
case ts_symbol_type_expression: {
|
||||
case ts_symbol_type_expression:
|
||||
REDUCE(ts_symbol_type_factor, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_term: {
|
||||
case ts_symbol_type_term:
|
||||
REDUCE(ts_symbol_type_factor, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_right_paren: {
|
||||
case ts_symbol_type_right_paren:
|
||||
REDUCE(ts_symbol_type_factor, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_number: {
|
||||
case ts_symbol_type_number:
|
||||
REDUCE(ts_symbol_type_factor, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_factor: {
|
||||
case ts_symbol_type_factor:
|
||||
REDUCE(ts_symbol_type_factor, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_variable: {
|
||||
case ts_symbol_type_variable:
|
||||
REDUCE(ts_symbol_type_factor, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_times: {
|
||||
case ts_symbol_type_times:
|
||||
REDUCE(ts_symbol_type_factor, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_plus: {
|
||||
case ts_symbol_type_plus:
|
||||
REDUCE(ts_symbol_type_factor, 3);
|
||||
break;
|
||||
}
|
||||
case ts_symbol_type_left_paren: {
|
||||
case ts_symbol_type_left_paren:
|
||||
REDUCE(ts_symbol_type_factor, 3);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
ERROR();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ERROR()
|
||||
}
|
||||
default:
|
||||
ERROR();
|
||||
}
|
||||
done:
|
||||
return PARSE_TREE();
|
||||
FINISH_PARSER();
|
||||
}
|
||||
|
|
|
|||
10
spec/runtime/arithmetic_spec.cpp
Normal file
10
spec/runtime/arithmetic_spec.cpp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#include <igloo/igloo_alt.h>
|
||||
#include "../fixtures/parsers/arithmetic.c"
|
||||
|
||||
using namespace igloo;
|
||||
|
||||
Describe(arithmetic) {
|
||||
It(parses_numbers) {
|
||||
ts_parse_arithmetic("5");
|
||||
};
|
||||
};
|
||||
|
|
@ -30,21 +30,18 @@ namespace tree_sitter {
|
|||
|
||||
string _switch(string condition, string body) {
|
||||
return "switch (" + condition + ") {\n" +
|
||||
indent(body) + "\n" +
|
||||
indent(body) +
|
||||
"}";
|
||||
}
|
||||
|
||||
string _case(string value, string body) {
|
||||
return "case " + value + ": {\n" +
|
||||
indent(body) + "\n" +
|
||||
indent("break;") + "\n"
|
||||
"}\n";
|
||||
return "case " + value + ":\n" +
|
||||
indent(body) + "\n";
|
||||
}
|
||||
|
||||
string _default(string body) {
|
||||
return "default: {\n" +
|
||||
indent(body) + "\n"
|
||||
"}";
|
||||
return "default:\n" +
|
||||
indent(body) + "\n";
|
||||
}
|
||||
|
||||
class CCodeGenerator {
|
||||
|
|
@ -99,7 +96,7 @@ namespace tree_sitter {
|
|||
string body = "";
|
||||
for (int i = 0; i < parse_table.states.size(); i++)
|
||||
body += _case(std::to_string(i), switch_on_lookahead(parse_table.states[i]));
|
||||
body += _default("ERROR()");
|
||||
body += _default("ERROR();");
|
||||
return _switch("PARSE_STATE()", body);
|
||||
}
|
||||
|
||||
|
|
@ -114,18 +111,16 @@ namespace tree_sitter {
|
|||
|
||||
string parse_function() {
|
||||
return
|
||||
"TSTree * ts_parse_arithmetic() {\n" +
|
||||
indent("SETUP_PARSER()") + "\n" +
|
||||
"start:\n" +
|
||||
"TSTree ts_parse_arithmetic(const char *input) {\n" +
|
||||
indent("START_PARSER();") + "\n" +
|
||||
indent(switch_on_current_state(parse_table)) + "\n" +
|
||||
"done:\n" +
|
||||
indent("return PARSE_TREE();") + "\n"
|
||||
indent("FINISH_PARSER();") + "\n"
|
||||
"}";
|
||||
}
|
||||
|
||||
string code() {
|
||||
return
|
||||
"#include <tree_sitter/runtime.h>\n"
|
||||
"#include \"runtime.h\"\n"
|
||||
"#include <stdlib.h>\n"
|
||||
"\n\n" +
|
||||
symbol_enum() +
|
||||
|
|
|
|||
42
src/runtime/parser.c
Normal file
42
src/runtime/parser.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#include "runtime.h"
|
||||
|
||||
|
||||
static int INITIAL_STATE_STACK_SIZE = 100;
|
||||
static int INITIAL_SYMBOL_STACK_SIZE = 100;
|
||||
|
||||
|
||||
TSParser TSParserMake(const char *input) {
|
||||
TSState *state_stack = calloc(INITIAL_STATE_STACK_SIZE, sizeof(*state_stack));
|
||||
TSSymbol *symbol_stack = calloc(INITIAL_SYMBOL_STACK_SIZE, sizeof(*symbol_stack));
|
||||
TSParser result = {
|
||||
.input = input,
|
||||
.tree = TSTreeMake(),
|
||||
.position = 0,
|
||||
.state_stack = state_stack,
|
||||
.symbol_stack = symbol_stack,
|
||||
.state_count = 0,
|
||||
.symbol_count = 0
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
void TSParserShift(TSParser *parser, TSState state) {
|
||||
|
||||
}
|
||||
|
||||
void TSParserReduce(TSParser *parser, TSSymbol symbol, int child_count) {
|
||||
|
||||
}
|
||||
|
||||
void TSParserError(TSParser *parser) {
|
||||
|
||||
}
|
||||
|
||||
TSSymbol TSParserLookahead(const TSParser *parser) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
TSState TSParserState(const TSParser *parser) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
9
src/runtime/tree.c
Normal file
9
src/runtime/tree.c
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include "runtime.h"
|
||||
|
||||
|
||||
TSTree TSTreeMake() {
|
||||
TSTree result = {
|
||||
|
||||
};
|
||||
return result;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue