Correct \n ignore rules

This commit is contained in:
gingerBill
2021-04-26 21:25:44 +01:00
parent 898245431f
commit 6d1eb473cf
2 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -848,7 +848,7 @@ SID_TYPE :: enum SID_NAME_USE {
Unknown, Unknown,
Computer, Computer,
Label, Label,
LogonSession LogonSession,
} }
SECURITY_MAX_SID_SIZE :: 68; SECURITY_MAX_SID_SIZE :: 68;
+10 -3
View File
@@ -1553,7 +1553,7 @@ bool is_semicolon_optional_for_node(AstFile *f, Ast *s) {
} }
void expect_semicolon_newline_error(AstFile *f, Token const &token, Ast *s) { void expect_semicolon_newline_error(AstFile *f, Token const &token, Ast *s) {
if (token.string == "\n") { if (!build_context.insert_semicolon && token.string == "\n") {
switch (token.kind) { switch (token.kind) {
case Token_CloseBrace: case Token_CloseBrace:
case Token_CloseParen: case Token_CloseParen:
@@ -2109,12 +2109,15 @@ Ast *parse_operand(AstFile *f, bool lhs) {
return ast_proc_group(f, token, open, close, args); return ast_proc_group(f, token, open, close, args);
} }
Ast *type = parse_proc_type(f, token); Ast *type = parse_proc_type(f, token);
Token where_token = {}; Token where_token = {};
Array<Ast *> where_clauses = {}; Array<Ast *> where_clauses = {};
u64 tags = 0; u64 tags = 0;
skip_possible_newline_for_literal(f); skip_possible_newline_for_literal(f);
if (f->curr_token.kind == Token_where) { if (f->curr_token.kind == Token_where) {
where_token = expect_token(f, Token_where); where_token = expect_token(f, Token_where);
isize prev_level = f->expr_level; isize prev_level = f->expr_level;
@@ -2875,6 +2878,9 @@ Ast *parse_expr(AstFile *f, bool lhs) {
Array<Ast *> parse_expr_list(AstFile *f, bool lhs) { Array<Ast *> parse_expr_list(AstFile *f, bool lhs) {
bool allow_newline = f->allow_newline;
f->allow_newline = true;
auto list = array_make<Ast *>(heap_allocator()); auto list = array_make<Ast *>(heap_allocator());
for (;;) { for (;;) {
Ast *e = parse_expr(f, lhs); Ast *e = parse_expr(f, lhs);
@@ -2886,6 +2892,8 @@ Array<Ast *> parse_expr_list(AstFile *f, bool lhs) {
advance_token(f); advance_token(f);
} }
f->allow_newline = allow_newline;
return list; return list;
} }
@@ -4552,8 +4560,7 @@ ParseFileError init_ast_file(AstFile *f, String fullpath, TokenPos *err_pos) {
if (!string_ends_with(f->fullpath, str_lit(".odin"))) { if (!string_ends_with(f->fullpath, str_lit(".odin"))) {
return ParseFile_WrongExtension; return ParseFile_WrongExtension;
} }
TokenizerFlags tokenizer_flags = TokenizerFlag_None; TokenizerFlags tokenizer_flags = TokenizerFlag_InsertSemicolon;
tokenizer_flags = TokenizerFlag_InsertSemicolon;
zero_item(&f->tokenizer); zero_item(&f->tokenizer);
f->tokenizer.curr_file_id = f->id; f->tokenizer.curr_file_id = f->id;