Compiler ignores float constants
jmw182 opened this issue · comments
The message compiler currently ignores constants that include float values, e.g. #define PI 3.14
or (more practical) #define SAMPLE_LENGTH 0.02
. Such constants are ignored whether they involve calculations or not.
This can be fixed by updating the regex statement in the line below to include \.
in the expression character set.
Lines 34 to 36 in 7ebd484
This simple fix should allow constant literals to be defined, but will not fix errors from performing arithmetic on a mixture of float and int constants. If this is difficult to fix we could choose not to support this. This affects one definition in the current climber_config.h, but this could potentially be phased out of climber:
pyrtma/testing/climber_config.h
Lines 26 to 27 in 7ebd484
I updated the regex in compile.py in fe8d708 to allow macros with decimal points. This should work for constant literals but will still result in errors for arithmetic expressions such as #define SAMPLE_LENGTH (0.01 * RAW_COUNTS_PER_SAMPLE)
.
Also, the regex skips string constants that include special characters. For example this constant is skipped by the compiler due to special characters "
and :
pyrtma/testing/climber_config.h
Line 11 in 0baa217
These issues have been resolved in compiler V2