latest
This commit is contained in:
+14
-14
@@ -9,7 +9,7 @@ namespace Parser {
|
||||
// read-time. This should always be the global environment.
|
||||
Environment* environment_for_macros;
|
||||
|
||||
void init(Environment* env) {
|
||||
proc init(Environment* env) -> void {
|
||||
// NOTE(Felix): it is important to keep the parser environment
|
||||
// up to date with the global environment. When donig tests,
|
||||
// or running a programm we have to reaload it.
|
||||
@@ -28,7 +28,7 @@ namespace Parser {
|
||||
lo->sourceCodeLocation->column = parser_col;
|
||||
}
|
||||
|
||||
void eat_comment_line(char* text, int* index_in_text) {
|
||||
proc eat_comment_line(char* text, int* index_in_text) -> void {
|
||||
// safety check if we are actually starting a comment here
|
||||
if (text[*index_in_text] != ';')
|
||||
return;
|
||||
@@ -42,7 +42,7 @@ namespace Parser {
|
||||
text[(*index_in_text)] != '\0');
|
||||
}
|
||||
|
||||
void eat_whitespace(char* text, int* index_in_text) {
|
||||
proc eat_whitespace(char* text, int* index_in_text) -> void {
|
||||
// skip whitespaces
|
||||
while (text[(*index_in_text)] == ' ' ||
|
||||
text[(*index_in_text)] == '\t' ||
|
||||
@@ -59,7 +59,7 @@ namespace Parser {
|
||||
|
||||
}
|
||||
|
||||
void eat_until_code(char* text, int* index_in_text) {
|
||||
proc eat_until_code(char* text, int* index_in_text) -> void {
|
||||
int position_before;
|
||||
do {
|
||||
position_before = *index_in_text;
|
||||
@@ -68,7 +68,7 @@ namespace Parser {
|
||||
} while (position_before != *index_in_text);
|
||||
}
|
||||
|
||||
String* read_atom(char* text, int* index_in_text) {
|
||||
proc read_atom(char* text, int* index_in_text) -> String* {
|
||||
int atom_length = 0;
|
||||
while (text[*index_in_text+atom_length] != ' ' &&
|
||||
text[*index_in_text+atom_length] != ')' &&
|
||||
@@ -102,7 +102,7 @@ namespace Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
Lisp_Object* parse_number(char* text, int* index_in_text) {
|
||||
proc parse_number(char* text, int* index_in_text) -> Lisp_Object* {
|
||||
double number;
|
||||
// TODO(Felix): parse the number direcrly from the string and
|
||||
// dont create a String first
|
||||
@@ -114,7 +114,7 @@ namespace Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
Lisp_Object* parse_keyword(char* text, int* index_in_text) {
|
||||
proc parse_keyword(char* text, int* index_in_text) -> Lisp_Object* {
|
||||
// we are now on the colon
|
||||
++(*index_in_text);
|
||||
++parser_col;
|
||||
@@ -125,7 +125,7 @@ namespace Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
Lisp_Object* parse_symbol(char* text, int* index_in_text) {
|
||||
proc parse_symbol(char* text, int* index_in_text) -> Lisp_Object* {
|
||||
// we are now at the first char of the symbol
|
||||
String* str_symbol = read_atom(text, index_in_text);
|
||||
Lisp_Object* ret = Memory::create_lisp_object_symbol(str_symbol);
|
||||
@@ -133,7 +133,7 @@ namespace Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
Lisp_Object* parse_string(char* text, int* index_in_text) {
|
||||
proc parse_string(char* text, int* index_in_text) -> Lisp_Object*{
|
||||
// the first character is the '"'
|
||||
++(*index_in_text);
|
||||
++parser_col;
|
||||
@@ -188,7 +188,7 @@ namespace Parser {
|
||||
return ret;
|
||||
}
|
||||
|
||||
Lisp_Object* parse_atom(char* text, int* index_in_text) {
|
||||
proc parse_atom(char* text, int* index_in_text) -> Lisp_Object* {
|
||||
// numbers
|
||||
if ((text[*index_in_text] <= 57 && // if number
|
||||
text[*index_in_text] >= 48)
|
||||
@@ -216,7 +216,7 @@ namespace Parser {
|
||||
return parse_symbol(text, index_in_text);
|
||||
}
|
||||
|
||||
Lisp_Object* parse_expression(char* text, int* index_in_text) {
|
||||
proc parse_expression(char* text, int* index_in_text) -> Lisp_Object* {
|
||||
|
||||
// if it is quoted
|
||||
if (text[*index_in_text] == '\'' ||
|
||||
@@ -440,7 +440,7 @@ namespace Parser {
|
||||
return expression;
|
||||
}
|
||||
|
||||
Lisp_Object* parse_single_expression(char* text) {
|
||||
proc parse_single_expression(char* text) -> Lisp_Object* {
|
||||
parser_file = Memory::create_string("stdin");
|
||||
parser_line = 1;
|
||||
parser_col = 1;
|
||||
@@ -470,7 +470,7 @@ namespace Parser {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void write_expanded_file(String* file_name, Lisp_Object_Array_List* program) {
|
||||
proc write_expanded_file(String* file_name, Lisp_Object_Array_List* program) -> void {
|
||||
const char* ext = ".expanded";
|
||||
char* newName = (char*)calloc(10 + file_name->length, sizeof(char));
|
||||
strcpy(newName, Memory::get_c_str(file_name));
|
||||
@@ -494,7 +494,7 @@ namespace Parser {
|
||||
free(newName);
|
||||
}
|
||||
|
||||
Lisp_Object_Array_List* parse_program(String* file_name, char* text) {
|
||||
proc parse_program(String* file_name, char* text) -> Lisp_Object_Array_List* {
|
||||
parser_file = file_name;
|
||||
parser_line = 1;
|
||||
parser_col = 0;
|
||||
|
||||
Reference in New Issue
Block a user