My problem can be broken down to the following which can happen inside a large regex: 1.
is a number, but 1..
are two token consisting of 1
as number and ..
as an operator.
The definition of a number in the Wolfram Language is very complex (I append the JFlex code at the end) and I basically need the (?!...)
operator in a deeply nested construct. However, JFlex seems to support negative lookahead only on "Rule"-basis which means I would need to expand my definitions manually.
So what want is that numbers don't eat the .
, when it is followed by another .
, because in the Wolfram Language, the two dots are then parsed as an operator sigh.
I have prepared an example that basically shows the entire number representation as a normal regex, has the negative look-ahead included and contains example-numbers.
Can someone tell me how I can do this in JFlex?
Here is the relevant JFlex code and the full definitions is available here
Digits = [0-9]+
Digits2 = [0-9a-zA-Z]+
Base = 2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36
Number = {Digits}((\.){Digits}?)? | \.{Digits}
PrecisionNumber = {Number}`((`?){Number})?
BaseNumber = {Base} "^^" {Digits2}(\.{Digits2}?)?
BasePrecisionNumber = {BaseNumber}((`{Number}?)|(``{Number}))
ScientificInteger = {Number} "\*^"(-?){Digits}
ScientificNumber = {PrecisionNumber} "\*^"(-?){Digits}
BaseScientificNumber = {BasePrecisionNumber} "\*^"(-?){Digits}
{BaseScientificNumber}|
{BasePrecisionNumber}|
{ScientificInteger}|
{BaseNumber}|
{ScientificNumber}|
{PrecisionNumber}|
{Number} { return WLElementTypes.NUMBER; }