xBimTeam / XbimEssentials

A .NET library to work with data in the IFC format. This is the core component of the Xbim Toolkit
https://xbimteam.github.io/
Other
485 stars 172 forks source link

XBimP21Scanner. '1e-05' is not recognized as Tokens.Float. #510

Open santiagoIT opened 1 year ago

santiagoIT commented 1 year ago

If you attempt to load the attached IFC file, nothing will be displayed. Other IFC Viewers display the content just fine (BimVision, etc..).

If you edit the following line:

#19=IFCGEOMETRICREPRESENTATIONCONTEXT('Building Model','Model',3,1e-05,#18,$);

to

#19=IFCGEOMETRICREPRESENTATIONCONTEXT('Building Model','Model',3,1.E-05,#18,$);

it then works.

The lexer/tokenizer is splitting 1e-05 into two tokens, when it should be only one token.

'1.E-05' is tokenized properly

image

XbimScannerIssue.zip

santiagoIT commented 1 year ago

The problem is with StepP21Lex.lex.

The regular expression expects a mandatory dot:

image

The first test string is not recognized. It should.

image

andyward commented 1 year ago

Looks like the exponent regex needs a bit of a rethink!

This seems to be a more robust implementation from StackOverflow

^(?:-?\d*)\.?\d?[eE][-\+]?\d+$
image
andyward commented 11 months ago

@martin1cerny Had a look at fixing this but it seems the GP Lexer needs a fix so we don't over-write the hand edited large file fix: commit 6517bc16042b3cfd820dd7eb45f72bbab92d13ad