Stable output for distinct token fields
Generator of lexical analyzers in C and C++. Unicode Supported.
Brought to you by:
fschaef
For the moment, you're using a dict to store distinct fields, and not sorting them when outputing to C/C++ code. The result is that the orders of the fields changes. This is unpractical because:
This could be solved either using an ordered dict rather than a dict, or sorting the fields before emitting them.
What do you think ?
Ticket moved from /p/quex/bugs/295/
Please, provide an example. Do you mean, you want to have the token-ids sorted by name?
Ticket moved from /p/getpot/support-requests/2/
Hi !
Sure, here is the definition of my token_type fields:
Which will produce this token definition in C:
As you can see, the fields are not ordered similarly in the C code, and no order is guaranteed, eg. it can change from one compilation to the next. This is very problematic because it can break binary compatibility, eg, if I recompile my lexer I have to recompile every dependency, even if the lexer, or the fields, didn't change.
Also I'm binding to Ada, where this causes other complications.
This all happens because you're using a regular dict in token_type.py:
And not ordering the fields before rendering in token_class_maker.py (I believe ?):
The fix is relatively easy, either:
In my opinion, 1. is better because it has the added benefit of preserving the order in which the user has specified the fields.
Ticket moved from /p/quex/support-requests/7/
I see. This is a good point.
I will include this in the next release.
Thanks for the note.
Well thank you :)
implemented since 0.67.1. Please, confirm!
Close due to lack of objection. Assume task accomplished.