Skip to content

Commit

Permalink
Merge pull request #1356 from GaijinEntertainment/gen2_as_option
Browse files Browse the repository at this point in the history
options gen2
  • Loading branch information
borisbat authored Nov 6, 2024
2 parents 54630ca + 9330462 commit 372d0dc
Show file tree
Hide file tree
Showing 6 changed files with 870 additions and 869 deletions.
2 changes: 1 addition & 1 deletion examples/test/misc/hello_world.das
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#gen2#
options gen2;

// NOTE - this is WIP example of every single feature new syntax has to offer
// new syntax no longer supports significant whitespace, oxoford commas, etc
Expand Down
4 changes: 3 additions & 1 deletion src/ast/ast_lint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,9 @@ namespace das {
"skip_lock_checks", Type::tBool,
"skip_module_lock_checks", Type::tBool,
// pinvoke
"threadlock_context", Type::tBool
"threadlock_context", Type::tBool,
// version_2_syntax
"gen2", Type::tBool,
};

void verifyOptions() {
Expand Down
11 changes: 9 additions & 2 deletions src/ast/ast_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,15 @@ namespace das {
continue;
}
}
if (text[i] == '#' && i + 5 < length && text[i + 1] == 'g' && text[i + 2] == 'e' && text[i + 3] == 'n' && text[i + 4] == '2' && text[i + 5] == '#') {
return true;
// check for options\s*gen2
if (text[i] == 'o' && i + 7 < length && text[i + 1] == 'p' && text[i + 2] == 't' && text[i + 3] == 'i' && text[i + 4] == 'o' && text[i + 5] == 'n' && text[i + 6] == 's' && isspace(text[i + 7]) ) {
i += 7;
while (i < length && isspace(text[i])) {
++i;
}
if (i + 4 < length && text[i] == 'g' && text[i + 1] == 'e' && text[i + 2] == 'n' && text[i + 3] == '2') {
return true;
}
}
}
return false;
Expand Down
Loading

0 comments on commit 372d0dc

Please sign in to comment.