Skip to content

Syntax formatter v1 v2#1492

Merged
borisbat merged 3 commits into
GaijinEntertainment:masterfrom
aleksisch:syntax-formatter-v1-v2
Feb 5, 2025
Merged

Syntax formatter v1 v2#1492
borisbat merged 3 commits into
GaijinEntertainment:masterfrom
aleksisch:syntax-formatter-v1-v2

Conversation

@aleksisch
Copy link
Copy Markdown
Collaborator

@aleksisch aleksisch commented Feb 2, 2025

This PR creates tool to transform from syntax v1 to syntax v2.

Main logic are in second commit.

Right now there's one problem:
we'll lose all comments and spaces/linebreak inside initialization expression:

    [[A  /**/
         a = 1]]
    // will be converted to
    A(a=1)

@aleksisch aleksisch force-pushed the syntax-formatter-v1-v2 branch 2 times, most recently from 028af80 to 084878c Compare February 3, 2025 18:44
@aleksisch aleksisch force-pushed the syntax-formatter-v1-v2 branch from 084878c to 2b088c9 Compare February 4, 2025 19:06
Comment thread src/parser/ds_lexer.lpp
<normal>\$t([^a-zA-Z0-9_]) unput(yytext[yyleng-1]); return MTAG_T;
<normal>\$c([^a-zA-Z0-9_]) unput(yytext[yyleng-1]); return MTAG_C;
<normal>\$f([^a-zA-Z0-9_]) unput(yytext[yyleng-1]); return MTAG_F;
<normal>\$e([^a-zA-Z0-9_]) unput(yytext[yyleng-1]); YYCOLUMN(yyextra->das_yycolumn--, "UNPUT $"); return MTAG_E;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about lexer part. But looks like it fixes incorrect location. Also, sometimes in other cases we do it on unput()

@aleksisch aleksisch force-pushed the syntax-formatter-v1-v2 branch 3 times, most recently from 36bb1da to d7e519e Compare February 4, 2025 20:01
@aleksisch aleksisch force-pushed the syntax-formatter-v1-v2 branch from d7e519e to 8212e5a Compare February 4, 2025 20:02
@aleksisch
Copy link
Copy Markdown
Collaborator Author

aleksisch commented Feb 4, 2025

@borisbat @profelis
Can't add reviewers, so please take a look

@borisbat borisbat merged commit f564e3d into GaijinEntertainment:master Feb 5, 2025
@aleksisch aleksisch deleted the syntax-formatter-v1-v2 branch November 12, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants