@@ -423,9 +423,7 @@ export class Parser {
423423 node . valueType = nodes . ValueType . Numeric ;
424424 }
425425 }
426- else if ( this . peekRegExp ( TokenType . Symbol , / \w \d + / i)
427- || this . peekOneOf ( [ TokenType . Address , TokenType . AddressPartial ] )
428- || this . peek ( TokenType . Ampersand ) ) {
426+ else if ( this . peekRegExp ( TokenType . Symbol , / \w \d + / i) || this . peek ( TokenType . Ampersand ) ) {
429427
430428 node . valueType = nodes . ValueType . Address ;
431429 const statement = this . _parseNcStatement ( ) ;
@@ -503,7 +501,7 @@ export class Parser {
503501 if ( type === 'def' ) {
504502 return this . internalParse ( text , this . _parseDefFile , this . textProvider ) ;
505503 }
506- else if ( type === 'src' ) {
504+ else if ( type === 'src' ) {
507505 return this . internalParse ( text , this . _parseMacroFile , this . textProvider ) ;
508506 }
509507 else if ( type === 'lnk' ) {
@@ -758,13 +756,15 @@ export class Parser {
758756 return null ;
759757 }
760758
759+ const blockSkip = this . _parseBlockSkip ( ) ;
760+
761761 // Sequence number and Label may leading a statement
762- let sequence :nodes . Node | null = null ;
763762 const declaration = this . declarations . get ( this . token . text ) ;
763+ let sequence :nodes . Node | null = null ;
764764 if ( ! declaration ) {
765765 sequence = this . _parseSequenceNumber ( ) ;
766766 }
767- else if ( declaration . type === nodes . NodeType . labelDef ) {
767+ else if ( declaration . type === nodes . NodeType . labelDef ) {
768768 sequence = this . _parseLabel ( declaration ) ;
769769 }
770770
@@ -773,18 +773,33 @@ export class Parser {
773773 || this . _parseNcStatement ( )
774774 || this . parseString ( ) ;
775775
776- // a statement is always a child of an existing sequence number
777- if ( statement ) {
778- if ( sequence ) {
779- sequence . addChild ( statement ) ;
780- return sequence ;
776+
777+ // Form e.g: / N100 G01
778+ if ( blockSkip ) {
779+ if ( statement ) {
780+ if ( sequence ) {
781+ sequence . addChild ( statement ) ;
782+ }
783+ else {
784+ blockSkip . addChild ( statement )
785+ }
781786 }
782- else {
783- return statement ;
787+ if ( sequence ) {
788+ blockSkip . addChild ( sequence ) ;
789+ }
790+ return blockSkip ;
791+ }
792+ // Form e.g: N100 G01
793+ else if ( sequence ) {
794+ if ( statement ) {
795+ sequence . addChild ( statement ) ;
784796 }
785- } else if ( sequence ) {
786797 return sequence ;
787798 }
799+ // Form e.g: G01
800+ else if ( statement ) {
801+ return statement ;
802+ }
788803
789804 // Variable and label declaratio within a function
790805 const declaraionType = this . _parseVariableDeclaration ( ) || this . _parseLabelDeclaration ( ) ;
@@ -859,6 +874,17 @@ export class Parser {
859874 return this . finish ( node ) ;
860875 }
861876
877+ public _parseBlockSkip ( ) : nodes . Node | null {
878+
879+ if ( ! this . peekDelim ( '/' ) ) {
880+ return null ;
881+ }
882+
883+ const node = this . createNode ( nodes . NodeType . BlockSkip ) ;
884+ this . consumeToken ( ) ;
885+ return this . finish ( node ) ;
886+ }
887+
862888 /**
863889 * The NC Parser works as follows:
864890 *
@@ -876,8 +902,6 @@ export class Parser {
876902
877903 if ( ! this . peekOneOf ( [
878904 TokenType . Symbol ,
879- TokenType . Address ,
880- TokenType . AddressPartial ,
881905 TokenType . Ampersand ] ) ) {
882906 return null ;
883907 }
@@ -1443,29 +1467,8 @@ export class Parser {
14431467 public _parseAddress ( ) : nodes . Node | null {
14441468 const node = < nodes . Address > this . create ( nodes . Address ) ;
14451469
1446- // e.g: R100.0 [1]; R100.#[1]
1447- if ( this . peek ( TokenType . Address ) || this . peek ( TokenType . AddressPartial ) ) {
1448-
1449- if ( this . accept ( TokenType . Address ) ) {
1450- if ( this . peek ( TokenType . Symbol ) ) {
1451- let expression = this . _parseSymbol ( ) ;
1452- node . addChild ( expression ) ;
1453- }
1454- return this . finish ( node ) ;
1455- }
1456- else if ( this . accept ( TokenType . AddressPartial ) ) {
1457- if ( this . peek ( TokenType . BracketL ) || this . peek ( TokenType . Hash ) || this . peek ( TokenType . Symbol ) ) {
1458- let expression = this . _parseBinaryExpr ( ) ;
1459- node . addChild ( expression ) ;
1460- }
1461- else {
1462- return this . finish ( node , ParseError . TermExpected , [ TokenType . BracketL , TokenType . Hash ] ) ;
1463- }
1464- return this . finish ( node ) ;
1465- }
1466- }
1467- // e.g: R100.0 [1]; R100.#[1]
1468- else if ( this . peekRegExp ( TokenType . Symbol , / ( ^ [ a - z ] $ ) / i) ) {
1470+ // Address e.g: R[1], R#1, R1.#[1]
1471+ if ( this . peekRegExp ( TokenType . Symbol , / ( ^ ( [ a - z ] ) ( \d * \. ) ? $ ) / i) ) {
14691472 let mark = this . mark ( ) ;
14701473 this . consumeToken ( ) ;
14711474 if ( this . peek ( TokenType . BracketL ) || this . peek ( TokenType . Hash ) ) {
@@ -1476,10 +1479,12 @@ export class Parser {
14761479 }
14771480 this . restoreAtMark ( mark ) ;
14781481 }
1479- else if ( this . peekRegExp ( TokenType . Symbol , / ( ^ [ a - z ] \d + $ ) / i) ) {
1482+ // Address e.g: R100, R100.1
1483+ else if ( this . peekRegExp ( TokenType . Symbol , / ( ^ ( [ a - z ] \d + ) ( \. \d + ) ? $ ) / i) ) {
14801484 this . consumeToken ( ) ;
14811485 return this . finish ( node ) ;
14821486 }
1487+
14831488 return null ;
14841489 }
14851490
@@ -1549,17 +1554,10 @@ export class Parser {
15491554
15501555 public _parseSymbol ( referenceTypes ?: nodes . ReferenceType [ ] ) : nodes . Symbol | null {
15511556
1552- // TODO if Reference type undefined, try to find type:
1553- //
1554- // Adress: R100.0 is fixed
1555- // Symbol R100 is Address, Variable or NC Code
1556- // Symbol 100.0 is fixed
1557- // Symbol 100 is Number or Variable
1558-
15591557 if ( ! this . peek ( TokenType . Symbol ) ) {
15601558 return null ;
15611559 }
1562-
1560+
15631561 const node = < nodes . Symbol > this . create ( nodes . Symbol ) ;
15641562 if ( referenceTypes ) {
15651563 node . referenceTypes = referenceTypes ;
0 commit comments