Skip to content

Conversation

@fruffy
Copy link
Collaborator

@fruffy fruffy commented Nov 7, 2025

No description provided.

…actually valid

Signed-off-by: fruffy <fruffy@nyu.edu>
@fruffy fruffy added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label Nov 7, 2025
@ChrisDodd
Copy link
Contributor

Another possible approach would be to change YYLLOC_DEFAULT to something like:

#define YYLLOC_DEFAULT(Cur, Rhs, N)                                     \
    ((Cur) = (N) ? YYRHSLOC(Rhs, 1) + YYRHSLOC(Rhs, N) : yylloc)

This would set the location to the location of the lookahead token for an epsilon reduction.

Signed-off-by: fruffy <fruffy@nyu.edu>
@ChrisDodd
Copy link
Contributor

Perhaps better:

#define YYLLOC_DEFAULT(Cur, Rhs, N)                                             \
    ((Cur) = (N) ? YYRHSLOC(Rhs, 1) + YYRHSLOC(Rhs, N)                          \
        : yylloc ? yyloc \
                 : Util::SourceInfo(driver.sources, driver.sources.getSourcePosition()))

or

#define YYLLOC_DEFAULT(Cur, Rhs, N)                                             \
    ((Cur) = (N) ? YYRHSLOC(Rhs, 1) + YYRHSLOC(Rhs, N)                          \
        : YYRHSLOC(Rhs, 0) ?  Util::SourceInfo(driver.sources, YYRHSLOC(Rhs, 0).getEnd())  \
                 : Util::SourceInfo(driver.sources, driver.sources.getSourcePosition()))

Signed-off-by: fruffy <fruffy@nyu.edu>
@fruffy
Copy link
Collaborator Author

fruffy commented Nov 8, 2025

Perhaps better:

#define YYLLOC_DEFAULT(Cur, Rhs, N)                                             \
    ((Cur) = (N) ? YYRHSLOC(Rhs, 1) + YYRHSLOC(Rhs, N)                          \
        : yylloc ? yyloc \
                 : Util::SourceInfo(driver.sources, driver.sources.getSourcePosition()))

or

#define YYLLOC_DEFAULT(Cur, Rhs, N)                                             \
    ((Cur) = (N) ? YYRHSLOC(Rhs, 1) + YYRHSLOC(Rhs, N)                          \
        : YYRHSLOC(Rhs, 0) ?  Util::SourceInfo(driver.sources, YYRHSLOC(Rhs, 0).getEnd())  \
                 : Util::SourceInfo(driver.sources, driver.sources.getSourcePosition()))

It might actually be nicer to have the less complex version, I looked at the reference file failures, and they seemed to be benign. Mostly a difference of 1 character in terms of start/end.

@fruffy fruffy marked this pull request as ready for review November 8, 2025 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Topics concerning the core segments of the compiler (frontend, midend, parser)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants