lexer doc section setup

master
Allen Webster 2016-09-05 11:44:19 -04:00
parent 4dc20d8fec
commit bc7d558945
9 changed files with 205 additions and 235 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,54 +0,0 @@
/* "4cpp" Open C++ Parser v0.1: Clear Config
no warranty implied; use at your own risk
NOTES ON USE:
This file is used to clear options. The main use for this is for cases when you want
it include different portions of the library with different settings. So that the compiler
does not complain about redifintion, and so that you do not have to undef everything yourself
this is provided to undef everything at once.
*/
#ifdef FCPP_NO_CRT
#undef FCPP_NO_CRT
#endif
#ifdef FCPP_NO_MALLOC
#undef FCPP_NO_MALLOC
#endif
#ifdef FCPP_NO_ASSERT
#undef FCPP_NO_ASSERT
#endif
#ifdef FCPP_NO_STRING
#undef FCPP_NO_STRING
#endif
#ifdef FCPP_GET_MEMORY
#undef FCPP_GET_MEMORY
#endif
#ifdef FCPP_FREE_MEMORY
#undef FCPP_FREE_MEMORY
#endif
#ifdef FCPP_ASSERT
#undef FCPP_ASSERT
#endif
#ifdef FCPP_MEM_COPY
#undef FCPP_MEM_COPY
#endif
#ifdef FCPP_MEM_MOVE
#undef FCPP_MEM_MOVE
#endif
#ifdef FCPP_LINK
#undef FCPP_LINK
#endif
#ifdef FCPP_EXTERN
#undef FCPP_EXTERN
#endif

View File

