Replace the recursive-descent parser that built an AST (Node* tree) with a single-pass compiler that emits bytecode directly into a Block structure. Remove the parser.c/parser.h files and their AST node types (NodeLiteral, NodeCall, NodeBinaryOp, etc.), add new compiler.c/compiler.h with a Compiler struct and Pratt-style precedence parsing that outputs CODE_CONSTANT and CODE_END instructions, and introduce vm.c/vm.h containing a Fiber-based interpreter with a stack, interpret() loop, and printValue() for OBJ_INT. Update main.c to call compile() then interpret() instead of parse(), remove TOKEN_INDENT/TOKEN_OUTDENT from token.h and dumpTokens(), and adjust the Xcode project to include the new source files while excluding the old parser.
260 lines
9.7 KiB
Plaintext
260 lines
9.7 KiB
Plaintext
// !$*UTF8*$!
|
|
{
|
|
archiveVersion = 1;
|
|
classes = {
|
|
};
|
|
objectVersion = 46;
|
|
objects = {
|
|
|
|
/* Begin PBXBuildFile section */
|
|
29AB1F281816E49C004B501E /* lexer.c in Sources */ = {isa = PBXBuildFile; fileRef = 29AB1F1E1816E49C004B501E /* lexer.c */; };
|
|
29AB1F291816E49C004B501E /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 29AB1F201816E49C004B501E /* main.c */; };
|
|
29AB1F2C1816E49C004B501E /* token.c in Sources */ = {isa = PBXBuildFile; fileRef = 29AB1F251816E49C004B501E /* token.c */; };
|
|
29AB1F2F1816FA66004B501E /* vm.c in Sources */ = {isa = PBXBuildFile; fileRef = 29AB1F2E1816FA66004B501E /* vm.c */; };
|
|
29AB1F3218170104004B501E /* compiler.c in Sources */ = {isa = PBXBuildFile; fileRef = 29AB1F3018170104004B501E /* compiler.c */; };
|
|
/* End PBXBuildFile section */
|
|
|
|
/* Begin PBXCopyFilesBuildPhase section */
|
|
29AB1F041816E3AD004B501E /* CopyFiles */ = {
|
|
isa = PBXCopyFilesBuildPhase;
|
|
buildActionMask = 2147483647;
|
|
dstPath = /usr/share/man/man1/;
|
|
dstSubfolderSpec = 0;
|
|
files = (
|
|
);
|
|
runOnlyForDeploymentPostprocessing = 1;
|
|
};
|
|
/* End PBXCopyFilesBuildPhase section */
|
|
|
|
/* Begin PBXFileReference section */
|
|
29AB1F061816E3AD004B501E /* wren */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = wren; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
29AB1F1E1816E49C004B501E /* lexer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lexer.c; path = src/lexer.c; sourceTree = SOURCE_ROOT; };
|
|
29AB1F1F1816E49C004B501E /* lexer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lexer.h; path = src/lexer.h; sourceTree = SOURCE_ROOT; };
|
|
29AB1F201816E49C004B501E /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = main.c; path = src/main.c; sourceTree = SOURCE_ROOT; };
|
|
29AB1F251816E49C004B501E /* token.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = token.c; path = src/token.c; sourceTree = SOURCE_ROOT; };
|
|
29AB1F261816E49C004B501E /* token.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = token.h; path = src/token.h; sourceTree = SOURCE_ROOT; };
|
|
29AB1F271816E49C004B501E /* wren.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; name = wren.1; path = src/wren.1; sourceTree = SOURCE_ROOT; };
|
|
29AB1F2D1816FA5B004B501E /* vm.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = vm.h; path = src/vm.h; sourceTree = SOURCE_ROOT; };
|
|
29AB1F2E1816FA66004B501E /* vm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = vm.c; path = src/vm.c; sourceTree = SOURCE_ROOT; };
|
|
29AB1F3018170104004B501E /* compiler.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = compiler.c; path = src/compiler.c; sourceTree = SOURCE_ROOT; };
|
|
29AB1F3118170104004B501E /* compiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = compiler.h; path = src/compiler.h; sourceTree = SOURCE_ROOT; };
|
|
/* End PBXFileReference section */
|
|
|
|
/* Begin PBXFrameworksBuildPhase section */
|
|
29AB1F031816E3AD004B501E /* Frameworks */ = {
|
|
isa = PBXFrameworksBuildPhase;
|
|
buildActionMask = 2147483647;
|
|
files = (
|
|
);
|
|
runOnlyForDeploymentPostprocessing = 0;
|
|
};
|
|
/* End PBXFrameworksBuildPhase section */
|
|
|
|
/* Begin PBXGroup section */
|
|
29AB1EFD1816E3AD004B501E = {
|
|
isa = PBXGroup;
|
|
children = (
|
|
29AB1F081816E3AD004B501E /* src */,
|
|
29AB1F071816E3AD004B501E /* Products */,
|
|
);
|
|
sourceTree = "<group>";
|
|
};
|
|
29AB1F071816E3AD004B501E /* Products */ = {
|
|
isa = PBXGroup;
|
|
children = (
|
|
29AB1F061816E3AD004B501E /* wren */,
|
|
);
|
|
name = Products;
|
|
sourceTree = "<group>";
|
|
};
|
|
29AB1F081816E3AD004B501E /* src */ = {
|
|
isa = PBXGroup;
|
|
children = (
|
|
29AB1F3018170104004B501E /* compiler.c */,
|
|
29AB1F3118170104004B501E /* compiler.h */,
|
|
29AB1F1E1816E49C004B501E /* lexer.c */,
|
|
29AB1F1F1816E49C004B501E /* lexer.h */,
|
|
29AB1F201816E49C004B501E /* main.c */,
|
|
29AB1F251816E49C004B501E /* token.c */,
|
|
29AB1F261816E49C004B501E /* token.h */,
|
|
29AB1F2E1816FA66004B501E /* vm.c */,
|
|
29AB1F2D1816FA5B004B501E /* vm.h */,
|
|
29AB1F271816E49C004B501E /* wren.1 */,
|
|
);
|
|
name = src;
|
|
path = wren;
|
|
sourceTree = "<group>";
|
|
};
|
|
/* End PBXGroup section */
|
|
|
|
/* Begin PBXNativeTarget section */
|
|
29AB1F051816E3AD004B501E /* wren */ = {
|
|
isa = PBXNativeTarget;
|
|
buildConfigurationList = 29AB1F0F1816E3AD004B501E /* Build configuration list for PBXNativeTarget "wren" */;
|
|
buildPhases = (
|
|
29AB1F021816E3AD004B501E /* Sources */,
|
|
29AB1F031816E3AD004B501E /* Frameworks */,
|
|
29AB1F041816E3AD004B501E /* CopyFiles */,
|
|
);
|
|
buildRules = (
|
|
);
|
|
dependencies = (
|
|
);
|
|
name = wren;
|
|
productName = wren;
|
|
productReference = 29AB1F061816E3AD004B501E /* wren */;
|
|
productType = "com.apple.product-type.tool";
|
|
};
|
|
/* End PBXNativeTarget section */
|
|
|
|
/* Begin PBXProject section */
|
|
29AB1EFE1816E3AD004B501E /* Project object */ = {
|
|
isa = PBXProject;
|
|
attributes = {
|
|
LastUpgradeCheck = 0500;
|
|
ORGANIZATIONNAME = "Bob Nystrom";
|
|
};
|
|
buildConfigurationList = 29AB1F011816E3AD004B501E /* Build configuration list for PBXProject "wren" */;
|
|
compatibilityVersion = "Xcode 3.2";
|
|
developmentRegion = English;
|
|
hasScannedForEncodings = 0;
|
|
knownRegions = (
|
|
en,
|
|
);
|
|
mainGroup = 29AB1EFD1816E3AD004B501E;
|
|
productRefGroup = 29AB1F071816E3AD004B501E /* Products */;
|
|
projectDirPath = "";
|
|
projectRoot = "";
|
|
targets = (
|
|
29AB1F051816E3AD004B501E /* wren */,
|
|
);
|
|
};
|
|
/* End PBXProject section */
|
|
|
|
/* Begin PBXSourcesBuildPhase section */
|
|
29AB1F021816E3AD004B501E /* Sources */ = {
|
|
isa = PBXSourcesBuildPhase;
|
|
buildActionMask = 2147483647;
|
|
files = (
|
|
29AB1F291816E49C004B501E /* main.c in Sources */,
|
|
29AB1F3218170104004B501E /* compiler.c in Sources */,
|
|
29AB1F2F1816FA66004B501E /* vm.c in Sources */,
|
|
29AB1F2C1816E49C004B501E /* token.c in Sources */,
|
|
29AB1F281816E49C004B501E /* lexer.c in Sources */,
|
|
);
|
|
runOnlyForDeploymentPostprocessing = 0;
|
|
};
|
|
/* End PBXSourcesBuildPhase section */
|
|
|
|
/* Begin XCBuildConfiguration section */
|
|
29AB1F0D1816E3AD004B501E /* Debug */ = {
|
|
isa = XCBuildConfiguration;
|
|
buildSettings = {
|
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++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;
|
|
MACOSX_DEPLOYMENT_TARGET = 10.8;
|
|
ONLY_ACTIVE_ARCH = YES;
|
|
SDKROOT = macosx;
|
|
};
|
|
name = Debug;
|
|
};
|
|
29AB1F0E1816E3AD004B501E /* Release */ = {
|
|
isa = XCBuildConfiguration;
|
|
buildSettings = {
|
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++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;
|
|
MACOSX_DEPLOYMENT_TARGET = 10.8;
|
|
SDKROOT = macosx;
|
|
};
|
|
name = Release;
|
|
};
|
|
29AB1F101816E3AD004B501E /* Debug */ = {
|
|
isa = XCBuildConfiguration;
|
|
buildSettings = {
|
|
GCC_C_LANGUAGE_STANDARD = c89;
|
|
GCC_WARN_PEDANTIC = NO;
|
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
};
|
|
name = Debug;
|
|
};
|
|
29AB1F111816E3AD004B501E /* Release */ = {
|
|
isa = XCBuildConfiguration;
|
|
buildSettings = {
|
|
GCC_C_LANGUAGE_STANDARD = c89;
|
|
GCC_WARN_PEDANTIC = NO;
|
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
};
|
|
name = Release;
|
|
};
|
|
/* End XCBuildConfiguration section */
|
|
|
|
/* Begin XCConfigurationList section */
|
|
29AB1F011816E3AD004B501E /* Build configuration list for PBXProject "wren" */ = {
|
|
isa = XCConfigurationList;
|
|
buildConfigurations = (
|
|
29AB1F0D1816E3AD004B501E /* Debug */,
|
|
29AB1F0E1816E3AD004B501E /* Release */,
|
|
);
|
|
defaultConfigurationIsVisible = 0;
|
|
defaultConfigurationName = Release;
|
|
};
|
|
29AB1F0F1816E3AD004B501E /* Build configuration list for PBXNativeTarget "wren" */ = {
|
|
isa = XCConfigurationList;
|
|
buildConfigurations = (
|
|
29AB1F101816E3AD004B501E /* Debug */,
|
|
29AB1F111816E3AD004B501E /* Release */,
|
|
);
|
|
defaultConfigurationIsVisible = 0;
|
|
};
|
|
/* End XCConfigurationList section */
|
|
};
|
|
rootObject = 29AB1EFE1816E3AD004B501E /* Project object */;
|
|
}
|