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

Move definitions of expression rules. #162

Merged
merged 13 commits into from
Dec 11, 2022
Merged

Move definitions of expression rules. #162

merged 13 commits into from
Dec 11, 2022

Conversation

odashi
Copy link
Collaborator

@odashi odashi commented Dec 10, 2022

Overview

This change doesn't introduce any new features.

This change moves all rule definitions for ExpressionCodegen to expression_rules.py.

CC @ZibingZhang

Details

References

Blocked by

  • NA

@odashi
Copy link
Collaborator Author

odashi commented Dec 10, 2022

ah it breaks blame. will fix it.

@odashi odashi force-pushed the refactor-expr-codegen branch from 725289f to e34b62c Compare December 10, 2022 14:39
@odashi odashi force-pushed the refactor-expr-codegen branch from e34b62c to 3ae62c1 Compare December 10, 2022 14:52
@ZibingZhang
Copy link
Contributor

I see you've marked as blocked by #161, but feel free to merge if working. I can resolve any conflicts in my branch later on.

@odashi
Copy link
Collaborator Author

odashi commented Dec 10, 2022

@ZibingZhang Sure, removed the reference.

(ast.Attribute(), expression_rules._INF_PRECEDENCE),
],
)
def test_get_precedence(tree: ast.AST, precedence: int) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Half the tests call this argument tree and the other half node. Personally I prefer node but don't really care but would make it easier to understand tests if the same variable name was used across them.

Copy link
Collaborator Author

@odashi odashi Dec 11, 2022

Choose a reason for hiding this comment

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

renamed to node anyway since the name has been used in codegens. tree is used in frontend though. I prefer this name a bit because it slightly means "entire tree" rather than the fragment. (But this is just a bike-shedding problem I guess)



# name => left_syntax, right_syntax, is_wrapped
BUILTIN_FUNCS: dict[str, FunctionRule] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Assuming this constant doesn't have a _ prefix since it's imported from another file. In that case, shouldn't _MATH_SYMBOLS in math_symbols.py also have it's _ prefix removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved _MATH_SYMBOLS to expression_rules.MATH_SYMBOLS



@pytest.mark.parametrize(
"tree,precedence",
Copy link
Collaborator

Choose a reason for hiding this comment

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

tree -> node (or node -> tree)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh yeah thanks!

@odashi odashi merged commit ddcbed9 into main Dec 11, 2022
@odashi odashi deleted the refactor-expr-codegen branch December 11, 2022 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants