Added more comments and definitions.

This commit is contained in:
Creeper Lv
2026-05-25 16:13:05 +10:00
parent 5be0fd7862
commit eb27f05927
+17 -2
View File
@@ -31,6 +31,9 @@
* } * }
* void main(){ * void main(){
* int x = add(1, 2); * 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.
* } * }
* } * }
* *
@@ -107,7 +110,8 @@ typedef struct SagittariusC_Config
char *assembler_path; char *assembler_path;
bool obj_only; bool obj_only;
} SagittariusC_Config; } SagittariusC_Config;
typedef struct SagittariusC_Tree_Cache{ typedef struct SagittariusC_Tree_Cache
{
SagittariusC_SyntaxNode_Root **root; SagittariusC_SyntaxNode_Root **root;
int64_t *ref_count; int64_t *ref_count;
} SagittariusC_Tree_Cache; } SagittariusC_Tree_Cache;
@@ -123,7 +127,18 @@ typedef struct SagittariusC_Segment
*/ */
struct SagittariusC_Segment *next; struct SagittariusC_Segment *next;
} SagittariusC_Segment; } 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); 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. * By writing the tree to a file, the file is called an object file.