updated kerep
This commit is contained in:
parent
6ad607ef15
commit
2defd751ec
10
.gitignore
vendored
10
.gitignore
vendored
@ -1,12 +1,16 @@
|
|||||||
# Build results
|
# build results
|
||||||
bin/
|
bin/
|
||||||
obj/
|
obj/
|
||||||
|
*.log
|
||||||
|
*.tmp
|
||||||
|
|
||||||
# user files
|
# IDE files
|
||||||
.old*/
|
|
||||||
.vs/
|
.vs/
|
||||||
.vshistory/
|
.vshistory/
|
||||||
.editorconfig
|
.editorconfig
|
||||||
*.user
|
*.user
|
||||||
*.vcxproj.filters
|
*.vcxproj.filters
|
||||||
|
|
||||||
|
# other files
|
||||||
|
.old*/
|
||||||
current.config
|
current.config
|
||||||
|
|||||||
76
Makefile
76
Makefile
@ -1,28 +1,56 @@
|
|||||||
###### Build cbuild/default_tasks #######
|
######################################
|
||||||
|
###### Build tasks #######
|
||||||
|
######################################
|
||||||
|
|
||||||
all: build_exec
|
all: build_exec_dbg
|
||||||
|
|
||||||
|
# generates different profile info
|
||||||
|
build_profile:
|
||||||
|
@cbuild/call_task.sh build_profile 2>&1 | tee make_raw.log
|
||||||
|
|
||||||
|
# creates executable using profile info generated by build_profile
|
||||||
|
build_exec: build_profile
|
||||||
|
@cbuild/call_task.sh build_exec 2>&1 | tee -a make_raw.log
|
||||||
|
|
||||||
|
# creates executable with debug info and no optimizations
|
||||||
|
build_exec_dbg:
|
||||||
|
@cbuild/call_task.sh build_exec_dbg 2>&1 | tee make_raw.log
|
||||||
|
|
||||||
|
######################################
|
||||||
|
###### Launch tasks #######
|
||||||
|
######################################
|
||||||
|
|
||||||
|
# executes $EXEC_FILE
|
||||||
|
exec: build_exec
|
||||||
|
@cbuild/call_task.sh exec 2>&1 | tee -a make_raw.log
|
||||||
|
|
||||||
|
# executes $EXEC_FILE
|
||||||
|
exec_dbg: build_exec_dbg
|
||||||
|
@cbuild/call_task.sh exec 2>&1 | tee -a make_raw.log
|
||||||
|
|
||||||
|
# executes $EXEC_FILE with valgrind memory checker
|
||||||
|
valgrind: build_exec_dbg
|
||||||
|
@cbuild/call_task.sh valgrind 2>&1 | tee -a make_raw.log
|
||||||
|
|
||||||
|
######################################
|
||||||
|
###### Other tasks #######
|
||||||
|
######################################
|
||||||
|
|
||||||
|
# deletes generated files
|
||||||
|
clean:
|
||||||
|
@cbuild/call_task.sh clean 2>&1 | tee make_raw.log
|
||||||
|
|
||||||
|
# removes all unreadable characters copied from stdio
|
||||||
|
fix_log:
|
||||||
|
sed 's/[^[:blank:][:print:]]//g' make_raw.log \
|
||||||
|
| sed 's/\[0;[0-9][0-9]m//g' \
|
||||||
|
| sed 's/\[0;[0-9]m//g' \
|
||||||
|
| sed 's/\[[0-9][0-9]m//g' \
|
||||||
|
| sed 's/\[[0-9]m//g' \
|
||||||
|
| sed 's/ H //g' \
|
||||||
|
| sed 's/\[3gH //g' \
|
||||||
|
> make_fixed.log
|
||||||
|
|
||||||
|
# recompile kerep.a in the next build task
|
||||||
rebuild_kerep:
|
rebuild_kerep:
|
||||||
@cbuild/call_task.sh rebuild_kerep
|
@cbuild/call_task.sh rebuild_kerep
|
||||||
|
|
||||||
build_exec:
|
|
||||||
@cbuild/call_task.sh build_exec
|
|
||||||
build_exec_dbg:
|
|
||||||
@cbuild/call_task.sh build_exec_dbg
|
|
||||||
|
|
||||||
build_shared_lib:
|
|
||||||
@cbuild/call_task.sh build_shared_lib
|
|
||||||
build_shared_lib_dbg:
|
|
||||||
@cbuild/call_task.sh build_shared_lib_dbg
|
|
||||||
|
|
||||||
build_static_lib:
|
|
||||||
@cbuild/call_task.sh build_static_lib
|
|
||||||
build_static_lib_dbg:
|
|
||||||
@cbuild/call_task.sh build_static_lib_dbg
|
|
||||||
|
|
||||||
###### Launch cbuild/default_tasks #######
|
|
||||||
exec: build_exec
|
|
||||||
@cbuild/call_task.sh exec
|
|
||||||
|
|
||||||
valgrind: build_exec_dbg
|
|
||||||
@cbuild/call_task.sh
|
|
||||||
|
|||||||
2
cbuild
2
cbuild
@ -1 +1 @@
|
|||||||
Subproject commit 1b38b43c547246ca358a676cee5eda85598ab949
|
Subproject commit 112fcc04652d6ce65fbde215cd3d1f8935db2a7c
|
||||||
@ -1,54 +1,97 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
CBUILD_VERSION=4
|
CBUILD_VERSION=5
|
||||||
CONFIG_VERSION=5
|
CONFIG_VERSION=6
|
||||||
|
|
||||||
PROJECT=cobek
|
PROJECT=cobek
|
||||||
CMP_C=gcc
|
CMP_C=gcc
|
||||||
CMP_CPP=g++
|
CMP_CPP=g++
|
||||||
STD_C=c11
|
STD_C=c11
|
||||||
STD_CPP=c++17
|
STD_CPP=c++17
|
||||||
WARN_C="-Wall -Wno-discarded-qualifiers"
|
WARN_C="-Wall -Wno-discarded-qualifiers -ftrack-macro-expansion=0"
|
||||||
WARN_CPP="-Wall"
|
WARN_CPP="-Wall"
|
||||||
SRC_C="$( find src -name '*.c')"
|
SRC_C="$( find src -name '*.c')"
|
||||||
SRC_CPP="$( find src -name '*.cpp')"
|
SRC_CPP="$( find src -name '*.cpp')"
|
||||||
#TESTS_C="$( find tests -name '*.c')"
|
#TESTS_C="$( find tests -name '*.c')"
|
||||||
#TESTS_CPP="$(find tests -name '*.cpp')"
|
#TESTS_CPP="$(find tests -name '*.cpp')"
|
||||||
|
|
||||||
OUTDIR=bin
|
# OBJDIR structure:
|
||||||
OBJDIR=obj
|
# ├── objects - dir where compiled *.o files are stored. cleans every call of build task
|
||||||
EXEC_FILE=cb2c.com
|
# ├── profile - dir where gcc *.gcda profiling info files stored
|
||||||
|
# ├── libs - there you can put static libs and linker will find them
|
||||||
|
# └── out - output files are created here and then copied to OUTDIR
|
||||||
|
OBJDIR="obj"
|
||||||
|
OUTDIR="bin"
|
||||||
|
|
||||||
case $TASK in
|
# OS-specific options
|
||||||
|
case "$OS" in
|
||||||
|
WINDOWS)
|
||||||
|
EXEC_FILE="$PROJECT.exe"
|
||||||
|
;;
|
||||||
|
LINUX)
|
||||||
|
EXEC_FILE="$PROJECT"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "operating system $OS has no configuration variants"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# TASKS
|
||||||
|
case "$TASK" in
|
||||||
rebuild_kerep)
|
rebuild_kerep)
|
||||||
TASK_SCRIPT=tasks/rebuild_kerep.sh
|
TASK_SCRIPT=tasks/rebuild_kerep.sh
|
||||||
;;
|
;;
|
||||||
build_exec)
|
# generates different profile info
|
||||||
C_ARGS="-O2"
|
build_profile)
|
||||||
|
OUTDIR="$OUTDIR/profile"
|
||||||
|
# -flto applies more optimizations across object files
|
||||||
|
# -flto=auto is needed to multithreaded copilation
|
||||||
|
# -fuse-linker-plugin is required to use static libs with lto, it strips away all
|
||||||
|
# -pg adds code to executable, that generates file containing function call info (gmon.out)
|
||||||
|
# -fprofile-generate
|
||||||
|
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -pg -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects"
|
||||||
CPP_ARGS="$C_ARGS"
|
CPP_ARGS="$C_ARGS"
|
||||||
LINKER_ARGS=""
|
LINKER_ARGS="$CPP_ARGS"
|
||||||
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
|
||||||
PRE_TASK_SCRIPT=tasks/pre_build.sh
|
PRE_TASK_SCRIPT=tasks/pre_build.sh
|
||||||
POST_TASK_SCRIPT=""
|
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||||
|
POST_TASK_SCRIPT=cbuild/default_tasks/profile.sh
|
||||||
KEREP_BUILD_TASK=build_static_lib
|
KEREP_BUILD_TASK=build_static_lib
|
||||||
;;
|
;;
|
||||||
|
# creates executable using profile info generated by build_profile
|
||||||
|
build_exec)
|
||||||
|
# -flto applies more optimizations across object files
|
||||||
|
# -flto=auto is needed to multithreaded copilation
|
||||||
|
# -fuse-linker-plugin is required to use static libs with lto, it strips away all
|
||||||
|
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects"
|
||||||
|
CPP_ARGS="$C_ARGS"
|
||||||
|
LINKER_ARGS="$CPP_ARGS"
|
||||||
|
PRE_TASK_SCRIPT=tasks/pre_build.sh
|
||||||
|
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||||
|
KEREP_BUILD_TASK=build_static_lib
|
||||||
|
;;
|
||||||
|
# creates executable with debug info and no optimizations
|
||||||
build_exec_dbg)
|
build_exec_dbg)
|
||||||
C_ARGS="-O0 -g"
|
C_ARGS="-O0 -g"
|
||||||
CPP_ARGS="$C_ARGS"
|
CPP_ARGS="$C_ARGS"
|
||||||
LINKER_ARGS=""
|
LINKER_ARGS="$CPP_ARGS"
|
||||||
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
|
||||||
PRE_TASK_SCRIPT=tasks/pre_build.sh
|
PRE_TASK_SCRIPT=tasks/pre_build.sh
|
||||||
POST_TASK_SCRIPT=""
|
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||||
KEREP_BUILD_TASK=build_static_lib_dbg
|
KEREP_BUILD_TASK=build_static_lib_dbg
|
||||||
;;
|
;;
|
||||||
|
# executes $EXEC_FILE
|
||||||
exec)
|
exec)
|
||||||
TASK_SCRIPT=cbuild/default_tasks/exec.sh
|
TASK_SCRIPT=cbuild/default_tasks/exec.sh
|
||||||
PRE_TASK_SCRIPT=""
|
|
||||||
POST_TASK_SCRIPT=""
|
|
||||||
;;
|
;;
|
||||||
|
# executes $EXEC_FILE with valgrind memory checker
|
||||||
valgrind)
|
valgrind)
|
||||||
VALGRIND_ARGS="-s --log-file=valgrind.log --read-var-info=yes --track-origins=yes --fullpath-after=$PROJECT/ --leak-check=full --show-leak-kinds=all"
|
VALGRIND_ARGS="-s --log-file=valgrind.log --read-var-info=yes --track-origins=yes --fullpath-after=$PROJECT/ --leak-check=full --show-leak-kinds=all"
|
||||||
TASK_SCRIPT=cbuild/default_tasks/valgrind.sh
|
TASK_SCRIPT=cbuild/default_tasks/valgrind.sh
|
||||||
PRE_TASK_SCRIPT=""
|
|
||||||
POST_TASK_SCRIPT=""
|
|
||||||
;;
|
;;
|
||||||
|
# deletes generated files
|
||||||
|
clean)
|
||||||
|
TASK_SCRIPT=cbuild/default_tasks/clean.sh
|
||||||
|
;;
|
||||||
|
# unknown task
|
||||||
|
*)
|
||||||
|
error "task <$TASK> not found"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
2
kerep
2
kerep
@ -1 +1 @@
|
|||||||
Subproject commit 609dfcf3ed6d454599165e8dd443ba30b95771b2
|
Subproject commit a0458f6d2ef04ce30f5c951281cd7de91bd48cff
|
||||||
@ -8,7 +8,7 @@ Autoarr(Token)* parseFile(char* filename){
|
|||||||
File* srcfile=m_srcfile.value.VoidPtr;
|
File* srcfile=m_srcfile.value.VoidPtr;
|
||||||
char* src;
|
char* src;
|
||||||
tryLast(file_readAll(srcfile, &src), m_srcLen)
|
tryLast(file_readAll(srcfile, &src), m_srcLen)
|
||||||
uint64 srcLen=m_srcLen.value.UInt64;
|
u64 srcLen=m_srcLen.value.UInt64;
|
||||||
kprintf("srclen: %lu\n", srcLen);
|
kprintf("srclen: %lu\n", srcLen);
|
||||||
src[srcLen]='\0';
|
src[srcLen]='\0';
|
||||||
tryLast(lexan(src, filename), m_tokens)
|
tryLast(lexan(src, filename), m_tokens)
|
||||||
@ -42,10 +42,10 @@ int main(const int argc, const char* const* argv){
|
|||||||
}
|
}
|
||||||
kprintf("\n"); return 0;
|
kprintf("\n"); return 0;
|
||||||
// kerep type system
|
// kerep type system
|
||||||
ktDescriptors_beginInit();
|
kt_beginInit();
|
||||||
ktDescriptors_initKerepTypes();
|
kt_initKerepTypes();
|
||||||
ktDescriptors_initCbLexerTypes();
|
kt_initCbLexerTypes();
|
||||||
ktDescriptors_endInit();
|
kt_endInit();
|
||||||
// keywords search tree
|
// keywords search tree
|
||||||
init_keywordsSearchTree();
|
init_keywordsSearchTree();
|
||||||
kprint(kp_s|kp_fgGray, "keywordsSearchTree: ", kp_h|kp_pre, keywordsSearchTree, kp_c, '\n');
|
kprint(kp_s|kp_fgGray, "keywordsSearchTree: ", kp_h|kp_pre, keywordsSearchTree, kp_c, '\n');
|
||||||
|
|||||||
@ -3,35 +3,35 @@
|
|||||||
#include "../../kerep/src/base/base.h"
|
#include "../../kerep/src/base/base.h"
|
||||||
#include "tokens.h"
|
#include "tokens.h"
|
||||||
|
|
||||||
typedef struct ContextStruct Context;
|
|
||||||
|
|
||||||
PACK_ENUM(ContextType,
|
PACKED_ENUM(ContextType,
|
||||||
CT_Namespace,
|
CT_Namespace,
|
||||||
CT_Function,
|
CT_Class,
|
||||||
CT_Class
|
CT_Function
|
||||||
)
|
)
|
||||||
|
|
||||||
struct ContextStruct {
|
typedef struct Context Context;
|
||||||
|
STRUCT(Context,
|
||||||
char* name;
|
char* name;
|
||||||
Context* parent;
|
Context* parent;
|
||||||
Autoarr(Token)* tokens;
|
Autoarr(Token)* tokens;
|
||||||
ContextType type;
|
ContextType type;
|
||||||
};
|
)
|
||||||
|
|
||||||
typedef struct NamespaceContext{
|
STRUCT(NamespaceContext,
|
||||||
Context base;
|
Context base;
|
||||||
} NamespaceContext;
|
)
|
||||||
|
|
||||||
typedef struct FunctionContext {
|
STRUCT(ClassContext,
|
||||||
|
Context base;
|
||||||
|
Autoarr(Token)* attributes;
|
||||||
|
Token accessModifier;
|
||||||
|
)
|
||||||
|
|
||||||
|
STRUCT(FunctionContext,
|
||||||
Context base;
|
Context base;
|
||||||
Autoarr(Token)* arguments;
|
Autoarr(Token)* arguments;
|
||||||
Autoarr(Token)* attributes;
|
Autoarr(Token)* attributes;
|
||||||
Token accessModifier;
|
Token accessModifier;
|
||||||
Token returnType;
|
Token returnType;
|
||||||
} FunctionContext;
|
)
|
||||||
|
|
||||||
typedef struct ClassContext {
|
|
||||||
Context base;
|
|
||||||
Autoarr(Token)* attributes;
|
|
||||||
Token accessModifier;
|
|
||||||
} ClassContext;
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
|
|
||||||
void ktDescriptors_initCbLexerTypes(){
|
void kt_initCbLexerTypes(){
|
||||||
kt_register(Token, NULL, NULL);
|
kt_register(Token);
|
||||||
kt_register(Autoarr_Token, ____Autoarr_free_Token, NULL);
|
kt_register(Autoarr_Token);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,16 +1,16 @@
|
|||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
#include "../../kerep/src/String/string.h"
|
#include "../../kerep/src/String/string.h"
|
||||||
|
|
||||||
typedef struct SharedLexerData{
|
STRUCT(SharedLexerData,
|
||||||
char* _source;
|
char* _source;
|
||||||
char* _filename;
|
char* _filename;
|
||||||
Autoarr(Token)* _tokens;
|
Autoarr(Token)* _tokens;
|
||||||
string _context;
|
string _context;
|
||||||
string _line;
|
string _line;
|
||||||
string _label;
|
string _label;
|
||||||
uint32 _linenum;
|
u32 _linenum;
|
||||||
uint32 _charnum;
|
u32 _charnum;
|
||||||
} SharedLexerData;
|
)
|
||||||
|
|
||||||
#define source sld->_source
|
#define source sld->_source
|
||||||
#define filename sld->_filename
|
#define filename sld->_filename
|
||||||
|
|||||||
@ -6,4 +6,4 @@
|
|||||||
//Autoarr(Token)*
|
//Autoarr(Token)*
|
||||||
Maybe lexan(char* source, char* filename);
|
Maybe lexan(char* source, char* filename);
|
||||||
|
|
||||||
void ktDescriptors_initCbLexerTypes();
|
void kt_initCbLexerTypes();
|
||||||
@ -1,7 +1,17 @@
|
|||||||
#include "tokens.h"
|
#include "tokens.h"
|
||||||
|
|
||||||
ktid_define(Token);
|
void Token_freeMembers(void* _t){
|
||||||
Autoarr_define(Token)
|
Token* t=(Token*)_t;
|
||||||
|
if(t->on_heap)
|
||||||
|
free(t->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* Token_toString(void* _t, u32 fmt){
|
||||||
|
return cptr_copy(((Token*)_t)->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
kt_define(Token, Token_freeMembers, Token_toString);
|
||||||
|
Autoarr_define(Token, false)
|
||||||
|
|
||||||
|
|
||||||
STNode* keywordsSearchTree=NULL;
|
STNode* keywordsSearchTree=NULL;
|
||||||
|
|||||||
@ -3,28 +3,28 @@
|
|||||||
#include "../../kerep/src/Autoarr/Autoarr.h"
|
#include "../../kerep/src/Autoarr/Autoarr.h"
|
||||||
#include "../../kerep/src/SearchTree/SearchTree.h"
|
#include "../../kerep/src/SearchTree/SearchTree.h"
|
||||||
|
|
||||||
PACK_ENUM(TokenId,
|
PACKED_ENUM(TokenId,
|
||||||
// base types
|
/* base types */
|
||||||
tok_void_t,
|
tok_void_t,
|
||||||
tok_int8_t,
|
tok_i8_t,
|
||||||
tok_uint8_t,
|
tok_u8_t,
|
||||||
tok_int16_t,
|
tok_i16_t,
|
||||||
tok_uint16_t,
|
tok_u16_t,
|
||||||
tok_int32_t,
|
tok_i32_t,
|
||||||
tok_uint32_t,
|
tok_u32_t,
|
||||||
tok_int64_t,
|
tok_i64_t,
|
||||||
tok_uint64_t,
|
tok_u64_t,
|
||||||
tok_char_t, //ascii
|
tok_char_t, /* ansi */
|
||||||
tok_char8_t, //utf8
|
tok_char8_t, /* utf8 *? */
|
||||||
tok_char16_t, //utf16
|
tok_char16_t, /* utf16 */
|
||||||
tok_bool_t,
|
tok_bool_t,
|
||||||
tok_float32_t,
|
tok_f32_t,
|
||||||
tok_float64_t,
|
tok_f64_t,
|
||||||
// constant
|
/* constant */
|
||||||
tok_null,
|
tok_null,
|
||||||
tok_true,
|
tok_true,
|
||||||
tok_false,
|
tok_false,
|
||||||
// control flow operators
|
/* control flow operators */
|
||||||
tok_if,
|
tok_if,
|
||||||
tok_else,
|
tok_else,
|
||||||
tok_for,
|
tok_for,
|
||||||
@ -35,7 +35,7 @@ PACK_ENUM(TokenId,
|
|||||||
tok_braketo,
|
tok_braketo,
|
||||||
tok_return,
|
tok_return,
|
||||||
tok_goto,
|
tok_goto,
|
||||||
// declaration keywords
|
/* declaration keywords */
|
||||||
tok_class,
|
tok_class,
|
||||||
tok_struct,
|
tok_struct,
|
||||||
tok_enum,
|
tok_enum,
|
||||||
@ -43,7 +43,7 @@ PACK_ENUM(TokenId,
|
|||||||
tok_event,
|
tok_event,
|
||||||
tok_import,
|
tok_import,
|
||||||
tok_alias,
|
tok_alias,
|
||||||
// access modifiers
|
/* access modifiers */
|
||||||
tok_static,
|
tok_static,
|
||||||
tok_const,
|
tok_const,
|
||||||
tok_readonly,
|
tok_readonly,
|
||||||
@ -53,45 +53,45 @@ PACK_ENUM(TokenId,
|
|||||||
tok_virtual,
|
tok_virtual,
|
||||||
tok_override,
|
tok_override,
|
||||||
tok_partial,
|
tok_partial,
|
||||||
// allocation keywords
|
/* allocation keywords */
|
||||||
tok_new, // allocates struct in heap
|
tok_new, /* allocates struct in heap */
|
||||||
tok_sizeof, // size of variable value
|
tok_sizeof, /* size of variable value */
|
||||||
tok_typeof, // type of variable
|
tok_typeof, /* type of variable */
|
||||||
// special characters
|
/* special characters */
|
||||||
tok_lbracket, // (
|
tok_lbracket, /* ( */
|
||||||
tok_lbracket_fi, // {
|
tok_lbracket_fi, /* { */
|
||||||
tok_lbracket_sq, // [
|
tok_lbracket_sq, /* [ */
|
||||||
tok_rbracket, // )
|
tok_rbracket, /* ) */
|
||||||
tok_rbracket_fi, // }
|
tok_rbracket_fi, /* } */
|
||||||
tok_rbracket_sq, // ]
|
tok_rbracket_sq, /* ] */
|
||||||
tok_less, // <
|
tok_less, /* < */
|
||||||
tok_more, // >
|
tok_more, /* > */
|
||||||
tok_plus, // +
|
tok_plus, /* + */
|
||||||
tok_minus, // -
|
tok_minus, /* - */
|
||||||
tok_asterisk, // *
|
tok_asterisk, /* * */
|
||||||
tok_slash, // /
|
tok_slash, /* / */
|
||||||
tok_assign, // =
|
tok_assign, /* = */
|
||||||
tok_not, // !
|
tok_not, /* ! */
|
||||||
tok_equals, // ==
|
tok_equals, /* == */
|
||||||
tok_not_equals, // !=
|
tok_not_equals, /* != */
|
||||||
tok_and, // &
|
tok_and, /* & */
|
||||||
tok_and_d, // &&
|
tok_and_d, /* && */
|
||||||
tok_or, // |
|
tok_or, /* | */
|
||||||
tok_or_d, // ||
|
tok_or_d, /* || */
|
||||||
tok_question, // ?
|
tok_question, /* ? */
|
||||||
tok_question_d, // ??
|
tok_question_d, /* ?? */
|
||||||
tok_colon, // :
|
tok_colon, /* : */
|
||||||
tok_semicolon, // ;
|
tok_semicolon, /* ; */
|
||||||
tok_point, // .
|
tok_point, /* . */
|
||||||
tok_comma, // ,
|
tok_comma, /* , */
|
||||||
tok_tilda, // ~
|
tok_tilda, /* ~ */
|
||||||
tok_backslash, // \ /
|
tok_backslash, /* \ / */
|
||||||
tok_percent, // %
|
tok_percent, /* % */
|
||||||
tok_xor, // ^
|
tok_xor, /* ^ */
|
||||||
tok_lattice, // #
|
tok_lattice, /* # */
|
||||||
tok_dollar, // $
|
tok_dollar, /* $ */
|
||||||
tok_at, // @
|
tok_at, /* @ */
|
||||||
// user-defined
|
/* user-defined */
|
||||||
tok_label,
|
tok_label,
|
||||||
tok_number,
|
tok_number,
|
||||||
tok_character,
|
tok_character,
|
||||||
@ -99,11 +99,11 @@ PACK_ENUM(TokenId,
|
|||||||
tok_comment
|
tok_comment
|
||||||
)
|
)
|
||||||
|
|
||||||
typedef struct Token{
|
STRUCT(Token,
|
||||||
char* value;
|
char* value;
|
||||||
TokenId id;
|
TokenId id;
|
||||||
} Token;
|
bool on_heap; // allocated on stack or heap
|
||||||
ktid_declare(Token);
|
)
|
||||||
Autoarr_declare(Token)
|
Autoarr_declare(Token)
|
||||||
|
|
||||||
extern STNode* keywordsSearchTree;
|
extern STNode* keywordsSearchTree;
|
||||||
@ -112,27 +112,27 @@ void init_keywordsSearchTree();
|
|||||||
|
|
||||||
|
|
||||||
static const Token default_tokens[]={
|
static const Token default_tokens[]={
|
||||||
// base types
|
/* base types */
|
||||||
{"void", tok_void_t},
|
{"void", tok_void_t},
|
||||||
{"int8", tok_int8_t},
|
{"i8", tok_i8_t},
|
||||||
{"uint8", tok_uint8_t},
|
{"u8", tok_u8_t},
|
||||||
{"int16", tok_int16_t},
|
{"i16", tok_i16_t},
|
||||||
{"uint16", tok_uint16_t},
|
{"u16", tok_u16_t},
|
||||||
{"int32", tok_int32_t},
|
{"i32", tok_i32_t},
|
||||||
{"uint32", tok_uint32_t},
|
{"u32", tok_u32_t},
|
||||||
{"int64", tok_int64_t},
|
{"i64", tok_i64_t},
|
||||||
{"uint64", tok_uint64_t},
|
{"u64", tok_u64_t},
|
||||||
{"char", tok_char_t},
|
{"char", tok_char_t},
|
||||||
{"char8", tok_char8_t},
|
{"char8", tok_char8_t},
|
||||||
{"char16", tok_char16_t},
|
{"char16", tok_char16_t},
|
||||||
{"bool", tok_bool_t},
|
{"bool", tok_bool_t},
|
||||||
{"float32", tok_float32_t},
|
{"f32", tok_f32_t},
|
||||||
{"float64", tok_float64_t},
|
{"f64", tok_f64_t},
|
||||||
// constant
|
/* constant */
|
||||||
{"null", tok_null},
|
{"null", tok_null},
|
||||||
{"true", tok_true},
|
{"true", tok_true},
|
||||||
{"false", tok_false},
|
{"false", tok_false},
|
||||||
// control flow operators
|
/* control flow operators */
|
||||||
{"if", tok_if},
|
{"if", tok_if},
|
||||||
{"else", tok_else},
|
{"else", tok_else},
|
||||||
{"for", tok_for},
|
{"for", tok_for},
|
||||||
@ -143,7 +143,7 @@ static const Token default_tokens[]={
|
|||||||
{"braketo", tok_braketo},
|
{"braketo", tok_braketo},
|
||||||
{"return", tok_return},
|
{"return", tok_return},
|
||||||
{"goto", tok_goto},
|
{"goto", tok_goto},
|
||||||
// declaration keywords
|
/* declaration keywords */
|
||||||
{"class", tok_class},
|
{"class", tok_class},
|
||||||
{"struct", tok_struct},
|
{"struct", tok_struct},
|
||||||
{"enum", tok_enum},
|
{"enum", tok_enum},
|
||||||
@ -151,7 +151,7 @@ static const Token default_tokens[]={
|
|||||||
{"event", tok_event},
|
{"event", tok_event},
|
||||||
{"import", tok_import},
|
{"import", tok_import},
|
||||||
{"alias", tok_alias},
|
{"alias", tok_alias},
|
||||||
// access modifiers
|
/* access modifiers */
|
||||||
{"static", tok_static},
|
{"static", tok_static},
|
||||||
{"const", tok_const},
|
{"const", tok_const},
|
||||||
{"readonly", tok_readonly},
|
{"readonly", tok_readonly},
|
||||||
@ -161,11 +161,11 @@ static const Token default_tokens[]={
|
|||||||
{"virtual", tok_virtual},
|
{"virtual", tok_virtual},
|
||||||
{"override", tok_override},
|
{"override", tok_override},
|
||||||
{"partial", tok_partial},
|
{"partial", tok_partial},
|
||||||
// allocation keywords
|
/* allocation keywords */
|
||||||
{"new", tok_new},
|
{"new", tok_new},
|
||||||
{"sizeof", tok_sizeof},
|
{"sizeof", tok_sizeof},
|
||||||
{"typeof", tok_typeof},
|
{"typeof", tok_typeof},
|
||||||
// special characters
|
/* special characters */
|
||||||
{"(", tok_lbracket},
|
{"(", tok_lbracket},
|
||||||
{"{", tok_lbracket_fi},
|
{"{", tok_lbracket_fi},
|
||||||
{"[", tok_lbracket_sq},
|
{"[", tok_lbracket_sq},
|
||||||
|
|||||||
4
tasks/clean_additions.sh
Normal file
4
tasks/clean_additions.sh
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
myprint "${WHITE}deleting .kerep_rebuild.tmp"
|
||||||
|
rm -rf .kerep_rebuild.tmp
|
||||||
@ -1,13 +1,17 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ ! -f "kerep/bin/kerep.a" ] || [ -f .rebuild_kerep ]
|
# check if kerep static lib exists or kerep_rebuild task was executed
|
||||||
then
|
if [ ! -f "$OBJDIR/libs/kerep.a" ] || [ -f .rebuild_kerep.tmp ]; then
|
||||||
|
[[ -z "$KEREP_BUILD_TASK" ]] && error "KEREP_BUILD_TASK is empty"
|
||||||
|
myprint "${BLUE}making kerep task <$KEREP_BUILD_TASK>"
|
||||||
|
|
||||||
cd kerep
|
cd kerep
|
||||||
if ! make "$KEREP_BUILD_TASK"; then
|
if ! make "$KEREP_BUILD_TASK"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
cd ..
|
cd ..
|
||||||
rm -rf .rebuild_kerep
|
|
||||||
|
cp kerep/bin/kerep.a $OBJDIR/libs/
|
||||||
|
myprint "${GREEN}copied ${CYAN}kerep.a"
|
||||||
|
rm -f .rebuild_kerep.tmp
|
||||||
fi
|
fi
|
||||||
cp kerep/bin/kerep.a obj/
|
|
||||||
printf "${GREEN}copied ${CYAN}kerep.a\n"
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
touch .rebuild_kerep
|
touch .rebuild_kerep.tmp
|
||||||
printf "kerep.a will be rebuilt in the next build task"
|
myprint "${YELLOW}kerep.a will be rebuilt in the next build task"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user