Skip to content

Commit

Permalink
IOS-XR: parser overhaul numbers (#6886)
Browse files Browse the repository at this point in the history
* Remove DEC and add UINT types
* Add uint_xxx rules to common
* update interface_name
* update vlan_id
* Update number converters in XrCPE
* change DEC references to uint_legacy
* update ctx.DEC() references to ctx.uint_legacy()
* update refs
  • Loading branch information
arifogel committed Apr 9, 2021
1 parent d9ccd71 commit a9dc6db
Show file tree
Hide file tree
Showing 27 changed files with 994 additions and 834 deletions.
Expand Up @@ -29,7 +29,6 @@ tokens {
STATEFUL_KERBEROS,
STATEFUL_NTLM,
TEXT,
UINT16,
VALUE,
WIRED,
WISPR,
Expand Down Expand Up @@ -5844,12 +5843,11 @@ DOLLAR
'$'
;

DEC: F_Digit+;

DIGIT
:
F_Digit
;
UINT8: F_Uint8;
UINT16: F_Uint16;
UINT32: F_Uint32;
UINT64: F_Uint64;
UINT_BIG: F_UintBig;

DOUBLE_QUOTE
:
Expand Down Expand Up @@ -6232,6 +6230,16 @@ F_StandardCommunity
F_Uint16 ':' F_Uint16
;
fragment
F_Uint8
:
F_Digit
| F_PositiveDigit F_Digit
| '1' F_Digit F_Digit
| '2' [0-4] F_Digit
| '25' [0-5]
;
fragment
F_Uint16
:
Expand All @@ -6244,6 +6252,66 @@ F_Uint16
| '6553' [0-5]
;
fragment
F_Uint32
:
// 0-4294967295
'0'
| F_PositiveDigit F_Digit F_Digit? F_Digit? F_Digit? F_Digit? F_Digit? F_Digit? F_Digit?
| [1-3] F_Digit F_Digit F_Digit F_Digit F_FiveDigits
| '4' [0-1] F_Digit F_Digit F_Digit F_FiveDigits
| '42' [0-8] F_Digit F_Digit F_FiveDigits
| '429' [0-3] F_Digit F_FiveDigits
| '4294' [0-8] F_FiveDigits
| '42949' [0-5] F_Digit F_Digit F_Digit F_Digit
| '429496' [0-6] F_Digit F_Digit F_Digit
| '4294967' [0-1] F_Digit F_Digit
| '42949672' [0-8] F_Digit
| '429496729' [0-5]
;
fragment
F_FiveDigits
:
F_Digit F_Digit F_Digit F_Digit F_Digit
;
fragment
F_Uint64
:
// 0-18446744073709551615
'1844674407370955161' [0-5]
| '184467440737095516' '0' F_Digit
| '18446744073709551' [0-5] F_Digit F_Digit
| '1844674407370955' '0' F_Digit F_Digit F_Digit
| '184467440737095' [0-4] F_Digit F_Digit F_Digit F_Digit
| '18446744073709' [0-4] F_FiveDigits
| '1844674407370' [0-8] F_Digit F_FiveDigits
// nothing lower than 0 for thirteenth digit
| '18446744073' [0-6] F_Digit F_Digit F_Digit F_FiveDigits
| '1844674407' [0-2] F_Digit F_Digit F_Digit F_Digit F_FiveDigits
| '184467440' [0-6] F_FiveDigits F_FiveDigits
// nothing lower than 0 for ninth digit
| '1844674' [0-3] F_Digit F_Digit F_FiveDigits F_FiveDigits
| '184467' [0-3] F_Digit F_Digit F_Digit F_FiveDigits F_FiveDigits
| '18446' [0-6] F_Digit F_Digit F_Digit F_Digit F_FiveDigits F_FiveDigits
| '1844' [0-5] F_FiveDigits F_FiveDigits F_FiveDigits
| '184' [0-3] F_Digit F_FiveDigits F_FiveDigits F_FiveDigits
| '18' [0-3] F_Digit F_Digit F_FiveDigits F_FiveDigits F_FiveDigits
| '1' [0-7] F_Digit F_Digit F_Digit F_FiveDigits F_FiveDigits F_FiveDigits
// All the non-zero numbers from 1-19 digits
| F_PositiveDigit F_Digit? F_Digit? F_Digit? F_Digit? F_Digit? F_Digit? F_Digit? F_Digit? F_Digit? F_Digit? F_Digit? F_Digit? F_Digit? F_Digit? F_Digit? F_Digit? F_Digit? F_Digit?
// Zero
| '0'
;
fragment
F_UintBig
:
F_PositiveDigit F_Digit*
| '0'
;
fragment
F_UpperCaseLetter
:
Expand Down Expand Up @@ -6333,20 +6401,12 @@ M_Alias_WS
mode M_AsPath;
M_AsPath_ACCESS_LIST
:
'access-list' -> type ( ACCESS_LIST ) , mode ( M_AsPathAccessList )
;
M_AsPath_CONFED
:
'confed' -> type ( CONFED ) , popMode
;
M_AsPath_DEC
:
F_Digit+ -> type ( DEC ) , popMode
;
M_AsPath_UINT32: F_Uint32 -> type(UINT32), popMode;
M_AsPath_RP_VARIABLE
:
Expand Down Expand Up @@ -6410,43 +6470,6 @@ M_AsPath_WS
F_Whitespace+ -> channel ( HIDDEN )
;
mode M_AsPathAccessList;
M_AsPathAccessList_DEC
:
F_Digit+ -> type ( DEC )
;
M_AsPathAccessList_DENY
:
'deny' -> type ( DENY ) , mode ( M_Description )
;
M_AsPathAccessList_NEWLINE
:
F_Newline -> type ( NEWLINE ) , mode ( DEFAULT_MODE )
;
M_AsPathAccessList_PERMIT
:
'permit' -> type ( PERMIT ) , mode ( M_Description )
;
M_AsPathAccessList_SEQ
:
'seq' -> type ( SEQ )
;
M_AsPathAccessList_VARIABLE
:
F_Variable_RequiredVarChar F_Variable_VarChar* -> type ( VARIABLE )
;
M_AsPathAccessList_WS
:
F_Whitespace+ -> channel ( HIDDEN )
;
mode M_Authentication;
M_Authentication_DOUBLE_QUOTE
Expand Down Expand Up @@ -6484,9 +6507,9 @@ M_Authentication_CONTROL_DIRECTION
'control-direction' -> type ( CONTROL_DIRECTION ) , popMode
;
M_Authentication_DEC
M_Authentication_UINT_BIG
:
F_Digit+ -> type ( DEC ) , popMode
F_UintBig -> type (UINT_BIG) , popMode
;
M_Authentication_DOT1X
Expand Down Expand Up @@ -7044,10 +7067,7 @@ M_Interface_NEWLINE
F_Newline -> type ( NEWLINE ) , popMode
;
M_Interface_NUMBER
:
DEC -> type ( DEC )
;
M_Interface_NUMBER: F_UintBig -> type (UINT_BIG);
M_Interface_PERIOD
:
Expand Down
Expand Up @@ -713,7 +713,7 @@ s_control_plane
:
CONTROL_PLANE
(
SLOT DEC
SLOT uint_legacy
)? NEWLINE s_control_plane_tail*
;

Expand Down Expand Up @@ -1021,7 +1021,7 @@ spti_null

srlg_interface_numeric_stanza
:
DEC null_rest_of_line
uint_legacy null_rest_of_line
;

srlg_interface_stanza
Expand Down Expand Up @@ -1066,7 +1066,7 @@ ssh_server
| LOGGING
|
(
SESSION_LIMIT limit = DEC
SESSION_LIMIT limit = uint_legacy
)
| V2
|
Expand All @@ -1078,7 +1078,7 @@ ssh_server

ssh_timeout
:
TIMEOUT DEC NEWLINE
TIMEOUT uint_legacy NEWLINE
;

// old top-level rules (from hybrid cisco parser)
Expand Down Expand Up @@ -1204,7 +1204,7 @@ t_server_null

t_key
:
KEY DEC? variable_permissive NEWLINE
KEY uint_legacy? variable_permissive NEWLINE
;

t_source_interface
Expand Down Expand Up @@ -1318,9 +1318,9 @@ u_passphrase
:
PASSPHRASE
(
GRACETIME gracetime = DEC
| LIFETIME lifetime = DEC
| WARNTIME warntime = DEC
GRACETIME gracetime = uint_legacy
| LIFETIME lifetime = uint_legacy
| WARNTIME warntime = uint_legacy
)*
;

Expand Down Expand Up @@ -1353,7 +1353,7 @@ ua_null

up_cisco_xr
:
DEC? up_cisco_xr_tail
uint_legacy? up_cisco_xr_tail
;

up_cisco_xr_tail
Expand All @@ -1369,7 +1369,7 @@ up_cisco_xr_tail

viaf_vrrp
:
NO? VRRP groupnum = DEC NEWLINE
NO? VRRP groupnum = uint_legacy NEWLINE
(
viafv_address
| viafv_null
Expand All @@ -1396,13 +1396,13 @@ viafv_preempt
:
PREEMPT
(
DELAY delay = DEC
DELAY delay = uint_legacy
) NEWLINE
;

viafv_priority
:
PRIORITY priority = DEC NEWLINE
PRIORITY priority = uint_legacy NEWLINE
;

vrrp_interface
Expand Down

0 comments on commit a9dc6db

Please sign in to comment.