Added more comments and definitions.
This commit is contained in:
@@ -12,18 +12,18 @@
|
||||
*
|
||||
* Finalize tree will perform type checking, name resolution, and other necessary checks and transformations to ensure the tree is ready for code generation. The finalized tree will be used for both generating assembly.
|
||||
*
|
||||
*
|
||||
* This flavor of C is designed to be simple and easy to compile, and it may not support all features of standard C.
|
||||
*
|
||||
* This flavor of C is designed to be simple and easy to compile, and it may not support all features of standard C.
|
||||
* The main purpose of this compiler is to provide a convenient way for developers to write code for Sagittarius VM, and it may have some limitations compared to a full-featured C compiler.
|
||||
*
|
||||
*
|
||||
* It also supports a simple module system, where you can include other C files as modules. The included files will be compiled together with the main file, and they can share the same namespaces and symbols.
|
||||
*
|
||||
*
|
||||
* It have no separate function declaration and definition, and all functions don't need to be defined before they are used.
|
||||
*
|
||||
*
|
||||
* It should also support generic types.
|
||||
*
|
||||
*
|
||||
* Sample Sagittarius C code:
|
||||
*
|
||||
*
|
||||
* import sys;
|
||||
* namespace sample{
|
||||
* T add<T>(T a, T b){
|
||||
@@ -31,9 +31,12 @@
|
||||
* }
|
||||
* void main(){
|
||||
* int x = add(1, 2);
|
||||
* float y = add(3.14f, 2.71f);
|
||||
* sys.printint(x);
|
||||
* printfloat(y); // Compiler will resolve printfloat to correct function in sys namespace.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct SagittariusC_SyntaxNode
|
||||
@@ -107,7 +110,8 @@ typedef struct SagittariusC_Config
|
||||
char *assembler_path;
|
||||
bool obj_only;
|
||||
} SagittariusC_Config;
|
||||
typedef struct SagittariusC_Tree_Cache{
|
||||
typedef struct SagittariusC_Tree_Cache
|
||||
{
|
||||
SagittariusC_SyntaxNode_Root **root;
|
||||
int64_t *ref_count;
|
||||
} SagittariusC_Tree_Cache;
|
||||
@@ -123,7 +127,18 @@ typedef struct SagittariusC_Segment
|
||||
*/
|
||||
struct SagittariusC_Segment *next;
|
||||
} SagittariusC_Segment;
|
||||
SAGITTARIUS_API bool sagittarius_c_scan_segments(FILE *f, SagittariusC_Segment **out_head);
|
||||
|
||||
bool sagittarius_c_next_word(FILE *f, char *file_name, Sag_Str *out);
|
||||
/*
|
||||
* This function performs basic scanning of the source code, which will read the source code and split it into segments, and also perform some basic processing on the segments, such as removing comments and whitespace. The segments are stored in a linked list manner, and the head of the list is returned through the out parameter.
|
||||
*This function should be called before post processing and parsing the segments.
|
||||
*/
|
||||
SAGITTARIUS_API bool sagittarius_c_scan_segments(FILE *f, char *file_name, SagittariusC_Segment **out_head);
|
||||
/*
|
||||
* Post process the segments, which will perform some necessary processing on the segments,
|
||||
* such as combining segments for floats like "3.14f" into a single segment, and also perform some basic checks on the segments to ensure they are well formed. This function should be called before parsing the segments into a syntax tree.
|
||||
*/
|
||||
SAGITTARIUS_API bool sagittarius_c_post_process_segments(SagittariusC_Segment *head);
|
||||
SAGITTARIUS_API bool sagittarius_c_parse_segments(SagittariusC_Segment *head, SagittariusC_SyntaxNode_Root *out_root);
|
||||
/**
|
||||
* By writing the tree to a file, the file is called an object file.
|
||||
|
||||
Reference in New Issue
Block a user