preliminary work on the loop parsing
This commit is contained in:
parent
39c92585f1
commit
eaebcd7bdd
4 changed files with 18 additions and 2 deletions
9
lexer.c
9
lexer.c
|
|
@ -262,8 +262,13 @@ static bool parse_special(lexer *l)
|
|||
l->index += 1;
|
||||
return true;
|
||||
case '.':
|
||||
add_token(l, TOKEN_DOT, 1);
|
||||
l->index += 1;
|
||||
if (l->source[l->index+1] == '.') {
|
||||
add_token(l, TOKEN_DOUBLE_DOT, 2);
|
||||
l->index += 2;
|
||||
} else {
|
||||
add_token(l, TOKEN_DOT, 1);
|
||||
l->index += 1;
|
||||
}
|
||||
return true;
|
||||
case ',':
|
||||
add_token(l, TOKEN_COMMA, 1);
|
||||
|
|
|
|||
1
lexer.h
1
lexer.h
|
|
@ -41,6 +41,7 @@ typedef enum {
|
|||
TOKEN_COLON, // :
|
||||
TOKEN_SEMICOLON, // ;
|
||||
TOKEN_DOT, // .
|
||||
TOKEN_DOUBLE_DOT, // ..
|
||||
TOKEN_BANG, // !
|
||||
TOKEN_COMMA, // ,
|
||||
TOKEN_LPAREN, // (
|
||||
|
|
|
|||
5
parser.c
5
parser.c
|
|
@ -373,6 +373,11 @@ ast_node *parse_expression(parser *p)
|
|||
return left;
|
||||
}
|
||||
|
||||
static ast_node *parse_for(parser *p)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static ast_node *parse_statement(parser *p)
|
||||
{
|
||||
if (match(p, TOKEN_BREAK)) {
|
||||
|
|
|
|||
5
parser.h
5
parser.h
|
|
@ -151,6 +151,11 @@ typedef struct _ast_node {
|
|||
/* This should be an access. */
|
||||
struct _ast_node *path;
|
||||
} import;
|
||||
struct {
|
||||
struct _ast_node *parameters;
|
||||
struct _ast_node *captures;
|
||||
usize param_len;
|
||||
} fr; // for
|
||||
} expr;
|
||||
} ast_node;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue