@@ -62,14 +62,18 @@ public IToken Zero()
62
62
63
63
var current = _scanner . Current ;
64
64
65
- if ( current == CharacterTable . SmallX )
65
+ if ( current == CharacterTable . SmallX || current == CharacterTable . BigX )
66
66
{
67
67
return Hex ( ) ;
68
68
}
69
- else if ( current == CharacterTable . SmallB )
69
+ else if ( current == CharacterTable . SmallB || current == CharacterTable . BigB )
70
70
{
71
71
return Binary ( ) ;
72
72
}
73
+ else if ( current == CharacterTable . SmallO || current == CharacterTable . BigO )
74
+ {
75
+ return Octal ( ) ;
76
+ }
73
77
else if ( current . IsDigit ( ) || current == CharacterTable . FullStop )
74
78
{
75
79
return Digit ( ) ;
@@ -143,7 +147,26 @@ private IToken Binary()
143
147
weight *= 2 ;
144
148
}
145
149
146
- return Final ( ) ;
150
+ return FinalForAltInteger ( ) ;
151
+ }
152
+
153
+ private IToken Octal ( )
154
+ {
155
+ var numbers = new List < Int32 > ( ) ;
156
+ var weight = 1 ;
157
+
158
+ while ( _scanner . MoveNext ( ) && _scanner . Current . IsInRange ( CharacterTable . Zero , CharacterTable . Seven ) )
159
+ {
160
+ numbers . Add ( _scanner . Current - CharacterTable . Zero ) ;
161
+ }
162
+
163
+ for ( var i = numbers . Count - 1 ; i >= 0 ; -- i )
164
+ {
165
+ AddValue ( 1UL , ( UInt64 ) ( numbers [ i ] * weight ) ) ;
166
+ weight *= 8 ;
167
+ }
168
+
169
+ return FinalForAltInteger ( ) ;
147
170
}
148
171
149
172
private IToken Hex ( )
@@ -162,7 +185,7 @@ private IToken Hex()
162
185
weight *= 16 ;
163
186
}
164
187
165
- return Final ( ) ;
188
+ return FinalForAltInteger ( ) ;
166
189
}
167
190
168
191
private IToken Decimal ( )
@@ -236,6 +259,16 @@ private IToken Exponent()
236
259
return Final ( ) ;
237
260
}
238
261
262
+ private IToken FinalForAltInteger ( )
263
+ {
264
+ if ( _scanner . Current == CharacterTable . FullStop )
265
+ {
266
+ AddError ( ErrorCode . DotUnexpected , _scanner . Position . ToRange ( ) ) ;
267
+ }
268
+
269
+ return Final ( ) ;
270
+ }
271
+
239
272
private IToken Final ( )
240
273
{
241
274
_scanner . MoveBack ( ) ;
@@ -244,11 +277,7 @@ private IToken Final()
244
277
245
278
private void AddError ( ErrorCode code , ITextRange range )
246
279
{
247
- if ( _errors == null )
248
- {
249
- _errors = [ ] ;
250
- }
251
-
280
+ _errors ??= [ ] ;
252
281
_errors . Add ( new ParseError ( code , range ) ) ;
253
282
}
254
283
0 commit comments