@ -12,7 +12,7 @@
# define FCPP_LINK static # define FCPP_LINK static
#endif #endif
#include "4coder_lexer_types.h" #include "4cpp_lexer_types.h"
#include "4cpp_lexer_fsms.h" #include "4cpp_lexer_fsms.h"
#include "4cpp_lexer_tables.c" #include "4cpp_lexer_tables.c"
@ -297,48 +297,15 @@ cpp_pp_directive_to_state(Cpp_Token_Type type){
return(result); return(result);
} }
#if 0
FCPP_LINK Cpp_Token_Merge
cpp_attempt_token_merge(Cpp_Token prev_token, Cpp_Token next_token){
Cpp_Token_Merge result = {(Cpp_Token_Type)0};
if (next_token.type == CPP_TOKEN_COMMENT && prev_token.type == CPP_TOKEN_COMMENT &&
next_token.flags == prev_token.flags && next_token.state_flags == prev_token.state_flags){
result.did_merge = 1;
prev_token.size = next_token.start + next_token.size - prev_token.start;
result.new_token = prev_token;
}
else if (next_token.type == CPP_TOKEN_JUNK && prev_token.type == CPP_TOKEN_JUNK &&
next_token.flags == prev_token.flags && next_token.state_flags == prev_token.state_flags){
result.did_merge = 1;
prev_token.size = next_token.start + next_token.size - prev_token.start;
result.new_token = prev_token;
}
return(result);
}
#endif
FCPP_LINK int32_t FCPP_LINK int32_t
cpp_place_token_nonalloc(Cpp_Token *out_tokens, int32_t token_i, Cpp_Token token){ cpp_place_token_nonalloc(Cpp_Token *out_tokens, int32_t token_i, Cpp_Token token){
//Cpp_Token_Merge merge = {(Cpp_Token_Type)0};
Cpp_Token prev_token = {(Cpp_Token_Type)0}; Cpp_Token prev_token = {(Cpp_Token_Type)0};
if (token_i > 0){ if (token_i > 0){
prev_token = out_tokens[token_i - 1]; prev_token = out_tokens[token_i - 1];
#if 0
merge = cpp_attempt_token_merge(prev_token, token);
if (merge.did_merge){
out_tokens[token_i - 1] = merge.new_token;
}
#endif
} }
#if 0
if (!merge.did_merge){
out_tokens[token_i++] = token;
}
#else
out_tokens[token_i++] = token; out_tokens[token_i++] = token;
#endif
return(token_i); return(token_i);
} }
@ -449,7 +416,7 @@ cpp_lex_nonalloc(Lex_Data *S_ptr,
S.token_start = S.pos; S.token_start = S.pos;
S.tb_pos = 0; S.tb_pos = 0;
S.fsm = zero_lex_fsm(); S.fsm = null_lex_fsm;
for(;;){ for(;;){
{ {
unsigned short *eq_classes = get_eq_classes[S.pp_state]; unsigned short *eq_classes = get_eq_classes[S.pp_state];

View File

@ -84,19 +84,11 @@ enum Lex_PP_State{
struct Lex_FSM{ struct Lex_FSM{
uint8_t state; uint8_t state;
union{ uint8_t int_state;
uint8_t int_state;
uint8_t directive_state;
uint8_t sub_machine;
};
uint8_t emit_token; uint8_t emit_token;
uint8_t multi_line; uint8_t multi_line;
}; };
inline Lex_FSM static Lex_FSM null_lex_fsm = {0};
zero_lex_fsm(){
Lex_FSM fsm = {0};
return(fsm);
}
#endif #endif

View File

@ -1,19 +0,0 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 30.11.2015
*
* CPP preprocessor
*
*/
// TOP
#define byte unsigned char
#undef byte
// BOTTOM

View File

@ -2193,10 +2193,40 @@ generate_custom_headers(){
string_keys, ArrayCount(string_keys)); string_keys, ArrayCount(string_keys));
// NOTE(allen): Parse the lexer library
static char *lexer_types_files[] = {
"4cpp_lexer_types.h",
};
static Meta_Keywords lexer_types_keys[] = {
{make_lit_string("typedef") , Item_Typedef } ,
{make_lit_string("struct") , Item_Struct } ,
{make_lit_string("union") , Item_Union } ,
{make_lit_string("ENUM") , Item_Enum } ,
};
Meta_Unit lexer_types_unit =
compile_meta_unit(part, lexer_types_files, ArrayCount(lexer_types_files),
lexer_types_keys, ArrayCount(lexer_types_keys));
static char *lexer_funcs_files[] = {
"4cpp_lexer.h",
};
static Meta_Keywords lexer_funcs_keys[] = {
{make_lit_string("FCPP_LINK") , Item_Function } ,
};
Meta_Unit lexer_funcs_unit =
compile_meta_unit(part, lexer_funcs_files, ArrayCount(lexer_funcs_files),
lexer_funcs_keys, ArrayCount(lexer_funcs_keys));
// NOTE(allen): Parse the customization API files // NOTE(allen): Parse the customization API files
static char *functions_files[] = { static char *functions_files[] = {
"4ed_api_implementation.cpp", "4ed_api_implementation.cpp",
"win32_api_impl.cpp" "win32_api_impl.cpp",
}; };
static Meta_Keywords functions_keys[] = { static Meta_Keywords functions_keys[] = {
@ -2225,11 +2255,9 @@ generate_custom_headers(){
partition_align(part, 4); partition_align(part, 4);
} }
// NOTE(allen): Parse the customization API types // NOTE(allen): Parse the customization API types
static char *type_files[] = { static char *type_files[] = {
"4coder_types.h", "4coder_types.h",
"4coder_lexer_types.h",
}; };
static Meta_Keywords type_keys[] = { static Meta_Keywords type_keys[] = {
@ -2242,7 +2270,6 @@ generate_custom_headers(){
Meta_Unit unit = compile_meta_unit(part, type_files, ArrayCount(type_files), Meta_Unit unit = compile_meta_unit(part, type_files, ArrayCount(type_files),
type_keys, ArrayCount(type_keys)); type_keys, ArrayCount(type_keys));
// NOTE(allen): Output // NOTE(allen): Output
String out = str_alloc(part, 10 << 20); String out = str_alloc(part, 10 << 20);
Out_Context context = {0}; Out_Context context = {0};
@ -2599,8 +2626,7 @@ generate_custom_headers(){
"<body>" "<body>"
"<div style='font-family:Arial; margin: 0 auto; " "<div style='font-family:Arial; margin: 0 auto; "
"width: 800px; text-align: justify; line-height: 1.25;'>" "width: 800px; text-align: justify; line-height: 1.25;'>"
"<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4coder API</h1>" "<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4coder API</h1>");
);
struct Section{ struct Section{
char *id_string; char *id_string;
@ -2611,11 +2637,11 @@ generate_custom_headers(){
{"introduction", "Introduction"}, {"introduction", "Introduction"},
{"4coder_systems", "4coder Systems"}, {"4coder_systems", "4coder Systems"},
{"types_and_functions", "Types and Functions"}, {"types_and_functions", "Types and Functions"},
{"string_library", "String Library"} {"string_library", "String Library"},
{"lexer_library", "Lexer Library"}
}; };
append_sc(&out, append_sc(&out, "<h3 style='margin:0;'>Table of Contents</h3>""<ul>");
"<h3 style='margin:0;'>Table of Contents</h3>""<ul>");
int32_t section_count = ArrayCount(sections); int32_t section_count = ArrayCount(sections);
for (int32_t i = 0; i < section_count; ++i){ for (int32_t i = 0; i < section_count; ++i){
@ -2745,7 +2771,7 @@ generate_custom_headers(){
append_sc(&out, "<ul>"); append_sc(&out, "<ul>");
for (int32_t i = 0; i < string_unit.set.count; ++i){ for (int32_t i = 0; i < string_unit.set.count; ++i){
print_item_in_list(&out, string_unit.set.items[i].name, "_str_doc"); print_item_in_list(&out, string_unit.set.items[i].name, "_doc");
} }
append_sc(&out, "</ul>"); append_sc(&out, "</ul>");
@ -2755,9 +2781,64 @@ generate_custom_headers(){
append_sc(&out, "<h3>&sect;"SECTION" String Function Descriptions</h3>"); append_sc(&out, "<h3>&sect;"SECTION" String Function Descriptions</h3>");
for (int32_t i = 0; i < string_unit.set.count; ++i){ for (int32_t i = 0; i < string_unit.set.count; ++i){
print_item(&out, part, string_unit.set.items+i, "_str_doc", "", SECTION, i+1); print_item(&out, part, string_unit.set.items+i, "_doc", "", SECTION, i+1);
} }
#undef MAJOR_SECTION
#define MAJOR_SECTION "5"
append_sc(&out, "\n<h2 id='section_");
append_sc(&out, sections[4].id_string);
append_sc(&out, "'>&sect;"MAJOR_SECTION" ");
append_sc(&out, sections[4].display_string);
append_sc(&out, "</h2>");
#undef SECTION
#define SECTION MAJOR_SECTION".1"
append_sc(&out, "<h3>&sect;"SECTION" Lexer Intro</h3>");
append_sc(&out, "<div><i>Coming Soon</i><div>");
#undef SECTION
#define SECTION MAJOR_SECTION".2"
append_sc(&out, "<h3>&sect;"SECTION" Lexer Function List</h3>");
append_sc(&out, "<ul>");
for (int32_t i = 0; i < lexer_funcs_unit.set.count; ++i){
print_item_in_list(&out, lexer_funcs_unit.set.items[i].name, "_doc");
}
append_sc(&out, "</ul>");
#undef SECTION
#define SECTION MAJOR_SECTION".3"
append_sc(&out, "<h3>&sect;"SECTION" Lexer Types List</h3>");
append_sc(&out, "<ul>");
for (int32_t i = 0; i < lexer_types_unit.set.count; ++i){
print_item_in_list(&out, lexer_types_unit.set.items[i].name, "_doc");
}
append_sc(&out, "</ul>");
#undef SECTION
#define SECTION MAJOR_SECTION".4"
append_sc(&out, "<h3>&sect;"SECTION" Lexer Function Descriptions</h3>");
for (int32_t i = 0; i < lexer_funcs_unit.set.count; ++i){
print_item(&out, part, lexer_funcs_unit.set.items+i, "_doc", "", SECTION, i+1);
}
#undef SECTION
#define SECTION MAJOR_SECTION".5"
append_sc(&out, "<h3>&sect;"SECTION" Lexer Type Descriptions</h3>");
for (int32_t i = 0; i < lexer_types_unit.set.count; ++i){
print_item(&out, part, lexer_types_unit.set.items+i, "_doc", "", SECTION, i+1);
}
append_sc(&out, "</div></body></html>"); append_sc(&out, "</div></body></html>");
end_file_out(context); end_file_out(context);
} }

View File

@ -445,7 +445,7 @@ init_build_line(Build_Line *line){
"..\\foreign\\freetype.lib" "..\\foreign\\freetype.lib"
#define CL_ICON \ #define CL_ICON \
"..\\foreign\\freetype.lib" "..\\res\\icon.res"
static void static void
build_cl(uint32_t flags, build_cl(uint32_t flags,
@ -808,6 +808,8 @@ package(char *cdir){
copy_all ("4coder_*.h", PACK_SUPER_DIR); copy_all ("4coder_*.h", PACK_SUPER_DIR);
copy_all ("4coder_*.cpp", PACK_SUPER_DIR); copy_all ("4coder_*.cpp", PACK_SUPER_DIR);
copy_all ("4cpp_*.h", PACK_SUPER_DIR);
copy_all ("4cpp_*.c", PACK_SUPER_DIR);
copy_file(0, "buildsuper"BAT, PACK_SUPER_DIR, 0); copy_file(0, "buildsuper"BAT, PACK_SUPER_DIR, 0);
get_4coder_dist_name(&str, 0, "API", "html"); get_4coder_dist_name(&str, 0, "API", "html");

View File

@ -14,7 +14,7 @@
#define Assert(n) do{ if (!(n)) { *(int*)0 = 0xA11E; } }while(0) #define Assert(n) do{ if (!(n)) { *(int*)0 = 0xA11E; } }while(0)
#define ArrayCount(a) (sizeof(a)/sizeof(*a)) #define ArrayCount(a) (sizeof(a)/sizeof(*a))
#include "4coder_lexer_types.h" #include "4cpp_lexer_types.h"
#include "4cpp_lexer_fsms.h" #include "4cpp_lexer_fsms.h"
#include "4ed_mem_ansi.c" #include "4ed_mem_ansi.c"