we can now quote with '
This commit is contained in:
+19
-4
@@ -164,12 +164,27 @@ Ast_Node* parse_atom(char* text, int* index_in_text) {
|
||||
}
|
||||
|
||||
Ast_Node* parse_expression(char* text, int* index_in_text) {
|
||||
// okay we know the text under the index is '('
|
||||
if (text[*index_in_text] == '\'') {
|
||||
++(*index_in_text);
|
||||
Ast_Node* result;
|
||||
if (text[*index_in_text] == '(' || text[*index_in_text] == '\'' ) {
|
||||
try {
|
||||
result = parse_expression(text, index_in_text);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
result = parse_atom(text, index_in_text);
|
||||
}
|
||||
}
|
||||
return create_ast_node_pair(
|
||||
create_ast_node_symbol("quote"),
|
||||
create_ast_node_pair(result, create_ast_node_nil()));
|
||||
}
|
||||
++(*index_in_text);
|
||||
|
||||
eat_whitespace(text, index_in_text);
|
||||
|
||||
// if there was actually nothing in the list return nil
|
||||
// if there was actually nothing in the list, return nil
|
||||
if (text[(*index_in_text)] == ')') {
|
||||
++(*index_in_text);
|
||||
return create_ast_node_nil();
|
||||
@@ -182,7 +197,7 @@ Ast_Node* parse_expression(char* text, int* index_in_text) {
|
||||
Ast_Node* expression = head;
|
||||
|
||||
while (true) {
|
||||
if (text[(*index_in_text)] == '(') {
|
||||
if (text[(*index_in_text)] == '(' || text[(*index_in_text)] == '\'' ) {
|
||||
head->value.pair->first = parse_expression(text, index_in_text);
|
||||
} else {
|
||||
head->value.pair->first = parse_atom(text, index_in_text);
|
||||
@@ -226,7 +241,7 @@ Ast_Node* parse_single_expression(char* text) {
|
||||
int index_in_text = 0;
|
||||
Ast_Node* result;
|
||||
eat_until_code(text, &index_in_text);
|
||||
if (text[(index_in_text)] == '(')
|
||||
if (text[(index_in_text)] == '(' || text[(index_in_text)] == '\'' )
|
||||
result = parse_expression(text, &index_in_text);
|
||||
else
|
||||
result = parse_atom(text, &index_in_text);
|
||||
|
||||
Reference in New Issue
Block a user