Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor set_token. #1428

Open
1uc opened this issue Sep 13, 2024 · 0 comments
Open

Refactor set_token. #1428

1uc opened this issue Sep 13, 2024 · 0 comments

Comments

@1uc
Copy link
Collaborator

1uc commented Sep 13, 2024

Currently, one must call set_token in nmodl.yy to have information about where the token appears in the MOD file. Since, it's manual, it's rarely used, and many nodes of the initial AST don't have any token information associated with them.

For example FUNCTION and PROCEDURE blocks have their ModToken set, while NET_RECEIVE doesn't.

nmodl/src/parser/nmodl.yy

Lines 1496 to 1506 in 5abff4f

procedure_block : PROCEDURE NAME_PTR "(" optional_argument_list ")" units statement_list "}"
{
$$ = new ast::ProcedureBlock($2, $4, $6, $7); $$->set_token($1);
}
;
net_receive_block : NETRECEIVE "(" optional_argument_list ")" statement_list "}"
{
$$ = new ast::NetReceiveBlock($3, $5);
}

Instead of fixing all occurences using the current API, we could consider changing the ctors for AST nodes such that they expect the ModToken (describing the location) as their first argument, and then the additional arguments. This way the compiler will complain about any omissions.

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

No branches or pull requests

1 participant