-
Notifications
You must be signed in to change notification settings - Fork 59
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
Modifying jasmin2tex integer representation to fit source integer representation better #886
Conversation
* Add new Syntax Node `pbasedinteger` which dissapear at pretyping * Changing parser and lexer accordingly * Changing latex_printer integer handling
compiler/src/lexer.mll
Outdated
{ INT {zvalue=Z.of_string s;raw=s}} | ||
|
||
| ('0' ['x' 'X'] hexdigit+) as s | ||
{ INT (Z.of_string s) } | ||
{ INT {zvalue=Z.of_string s;raw=s} } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you compute the Z value here? Isn’t it simpler to only keep the string here and compute the value in pre-typing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't very used to the process of the compiler so I wanted the modification to affect the smallest possible part of the code. If you think it is preferable that the Z type building is done in pre-typing, I can change it (it will indeed simplify code readability)
* type pbaseinteger deleted (not usefull anymore) * converting is done in pre-typing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering your future plans, it might be worth introducing an abstract type (say int_notation
) right now.
Co-authored-by: Vincent Laporte <vbgl@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I’ll merge as soon as CI completes.
(cherry picked from commit faf9b1d)
Issue
jasmin2tex program always convert integer from source file to base 10. In certain cases, it makes readability of the program harder. For example :
is converted to :
Solution
We implement a new Syntax node
pbinteger
that store the raw integer string coming from source file :At pretyping, we convert this type back to
Z.t
, which mean that it does not affect the behavior of the compiler for all next compilation steps. Sincelatex_printer
is executed before pre-typing, we can use the raw string for generating latex file. The new output is now :Changelog
pbasedinteger
which dissapear at pretyping