Parse STEP-file (with javascript)
<p>I'm trying to read the information from a STEP-file (<a href="https://en.wikipedia.org/wiki/ISO_10303-21" rel="nofollow noreferrer">ISO 10303-21</a>) with javascript. I'm not sure how to tackle this at all.</p>

<p>I have found open source alternatives but in all languages but Javascript... So I'm not able to learn much from them.</p>

<p>Since the text is rather irregular it's really hard to just use a regular expression to extract the information.</p>

<pre><code>ISO-10303-21;
HEADER;
FILE_DESCRIPTION(
/* description */ ('A minimal AP214 example with a single part'),
/* implementation_level */ '2;1');
FILE_NAME(
/* name */ 'demo',
/* time_stamp */ '2003-12-27T11:57:53',
/* author */ ('Lothar Klein'),
/* organization */ ('LKSoft'),
/* preprocessor_version */ ' ',
/* originating_system */ 'IDA-STEP',
/* authorization */ ' ');
FILE_SCHEMA (('AUTOMOTIVE_DESIGN { 1 0 10303 214 2 1 1}'));
ENDSEC;
DATA;
#10=ORGANIZATION('O0001','LKSoft','company');
#11=PRODUCT_DEFINITION_CONTEXT('part definition',#12,'manufacturing');
#12=APPLICATION_CONTEXT('mechanical design');
#13=APPLICATION_PROTOCOL_DEFINITION('','automotive_design',2003,#12);
#14=PRODUCT_DEFINITION('0',$,#15,#11);
#15=PRODUCT_DEFINITION_FORMATION('1',$,#16);
#16=PRODUCT('A0001','Test Part 1','',(#18));
#17=PRODUCT_RELATED_PRODUCT_CATEGORY('part',$,(#16));
#18=PRODUCT_CONTEXT('',#12,'');
#19=APPLIED_ORGANIZATION_ASSIGNMENT(#10,#20,(#16));
#20=ORGANIZATION_ROLE('id owner');
#21=IFCPROPERTYSINGLEVALUE('Visa 2D F\S\dstpunkter i 3D',$,IFCBOOLEAN(.F.),$);
ENDSEC;
END-ISO-10303-21;
</code></pre>

<p>And different export tools export with different variations:</p>

<pre><code>#95=STYLED_ITEM('',(#94),#92);
#12 = CARTESIAN_POINT ( 'NONE',  ( 1.213, 5.617, -7.500 ) ) ;
#263 = TEST ( 'Spaces must not be ignored here' ) ;
</code></pre>

<p><a href="https://stackoverflow.com/questions/23246867/regex-for-instances-in-step-files">source for example</a></p>

<p>What is the best way to read the step files? Parser generators, Regex or something else?</p>