Fix some missing operators not getting parsed properly. Fixed field access type checking with depth more than 1.
This commit is contained in:
25
Parsing.jai
25
Parsing.jai
@@ -101,6 +101,11 @@ parse_rules :: #run -> [(cast(int)Token_Kind.TOKEN_ERROR) + 1]Parse_Rule {
|
||||
rules[Token_Kind.TOKEN_STAR] = .{null, binary, .PREC_FACTOR};
|
||||
rules[Token_Kind.TOKEN_ISNOTEQUAL] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_ASSIGN] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_MINUSEQUALS] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_PLUSEQUALS] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_DIVEQUALS] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_TIMESEQUALS] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_MODEQUALS] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_ISEQUAL] = .{null, binary, .PREC_EQUALITY};
|
||||
rules[Token_Kind.TOKEN_GREATER] = .{null, binary, .PREC_COMPARISON};
|
||||
rules[Token_Kind.TOKEN_GREATEREQUALS] = .{null, binary, .PREC_COMPARISON};
|
||||
@@ -410,6 +415,15 @@ check :: (parse_state : *Parse_State, kind : Token_Kind) -> bool {
|
||||
return parse_state.current.kind == kind;
|
||||
}
|
||||
|
||||
check_any :: (parse_state : *Parse_State, kinds : ..Token_Kind) -> bool {
|
||||
for kind : kinds {
|
||||
if check(parse_state, kind) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//nb - Checks if the next token is of a certain kind
|
||||
check_next :: (parse_state : *Parse_State, kind : Token_Kind) -> bool {
|
||||
return parse_state.tokens[parse_state.current_token_index].kind == kind;
|
||||
@@ -625,7 +639,7 @@ dot :: (parse_state : *Parse_State, left : *AST_Node) -> *AST_Node {
|
||||
source_location : Source_Range;
|
||||
source_location.begin = left.source_location.begin;
|
||||
|
||||
if check(parse_state, .TOKEN_ASSIGN) {
|
||||
if check_any(parse_state, .TOKEN_ASSIGN, .TOKEN_MINUSEQUALS, .TOKEN_PLUSEQUALS, .TOKEN_DIVEQUALS, .TOKEN_MODEQUALS, .TOKEN_TIMESEQUALS) {
|
||||
advance(parse_state);
|
||||
variable := make_node(parse_state, .Variable);
|
||||
variable.source_location = generate_source_location_from_token(parse_state, identifier);
|
||||
@@ -638,12 +652,15 @@ dot :: (parse_state : *Parse_State, left : *AST_Node) -> *AST_Node {
|
||||
add_child(node, left);
|
||||
add_child(node, expression(parse_state));
|
||||
return node;
|
||||
} else if check(parse_state, .TOKEN_DOT) {
|
||||
// @Incomplete(nb): Another level of access
|
||||
}
|
||||
}
|
||||
variable := make_node(parse_state, .Variable);
|
||||
variable.name = identifier.ident_value;
|
||||
|
||||
if check(parse_state, .TOKEN_DOT) {
|
||||
advance(parse_state);
|
||||
dot(parse_state, variable);
|
||||
}
|
||||
|
||||
add_child(left, variable);
|
||||
|
||||
source_location.end = parse_state.previous;
|
||||
|
||||
Reference in New Issue
Block a user