Skip to content

Commit

Permalink
Merge pull request #1447 from GaijinEntertainment/missing_return_valu…
Browse files Browse the repository at this point in the history
…e_move

enum now supports lack of commas
  • Loading branch information
borisbat authored Dec 24, 2024
2 parents 3774083 + b87cd9b commit 7a946a7
Show file tree
Hide file tree
Showing 8 changed files with 17,792 additions and 17,671 deletions.
28 changes: 20 additions & 8 deletions examples/test/misc/hello_new_syntax.das
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,40 @@ enum EmptyEnum {
}

enum MyEnum {
ONE,
TWO,
ONE
TWO
THREE
}

enum EnumWithTrailingComma {
ONE,
TWO,
ONE
TWO
}

enum Enum8u : uint8 {
ONE,
TWO,
ONE
TWO
THREE = 16u8 // TODO: 16i8 causes 2x smart_ptr_leak, note - it causes 1x smart_ptr_leak with old parser
}

enum private Enum64 : uint64 { // 64 bit enum, private
ONE,
TWO,
ONE
TWO
THREE = 16ul
}

enum WhiteSpaceEnum {

ONE
TWO,,,,,,

THREE

FOUR = 4
,

}

// TODO: add example of enum with annotation. for now we don't have a builtin enum one

[export]
Expand Down
28 changes: 20 additions & 8 deletions examples/test/misc/hello_world.das
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,40 @@ enum EmptyEnum {
}

enum MyEnum {
ONE,
TWO,
ONE
TWO
THREE
}

enum EnumWithTrailingComma {
ONE,
TWO,
ONE
TWO
}

enum Enum8u : uint8 {
ONE,
TWO,
ONE
TWO
THREE = 16u8 // TODO: 16i8 causes 2x smart_ptr_leak, note - it causes 1x smart_ptr_leak with old parser
}

enum private Enum64 : uint64 { // 64 bit enum, private
ONE,
TWO,
ONE
TWO
THREE = 16ul
}

enum WhiteSpaceEnum {

ONE
TWO,,,,,,

THREE

FOUR = 4
,

}

// TODO: add example of enum with annotation. for now we don't have a builtin enum one

[export]
Expand Down
8 changes: 4 additions & 4 deletions src/parser/ds2_lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3115,18 +3115,18 @@ YY_RULE_SETUP
YYCOLUMN(yyextra->das_yycolumn = 0, "NEW LINE (with tail end)");
das_accept_cpp_comment(yyextra->g_CommentReaders, yyscanner, *yylloc_param, yytext);
#ifdef FLEX_DEBUG
printf("indent:%i parentheses:%i squares:%i keyword:%s\n",
yyextra->das_indent_level, yyextra->das_nested_parentheses, yyextra->das_nested_square_braces,
printf("char:%c indent:%i parentheses:%i squares:%i keyword:%s\n",
yyextra->das_indent_char, yyextra->das_indent_level, yyextra->das_nested_parentheses, yyextra->das_nested_square_braces,
yyextra->das_keyword ? "true" : "false");
#endif
if ( yyextra->das_indent_level && !yyextra->das_keyword ) {
if ( !yyextra->das_nested_parentheses && !yyextra->das_nested_square_braces ) {
// here, we may need to emit ; if we are in a block
// yyextra->das_nested_curly_braces is set, but we need to know if we are in the emit block
#ifdef FLEX_DEBUG
printf("emit ; at EOL, line %i\n", yylineno);
printf("emit %c at EOL, line %i\n", yyextra->das_indent_char, yylineno);
#endif
return ';';
return yyextra->das_indent_char;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/parser/ds2_lexer.lpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,18 +702,18 @@ void das_accept_cpp_comment ( vector<CommentReader *> & crdi, yyscan_t scanner,
YYCOLUMN(yyextra->das_yycolumn = 0, "NEW LINE (with tail end)");
das_accept_cpp_comment(yyextra->g_CommentReaders, yyscanner, *yylloc_param, yytext);
#ifdef FLEX_DEBUG
printf("indent:%i parentheses:%i squares:%i keyword:%s\n",
yyextra->das_indent_level, yyextra->das_nested_parentheses, yyextra->das_nested_square_braces,
printf("char:%c indent:%i parentheses:%i squares:%i keyword:%s\n",
yyextra->das_indent_char, yyextra->das_indent_level, yyextra->das_nested_parentheses, yyextra->das_nested_square_braces,
yyextra->das_keyword ? "true" : "false");
#endif
if ( yyextra->das_indent_level && !yyextra->das_keyword ) {
if ( !yyextra->das_nested_parentheses && !yyextra->das_nested_square_braces ) {
// here, we may need to emit ; if we are in a block
// yyextra->das_nested_curly_braces is set, but we need to know if we are in the emit block
#ifdef FLEX_DEBUG
printf("emit ; at EOL, line %i\n", yylineno);
printf("emit %c at EOL, line %i\n", yyextra->das_indent_char, yylineno);
#endif
return ';';
return yyextra->das_indent_char;
}
}
}
Expand Down
Loading

0 comments on commit 7a946a7

Please sign in to comment.