I did some migration to eclipse. Old code-blocks version still exists. I installed new very simple test framework called minunit. If eclipse doesn't explode, I will use it as main IDE.
parent
67b2379d03
commit
e8018808e1
|
@ -0,0 +1,114 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.cross.exe.debug.1544392496">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cross.exe.debug.1544392496" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cross.exe.debug.1544392496" name="Debug" parent="cdt.managedbuild.config.gnu.cross.exe.debug">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.cross.exe.debug.1544392496." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.exe.debug.2045041315" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.debug">
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.1733237476" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
|
||||
<builder buildPath="${workspace_loc:/Sencha-lang/Debug}" id="cdt.managedbuild.builder.gnu.cross.2091580062" managedBuildOn="true" name="Gnu Make Builder.Debug" superClass="cdt.managedbuild.builder.gnu.cross"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1055356392" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.758256537" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.debugging.level.1319397326" superClass="gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.809384772" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.495732557" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
|
||||
<option id="gnu.cpp.compiler.option.optimization.level.793014755" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.debugging.level.1513381051" superClass="gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.859439950" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.693029150" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.1545256246" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1240442083" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.973026492" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.assembler.1898223694" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.415327363" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.cross.exe.release.1985450505">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cross.exe.release.1985450505" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cross.exe.release.1985450505" name="Release" parent="cdt.managedbuild.config.gnu.cross.exe.release">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.cross.exe.release.1985450505." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.exe.release.1226114014" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.release">
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.676474921" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
|
||||
<builder buildPath="${workspace_loc:/Sencha-lang/Release}" id="cdt.managedbuild.builder.gnu.cross.23375219" managedBuildOn="true" name="Gnu Make Builder.Release" superClass="cdt.managedbuild.builder.gnu.cross"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.671993191" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
|
||||
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.1104799874" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.debugging.level.1423670337" superClass="gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1507898701" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.938543294" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
|
||||
<option id="gnu.cpp.compiler.option.optimization.level.491096180" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.debugging.level.1816198684" superClass="gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.599623873" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.1203418436" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.860949532" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.124143498" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.1698336651" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.assembler.1350015407" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.949134942" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="Sencha-lang.cdt.managedbuild.target.gnu.cross.exe.1970449863" name="Executable" projectType="cdt.managedbuild.target.gnu.cross.exe"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.1985450505;cdt.managedbuild.config.gnu.cross.exe.release.1985450505.;cdt.managedbuild.tool.gnu.cross.c.compiler.671993191;cdt.managedbuild.tool.gnu.c.compiler.input.1507898701">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.1985450505;cdt.managedbuild.config.gnu.cross.exe.release.1985450505.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.938543294;cdt.managedbuild.tool.gnu.cpp.compiler.input.599623873">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1544392496;cdt.managedbuild.config.gnu.cross.exe.debug.1544392496.;cdt.managedbuild.tool.gnu.cross.c.compiler.1055356392;cdt.managedbuild.tool.gnu.c.compiler.input.809384772">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1544392496;cdt.managedbuild.config.gnu.cross.exe.debug.1544392496.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.495732557;cdt.managedbuild.tool.gnu.cpp.compiler.input.859439950">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
</cproject>
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Sencha-lang</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,5 @@
|
|||
Lexer.d: ../Lexer.cpp ../Lexer.h ../Token.h
|
||||
|
||||
../Lexer.h:
|
||||
|
||||
../Token.h:
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
Object.d: ../Object.cpp ../Object.h
|
||||
|
||||
../Object.h:
|
Binary file not shown.
|
@ -0,0 +1,5 @@
|
|||
Parser.d: ../Parser.cpp ../Parser.h ../Token.h
|
||||
|
||||
../Parser.h:
|
||||
|
||||
../Token.h:
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
Token.d: ../Token.cpp ../Token.h
|
||||
|
||||
../Token.h:
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
lexer_tests.d: ../lexer_tests.cpp ../minunit.h
|
||||
|
||||
../minunit.h:
|
Binary file not shown.
|
@ -0,0 +1,7 @@
|
|||
main.d: ../main.cpp ../Token.h ../Lexer.h ../Parser.h
|
||||
|
||||
../Token.h:
|
||||
|
||||
../Lexer.h:
|
||||
|
||||
../Parser.h:
|
Binary file not shown.
|
@ -0,0 +1,58 @@
|
|||
################################################################################
|
||||
# Automatically-generated file. Do not edit!
|
||||
################################################################################
|
||||
|
||||
-include ../makefile.init
|
||||
|
||||
RM := rm -rf
|
||||
|
||||
# All of the sources participating in the build are defined here
|
||||
-include sources.mk
|
||||
-include subdir.mk
|
||||
-include objects.mk
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
ifneq ($(strip $(C++_DEPS)),)
|
||||
-include $(C++_DEPS)
|
||||
endif
|
||||
ifneq ($(strip $(C_DEPS)),)
|
||||
-include $(C_DEPS)
|
||||
endif
|
||||
ifneq ($(strip $(CC_DEPS)),)
|
||||
-include $(CC_DEPS)
|
||||
endif
|
||||
ifneq ($(strip $(CPP_DEPS)),)
|
||||
-include $(CPP_DEPS)
|
||||
endif
|
||||
ifneq ($(strip $(CXX_DEPS)),)
|
||||
-include $(CXX_DEPS)
|
||||
endif
|
||||
ifneq ($(strip $(C_UPPER_DEPS)),)
|
||||
-include $(C_UPPER_DEPS)
|
||||
endif
|
||||
endif
|
||||
|
||||
-include ../makefile.defs
|
||||
|
||||
# Add inputs and outputs from these tool invocations to the build variables
|
||||
|
||||
# All Target
|
||||
all: Sencha-lang
|
||||
|
||||
# Tool invocations
|
||||
Sencha-lang: $(OBJS) $(USER_OBJS)
|
||||
@echo 'Building target: $@'
|
||||
@echo 'Invoking: Cross G++ Linker'
|
||||
g++ -o "Sencha-lang" $(OBJS) $(USER_OBJS) $(LIBS)
|
||||
@echo 'Finished building target: $@'
|
||||
@echo ' '
|
||||
|
||||
# Other Targets
|
||||
clean:
|
||||
-$(RM) $(C++_DEPS)$(OBJS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) Sencha-lang
|
||||
-@echo ' '
|
||||
|
||||
.PHONY: all clean dependents
|
||||
.SECONDARY:
|
||||
|
||||
-include ../makefile.targets
|
|
@ -0,0 +1,8 @@
|
|||
################################################################################
|
||||
# Automatically-generated file. Do not edit!
|
||||
################################################################################
|
||||
|
||||
USER_OBJS :=
|
||||
|
||||
LIBS :=
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
################################################################################
|
||||
# Automatically-generated file. Do not edit!
|
||||
################################################################################
|
||||
|
||||
O_SRCS :=
|
||||
CPP_SRCS :=
|
||||
C_UPPER_SRCS :=
|
||||
C_SRCS :=
|
||||
S_UPPER_SRCS :=
|
||||
OBJ_SRCS :=
|
||||
ASM_SRCS :=
|
||||
CXX_SRCS :=
|
||||
C++_SRCS :=
|
||||
CC_SRCS :=
|
||||
C++_DEPS :=
|
||||
OBJS :=
|
||||
C_DEPS :=
|
||||
CC_DEPS :=
|
||||
CPP_DEPS :=
|
||||
EXECUTABLES :=
|
||||
CXX_DEPS :=
|
||||
C_UPPER_DEPS :=
|
||||
|
||||
# Every subdirectory with source files must be described here
|
||||
SUBDIRS := \
|
||||
. \
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
################################################################################
|
||||
# Automatically-generated file. Do not edit!
|
||||
################################################################################
|
||||
|
||||
# Add inputs and outputs from these tool invocations to the build variables
|
||||
CPP_SRCS += \
|
||||
../Lexer.cpp \
|
||||
../Object.cpp \
|
||||
../Parser.cpp \
|
||||
../Token.cpp \
|
||||
../lexer_tests.cpp \
|
||||
../main.cpp
|
||||
|
||||
OBJS += \
|
||||
./Lexer.o \
|
||||
./Object.o \
|
||||
./Parser.o \
|
||||
./Token.o \
|
||||
./lexer_tests.o \
|
||||
./main.o
|
||||
|
||||
CPP_DEPS += \
|
||||
./Lexer.d \
|
||||
./Object.d \
|
||||
./Parser.d \
|
||||
./Token.d \
|
||||
./lexer_tests.d \
|
||||
./main.d
|
||||
|
||||
|
||||
# Each subdirectory must supply rules for building sources it contributes
|
||||
%.o: ../%.cpp
|
||||
@echo 'Building file: $<'
|
||||
@echo 'Invoking: Cross G++ Compiler'
|
||||
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
|
||||
@echo 'Finished building: $<'
|
||||
@echo ' '
|
||||
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
#include "Lexer.h"
|
||||
|
||||
Lexer::Lexer()
|
||||
{
|
||||
string keys[] = {"function", "class", "for", "while", "if", "else"};
|
||||
keywords.assign(keys, keys+6);
|
||||
|
||||
char punct[] = {'.', ',', ';', '{', '}', '[', ']', '(', ')'};
|
||||
punctuation.assign(punct, punct+9);
|
||||
|
||||
string oper[] = {"<", ">", "+", "-", "/", "*", "%", "&", "|", "=", ":", "==", "+=", "-=", "<=", ">=", "!=", "&&", "||"};
|
||||
operators.assign(oper, oper +19);
|
||||
}
|
||||
|
||||
Lexer::~Lexer()
|
||||
{
|
||||
//dtor
|
||||
}
|
||||
|
||||
void Lexer::add_keyword(string word)
|
||||
{
|
||||
if(!is_keyword(word))
|
||||
{
|
||||
keywords.push_back(word);
|
||||
}
|
||||
}
|
||||
void Lexer::add_punctuation_char(char c)
|
||||
{
|
||||
if(!is_punctuation(c))
|
||||
{
|
||||
punctuation.push_back(c);
|
||||
}
|
||||
}
|
||||
|
||||
void Lexer::add_operator(string oper)
|
||||
{
|
||||
if(!is_operator(oper))
|
||||
{
|
||||
operators.push_back(oper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vector<Token> Lexer::parse_line(string line)
|
||||
{
|
||||
vector<Token> tokens;
|
||||
while(line != "")
|
||||
{
|
||||
pair<string, Token> result_of_parsing = parse_token(line);
|
||||
line = result_of_parsing.first;
|
||||
Token token = result_of_parsing.second;
|
||||
if(token.get_value() != "")
|
||||
{
|
||||
tokens.push_back(token);
|
||||
}
|
||||
}
|
||||
return tokens;
|
||||
|
||||
}
|
||||
|
||||
pair<string, Token> Lexer::parse_token(string line)
|
||||
{
|
||||
string token_value = "";
|
||||
unsigned int i;
|
||||
bool in_char_literal = false;
|
||||
for(i=0; i< line.size(); i++)
|
||||
{
|
||||
if(token_value == "" && isspace(line[i])) continue;
|
||||
|
||||
if(isalnum(line[i]) || line[i] == '\"' || line[i]== '_')
|
||||
{
|
||||
token_value += line[i];
|
||||
if(line[i] == '\"')
|
||||
{
|
||||
if(in_char_literal)
|
||||
{
|
||||
in_char_literal = false;
|
||||
}
|
||||
else in_char_literal = true;
|
||||
}
|
||||
}
|
||||
else if(ispunct(line[i]))
|
||||
{
|
||||
if(token_value=="")
|
||||
{
|
||||
token_value=line[i];
|
||||
i++;
|
||||
if(i<line.size())
|
||||
{
|
||||
if(line[i] == '=')
|
||||
{
|
||||
token_value+=line[i];
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (in_char_literal && isspace(line[i]))
|
||||
{
|
||||
token_value += line[i];
|
||||
}
|
||||
else break;
|
||||
}
|
||||
|
||||
Token token = Token(guess_type(token_value), token_value);
|
||||
string truncated_line = line.substr(i);
|
||||
|
||||
return pair<string, Token>(truncated_line, token);
|
||||
}
|
||||
|
||||
bool Lexer::is_keyword(string value)
|
||||
{
|
||||
for(int i=0; i< keywords.size(); i++)
|
||||
{
|
||||
if(value == keywords[i]) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Lexer::is_punctuation(char c)
|
||||
{
|
||||
|
||||
for(int i=0; i< punctuation.size(); i++)
|
||||
{
|
||||
if(c == punctuation[i]) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Lexer::is_operator(string value)
|
||||
{
|
||||
for(int i=0; i< operators.size(); i++)
|
||||
{
|
||||
if(value == operators[i]) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
type_of_token Lexer::guess_type(string value) //TODO, hey wouldn't it be nice, to implement it?
|
||||
{
|
||||
/* I can have one of these types:
|
||||
typedef enum { t_invalid_token=0, t_symbol, t_integer, t_literal,
|
||||
t_punctuation, t_keyword } type_of_token;
|
||||
|
||||
*/
|
||||
|
||||
if(value == "") return t_invalid_token;
|
||||
if(isdigit(value[0]))
|
||||
{
|
||||
bool is_integer = true;
|
||||
for(int i=1; i<value.size(); i++)
|
||||
{
|
||||
if(!isdigit(value[i])) is_integer = false;
|
||||
}
|
||||
|
||||
if(is_integer) return t_integer;
|
||||
else return t_invalid_token;
|
||||
}
|
||||
if(isalpha(value[0]))
|
||||
{
|
||||
if(is_keyword(value)) return t_keyword;
|
||||
else return t_symbol;
|
||||
|
||||
}
|
||||
|
||||
if(value[0]=='\"')
|
||||
{
|
||||
if(value[value.size()-1] == '\"') return t_literal;
|
||||
else return t_invalid_token;
|
||||
}
|
||||
|
||||
if(value.size() == 1 )
|
||||
{
|
||||
if(is_punctuation(value[0])) return t_punctuation;
|
||||
else
|
||||
{
|
||||
if(is_operator(value)) return t_operator;
|
||||
}
|
||||
}
|
||||
if(value.size() == 2 && is_operator(value)) return t_operator;
|
||||
|
||||
//If any...
|
||||
return t_invalid_token;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef LEXER_H
|
||||
#define LEXER_H
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <cctype>
|
||||
#include <iostream>
|
||||
#include "Token.h"
|
||||
|
||||
using namespace std;
|
||||
class Lexer
|
||||
{
|
||||
public:
|
||||
Lexer();
|
||||
virtual ~Lexer();
|
||||
|
||||
|
||||
|
||||
void add_keyword(string word);
|
||||
void add_punctuation_char(char c);
|
||||
void add_operator(string oper);
|
||||
|
||||
vector<Token> parse_line(string line);
|
||||
pair<string, Token> parse_token(string line);
|
||||
type_of_token guess_type(string value);
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
bool is_keyword(string value);
|
||||
bool is_punctuation(char c);
|
||||
bool is_operator(string value );
|
||||
|
||||
vector<string> keywords;
|
||||
vector<char> punctuation;
|
||||
vector<string> operators;
|
||||
};
|
||||
|
||||
#endif // LEXER_H
|
|
@ -0,0 +1,12 @@
|
|||
#include "Object.h"
|
||||
|
||||
Object::Object()
|
||||
{
|
||||
number_value = 0;
|
||||
//ctor
|
||||
}
|
||||
|
||||
Object::~Object()
|
||||
{
|
||||
//dtor
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef OBJECT_H
|
||||
#define OBJECT_H
|
||||
#include <string>
|
||||
//I don't know how should it look like!
|
||||
class Object
|
||||
{
|
||||
public:
|
||||
Object();
|
||||
virtual ~Object();
|
||||
//Representation of the object
|
||||
std::string str();
|
||||
//Type
|
||||
std::string type();
|
||||
//Possible values
|
||||
double number_value;
|
||||
std::string characters;
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // OBJECT_H
|
|
@ -0,0 +1,295 @@
|
|||
#include "Parser.h"
|
||||
#include "iostream"
|
||||
|
||||
Parser::Parser(vector<Token> tokens)
|
||||
{
|
||||
error_message = "***ERRORS DURING PARSING***\n";
|
||||
report_message = "***PARSER REPORT***\n";
|
||||
token_stream = tokens;
|
||||
position_in_stream = 0;
|
||||
read_next();
|
||||
}
|
||||
|
||||
Parser::~Parser()
|
||||
{
|
||||
//dtor
|
||||
}
|
||||
|
||||
void Parser::report(string s)
|
||||
{
|
||||
report_message += s ;
|
||||
}
|
||||
|
||||
void Parser::error(string s)
|
||||
{
|
||||
error_message += s ;
|
||||
}
|
||||
|
||||
bool Parser::read_next()
|
||||
{
|
||||
if(position_in_stream < token_stream.size())
|
||||
{
|
||||
current_token = token_stream[position_in_stream];
|
||||
tok_value = current_token.get_value();
|
||||
position_in_stream++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_token = Token(t_invalid_token, "");
|
||||
tok_value = current_token.get_value();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::interpret()
|
||||
{
|
||||
while(tok_value!= "")
|
||||
{
|
||||
if(is_type())
|
||||
{
|
||||
report("Identifier: " + tok_value + "\n");
|
||||
read_next();
|
||||
|
||||
if(accept("="))
|
||||
{
|
||||
expr();
|
||||
report(" :=\n");
|
||||
}
|
||||
if(accept(";"))
|
||||
{
|
||||
report("Variable definition\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
expect("(");
|
||||
int argc = 0;
|
||||
while(true)
|
||||
{
|
||||
argc++;
|
||||
is_type();
|
||||
report("function argument: " + tok_value + "\n");
|
||||
read_next();
|
||||
if(peek(")"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
expect(",");
|
||||
}
|
||||
expect(")");
|
||||
|
||||
if(!accept(";"))
|
||||
{
|
||||
report("function body:\n");
|
||||
statement();
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
report("Regular statement:\n");
|
||||
statement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Parser::peek(string s)
|
||||
{
|
||||
return tok_value == s;
|
||||
}
|
||||
|
||||
bool Parser::accept(string s)
|
||||
{
|
||||
if(peek(s))
|
||||
{
|
||||
read_next();
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
bool Parser::expect(string s)
|
||||
{
|
||||
if(!accept(s))
|
||||
{
|
||||
string error_message = "Error: expected ";
|
||||
error_message += s;
|
||||
error_message += " but received: " + tok_value + "\n";
|
||||
|
||||
error(error_message);
|
||||
return false;
|
||||
}
|
||||
else return true;
|
||||
}
|
||||
|
||||
bool Parser::is_type()
|
||||
{
|
||||
if(current_token.get_type() == t_symbol || current_token.get_type() == t_keyword)
|
||||
{
|
||||
if(tok_value == "def" || tok_value == "string" || tok_value == "num")
|
||||
{
|
||||
read_next();
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
void Parser::statement()
|
||||
{
|
||||
if(accept("{"))
|
||||
{
|
||||
while(!accept("}"))
|
||||
{
|
||||
statement();
|
||||
}
|
||||
}
|
||||
else if(is_type())
|
||||
{
|
||||
report("Local variable: " + tok_value + "\n");
|
||||
read_next();
|
||||
if(accept("="))
|
||||
{
|
||||
expr();
|
||||
report(" :=\n");
|
||||
}
|
||||
expect(";");
|
||||
}
|
||||
else if(accept("if"))
|
||||
{
|
||||
//stuff
|
||||
//TODO implement that
|
||||
}
|
||||
else if(accept("while"))
|
||||
{
|
||||
//similar stuff
|
||||
}
|
||||
else if(accept("return"))
|
||||
{
|
||||
|
||||
if(!peek(";"))
|
||||
{
|
||||
expr();
|
||||
}
|
||||
expect(";");
|
||||
report("RETURN\n");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
expr();
|
||||
while(!expect(";")) read_next();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::prim_expr()
|
||||
{
|
||||
if(current_token.get_type() == t_integer)
|
||||
{
|
||||
report("Number: " + tok_value + "\n");
|
||||
}
|
||||
else if(current_token.get_type() == t_symbol)
|
||||
{
|
||||
report("Variable: " + tok_value + "\n");
|
||||
}
|
||||
else if(current_token.get_type() == t_literal)
|
||||
{
|
||||
report("Character literal: " + tok_value + "\n");
|
||||
}
|
||||
else if(accept("("))
|
||||
{
|
||||
expr();
|
||||
expect(")");
|
||||
}
|
||||
else
|
||||
{
|
||||
error("ERROR: unexpected primary expression" + tok_value + "\n");
|
||||
|
||||
}
|
||||
read_next();
|
||||
}
|
||||
|
||||
void Parser::postfix_expr()
|
||||
{
|
||||
prim_expr();
|
||||
if(accept("["))
|
||||
{
|
||||
expr();
|
||||
expect("]");
|
||||
report(" [] ");
|
||||
|
||||
}
|
||||
else if(accept("("))
|
||||
{
|
||||
if(!accept(")"))
|
||||
{
|
||||
expr();
|
||||
report("function argument\n");
|
||||
while(accept(","))
|
||||
{
|
||||
expr();
|
||||
report("function argument\n");
|
||||
}
|
||||
expect(")");
|
||||
}
|
||||
report("FUNC_CALL\n");
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::add_expr()
|
||||
{
|
||||
postfix_expr();
|
||||
while(peek("+") || peek("-"))
|
||||
{
|
||||
if(accept("+"))
|
||||
{
|
||||
postfix_expr();
|
||||
report(" +\n");
|
||||
} else if(accept("-"))
|
||||
{
|
||||
postfix_expr();
|
||||
report(" -\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::rel_expr()
|
||||
{
|
||||
add_expr();
|
||||
while(peek("<"))
|
||||
{
|
||||
accept("<");
|
||||
add_expr();
|
||||
report(" <\n");
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::eq_expr()
|
||||
{
|
||||
rel_expr();
|
||||
while(peek("==") || peek("!="))
|
||||
{
|
||||
if(accept("=="))
|
||||
{
|
||||
rel_expr();
|
||||
report("==\n");
|
||||
}
|
||||
else if(accept("!="))
|
||||
{
|
||||
rel_expr();
|
||||
report("!=\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::expr()
|
||||
{
|
||||
eq_expr();
|
||||
if(accept("="))
|
||||
{
|
||||
expr();
|
||||
report(" := ");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
#ifndef PARSER_H
|
||||
#define PARSER_H
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Token.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
class Parser
|
||||
{
|
||||
public:
|
||||
Parser(vector<Token> tokens);
|
||||
virtual ~Parser();
|
||||
void interpret();
|
||||
string report_message;
|
||||
string error_message;
|
||||
|
||||
|
||||
protected:
|
||||
private:
|
||||
Token current_token;
|
||||
string tok_value;
|
||||
vector<Token> token_stream;
|
||||
int position_in_stream;
|
||||
|
||||
bool read_next();
|
||||
bool peek(string s);
|
||||
bool accept(string s);
|
||||
bool expect(string s);
|
||||
bool is_type();
|
||||
|
||||
void error(string s);
|
||||
void report(string s);
|
||||
|
||||
void statement();
|
||||
|
||||
void add_expr();
|
||||
void prim_expr();
|
||||
void postfix_expr();
|
||||
void rel_expr();
|
||||
void eq_expr();
|
||||
void expr();
|
||||
};
|
||||
|
||||
#endif // PARSER_H
|
|
@ -0,0 +1,2 @@
|
|||
#include "Token.h"
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef TOKEN_H
|
||||
#define TOKEN_H
|
||||
#include <string>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef enum { t_invalid_token=0, t_symbol, t_integer, t_literal,
|
||||
t_punctuation, t_keyword, t_operator, t_float } type_of_token; //t_float not implemented
|
||||
//TODO implement t_float in lexer
|
||||
|
||||
|
||||
class Token
|
||||
{
|
||||
public:
|
||||
type_of_token type;
|
||||
string value;
|
||||
Token() : type(t_invalid_token), value("") {};
|
||||
Token(type_of_token type, string value) : type(type), value(value) { };
|
||||
type_of_token get_type() { return type; };
|
||||
string get_value() { return value; };
|
||||
|
||||
};
|
||||
|
||||
#endif // TOKEN_H
|
|
@ -0,0 +1,58 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include "Token.h"
|
||||
#include "Lexer.h"
|
||||
#include "Parser.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void test_lexer()
|
||||
{
|
||||
string test_line = "def i; bulb; i + 3; string banan; banan = \"banan and other stuff\"; string kaboom(num how_many_times) { def z; }";
|
||||
string test_line2 = "def how_many_trees = 1; how_many_trees + 3 == 2; num cut_tree( num how_many) {return how_many -1; != <=}";
|
||||
Lexer lexer;
|
||||
vector<Token> tokens = lexer.parse_line(test_line);
|
||||
|
||||
|
||||
for(int i=0; i< tokens.size(); i++)
|
||||
{
|
||||
cout << tokens[i].get_value() << " type: " << tokens[i].get_type() << endl;
|
||||
}
|
||||
|
||||
|
||||
tokens = lexer.parse_line(test_line2);
|
||||
|
||||
/*for(int i=0; i< tokens.size(); i++)
|
||||
{
|
||||
cout << tokens[i].get_value() << " type: " << tokens[i].get_type() << endl;
|
||||
}*/
|
||||
}
|
||||
|
||||
void test_parser()
|
||||
{
|
||||
vector<string> lines;
|
||||
lines.push_back("def i; bulb; i + 3; string banan = \"kartofel\"; banan = \"banan\"; string kaboom(num how_many_times) { def z; }");
|
||||
lines.push_back("{ i like bananas; string hello = \"hello\"; hello(); }");
|
||||
lines.push_back("def how_many_trees = 1; how_many_trees + 3 == 2; num cut_tree(num how_many) {return how_many -1;}");
|
||||
Lexer lexer;
|
||||
vector<Token> tokens;
|
||||
for(int i=0; i<lines.size(); i++)
|
||||
{
|
||||
tokens = lexer.parse_line(lines[i]);
|
||||
Parser parser = Parser(tokens);
|
||||
parser.interpret();
|
||||
cout << "<<<Parsing number: " << i << " >>>" << endl;
|
||||
cout << "Instructions: " << endl ;
|
||||
cout << lines[i] << endl << endl;
|
||||
cout << parser.report_message;
|
||||
cout << parser.error_message << endl;
|
||||
}
|
||||
|
||||
}
|
||||
int main()
|
||||
{
|
||||
cout << "Hello world!" << endl;
|
||||
test_parser();
|
||||
//test_lexer();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* minunit.h
|
||||
*
|
||||
* Created on: Nov 2, 2012
|
||||
* Author: attero
|
||||
*/
|
||||
|
||||
#ifndef MINUNIT_H_
|
||||
#define MINUNIT_H_
|
||||
|
||||
#define mu_assert(message, test) do { if (!(test)) return message; } while (0)
|
||||
#define mu_run_test(test) do { char *message = test(); tests_run++; \
|
||||
if (message) return message; } while (0)
|
||||
extern int tests_run;
|
||||
|
||||
|
||||
#endif /* MINUNIT_H_ */
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.1709733272">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.1709733272" moduleId="org.eclipse.cdt.core.settings" name="Build (GNU)">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration buildProperties="" id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.1709733272" name="Build (GNU)" parent="org.eclipse.cdt.build.core.emptycfg">
|
||||
<folderInfo id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.1709733272.940433689" name="/" resourcePath="">
|
||||
<toolChain id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.1507619182" name="org.eclipse.linuxtools.cdt.autotools.core.toolChain" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolChain">
|
||||
<targetPlatform id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform.594452659" isAbstract="false" name="GNU Autotools Target Platform" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform"/>
|
||||
<builder id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder.2141841484" managedBuildOn="false" name="null.Build (GNU)" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder"/>
|
||||
<tool id="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure.447184730" name="configure" superClass="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure">
|
||||
<option id="org.eclipse.linuxtools.cdt.autotools.core.option.configure.name.605453349" superClass="org.eclipse.linuxtools.cdt.autotools.core.option.configure.name" value="org.eclipse.linuxtools.cdt.autotools.core.toolChain.1709733272" valueType="string"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen.2024332737" name="autogen.sh" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen"/>
|
||||
<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc.890759014" name="GCC C Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1879953934" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp.1902945035" name="GCC C++ Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1269568410" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="sencha.null.770789515" name="sencha"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
|
||||
<buildTargets>
|
||||
<target name="sencha" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>sencha</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
</buildTargets>
|
||||
</storageModule>
|
||||
</cproject>
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>sencha</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,12 @@
|
|||
#include "Object.h"
|
||||
|
||||
Object::Object()
|
||||
{
|
||||
number_value = 0;
|
||||
//ctor
|
||||
}
|
||||
|
||||
Object::~Object()
|
||||
{
|
||||
//dtor
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef OBJECT_H
|
||||
#define OBJECT_H
|
||||
#include <string>
|
||||
//I don't know how should it look like!
|
||||
class Object
|
||||
{
|
||||
public:
|
||||
Object();
|
||||
virtual ~Object();
|
||||
//Representation of the object
|
||||
std::string str();
|
||||
//Type
|
||||
std::string type();
|
||||
//Possible values
|
||||
double number_value;
|
||||
std::string characters;
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // OBJECT_H
|
|
@ -90,7 +90,8 @@ void Parser::interpret()
|
|||
statement();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Parser::peek(string s)
|
||||
{
|
||||
return tok_value == s;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <vector>
|
||||
#include "Token.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
class Parser
|
||||
{
|
||||
|
@ -13,6 +14,7 @@ class Parser
|
|||
void interpret();
|
||||
string report_message;
|
||||
string error_message;
|
||||
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* lexer_tests.cpp
|
||||
*
|
||||
* Created on: Nov 2, 2012
|
||||
* Author: attero
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include "minunit.h"
|
||||
|
||||
int tests_run = 0;
|
||||
|
||||
int foo = 7;
|
||||
int bar = 4;
|
||||
|
||||
static char * test_foo() {
|
||||
mu_assert("error, foo != 7", foo == 7);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char * test_bar() {
|
||||
mu_assert("error, bar != 5", bar == 5);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char * all_tests() {
|
||||
mu_run_test(test_foo);
|
||||
mu_run_test(test_bar);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -53,6 +53,6 @@ int main()
|
|||
{
|
||||
cout << "Hello world!" << endl;
|
||||
//test_parser();
|
||||
test_lexer();
|
||||
//test_lexer();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* minunit.h
|
||||
*
|
||||
* Created on: Nov 2, 2012
|
||||
* Author: attero
|
||||
*/
|
||||
|
||||
#ifndef MINUNIT_H_
|
||||
#define MINUNIT_H_
|
||||
|
||||
#define mu_assert(message, test) do { if (!(test)) return message; } while (0)
|
||||
#define mu_run_test(test) do { char *message = test(); tests_run++; \
|
||||
if (message) return message; } while (0)
|
||||
extern int tests_run;
|
||||
|
||||
|
||||
#endif /* MINUNIT_H_ */
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -32,6 +32,12 @@
|
|||
<Add option="-Wall" />
|
||||
<Add option="-fexceptions" />
|
||||
</Compiler>
|
||||
<Unit filename="AppleTree.cpp" />
|
||||
<Unit filename="AppleTree.h" />
|
||||
<Unit filename="Fruit.cpp" />
|
||||
<Unit filename="Fruit.h" />
|
||||
<Unit filename="FruitBasket.cpp" />
|
||||
<Unit filename="FruitBasket.h" />
|
||||
<Unit filename="Lexer.cpp" />
|
||||
<Unit filename="Lexer.h" />
|
||||
<Unit filename="Parser.cpp" />
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
1351424620 /home/attero/development/sencha-lang/sencha/Token.h
|
||||
<string>
|
||||
|
||||
1351540082 source:/home/attero/development/sencha-lang/sencha/Lexer.cpp
|
||||
1351540959 source:/home/attero/development/sencha-lang/sencha/Lexer.cpp
|
||||
"Lexer.h"
|
||||
|
||||
1351539503 /home/attero/development/sencha-lang/sencha/Lexer.h
|
||||
|
@ -16,7 +16,7 @@
|
|||
<iostream>
|
||||
"Token.h"
|
||||
|
||||
1351539590 source:/home/attero/development/sencha-lang/sencha/main.cpp
|
||||
1351541355 source:/home/attero/development/sencha-lang/sencha/main.cpp
|
||||
<iostream>
|
||||
<string>
|
||||
"Token.h"
|
||||
|
@ -27,13 +27,28 @@
|
|||
"Parser.h"
|
||||
"iostream"
|
||||
|
||||
1351539525 /home/attero/development/sencha-lang/sencha/Parser.h
|
||||
1351543306 /home/attero/development/sencha-lang/sencha/Parser.h
|
||||
<string>
|
||||
<vector>
|
||||
"Token.h"
|
||||
"Fruit.h"
|
||||
"FruitBasket.h"
|
||||
|
||||
1351512311 source:/home/attero/development/sencha-lang/sencha/AppleTree.cpp
|
||||
"AppleTree.h"
|
||||
|
||||
1351512311 /home/attero/development/sencha-lang/sencha/AppleTree.h
|
||||
|
||||
1351543287 /home/attero/development/sencha-lang/sencha/Fruit.h
|
||||
<string>
|
||||
|
||||
1351543266 source:/home/attero/development/sencha-lang/sencha/Fruit.cpp
|
||||
"Fruit.h"
|
||||
|
||||
1351542956 source:/home/attero/development/sencha-lang/sencha/FruitBasket.cpp
|
||||
"FruitBasket.h"
|
||||
|
||||
1351543037 /home/attero/development/sencha-lang/sencha/FruitBasket.h
|
||||
<vector>
|
||||
"Fruit.h"
|
||||
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<ActiveTarget name="Debug" />
|
||||
<File name="Fruit.h" open="1" top="0" tabpos="10">
|
||||
<Cursor position="199" topLine="0" />
|
||||
</File>
|
||||
<File name="Lexer.cpp" open="1" top="0" tabpos="4">
|
||||
<Cursor position="1850" topLine="57" />
|
||||
<Cursor position="2314" topLine="88" />
|
||||
</File>
|
||||
<File name="Lexer.h" open="1" top="0" tabpos="5">
|
||||
<Cursor position="378" topLine="8" />
|
||||
<Cursor position="525" topLine="11" />
|
||||
</File>
|
||||
<File name="Parser.cpp" open="1" top="0" tabpos="7">
|
||||
<Cursor position="2767" topLine="98" />
|
||||
<File name="Parser.cpp" open="1" top="1" tabpos="6">
|
||||
<Cursor position="258" topLine="0" />
|
||||
</File>
|
||||
<File name="Parser.h" open="1" top="0" tabpos="7">
|
||||
<Cursor position="136" topLine="0" />
|
||||
</File>
|
||||
<File name="Token.cpp" open="1" top="0" tabpos="3">
|
||||
<Cursor position="22" topLine="0" />
|
||||
|
@ -16,7 +22,7 @@
|
|||
<File name="Token.h" open="1" top="0" tabpos="2">
|
||||
<Cursor position="416" topLine="0" />
|
||||
</File>
|
||||
<File name="main.cpp" open="1" top="1" tabpos="1">
|
||||
<Cursor position="1265" topLine="29" />
|
||||
<File name="main.cpp" open="1" top="0" tabpos="1">
|
||||
<Cursor position="1282" topLine="23" />
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
|
Loading…
Reference in New Issue