HPInc / HP-Digital-Microfluidics

HP Digital Microfluidics Software Platform and Libraries
MIT License
2 stars 0 forks source link

Remove floats with trailing decimal points #218

Closed EvanKirshenbaum closed 5 months ago

EvanKirshenbaum commented 5 months ago

Floating point numbers in the macro language are defined by the lexer by

INT : DIGIT+ ('_' DIGIT+)* ;
fragment EXPT : [eE] '-'? INT;
FLOAT : INT '.' INT? EXPT? | INT EXPT;

One consequence of this is that 2. is a floating point number.

Some time ago, I changed the attribute separator from

ATTR: '\'s';

to

ATTR: '\'s' | '.';

This allows the user to say w.volume instead of w's volume, which seems to be more natural to some users that have prior programming experience. Unfortunately, it means that if you try to say well #2.volume instead of well #2's volume, you get a very cryptic error message, because the . is being interpreted as part of a floating-point token rather than as a separator:

line 1:6 Expected INT, got FLOAT: 2.

To get us back to being PLA-compliant, I want to remove the possibility of having floating point numbers with trailing decimal points. The only reason people use them is to say "This is a float, not an int," and that can be done by adding a zero after the decimal point just as easily. (or "e0", if you like).

Migrated from internal repository. Originally created by @EvanKirshenbaum on Jan 15, 2023 at 12:17 PM PST. Closed on Jan 15, 2023 at 1:40 PM PST.
EvanKirshenbaum commented 5 months ago

This issue was referenced by the following commit before migration:

EvanKirshenbaum commented 5 months ago

As easy as it looked. FLOAT is now defined as

FLOAT : INT '.' INT EXPT? | INT EXPT;

and everything seems to work.

Migrated from internal repository. Originally created by @EvanKirshenbaum on Jan 15, 2023 at 1:39 PM PST.