Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-compiler-and-rts
compiler
Commits
681110b4
Commit
681110b4
authored
Jul 25, 2018
by
John van Groningen
Browse files
fix scanning of hexadecimal and octal number preceded by a '-'
(modification of bug fix submitted by Mart Lubbers)
parent
8ce28293
Changes
1
Hide whitespace changes
Inline
Side-by-side
frontend/scanner.icl
View file @
681110b4
...
...
@@ -520,7 +520,7 @@ ScanComment2 c1 input
'/'
->
ScanComment
(
SkipToEndOfLine
input
)
'*'
->
case
ScanComment
input
of
(
No
,
input
)
->
ScanComment
input
error
->
error
error
->
error
_
->
ScanComment
input
|
c1
==
'*'
#
(
eol2
,
c2
,
input
)
=
ReadNormalChar
input
...
...
@@ -966,9 +966,9 @@ ScanNumeral n input chars=:['0':r]
|
c
==
'x'
#
(
eof
,
c1
,
input
)
=
ReadNormalChar
input
|
eof
=
(
IntToken
"0"
,
charBack
input
)
|
isHexDigit
c1
=
ScanHexNumeral
(~
(
hexDigitToInt
c1
)
)
input
|
isHexDigit
c1
=
Scan
Negative
HexNumeral
(
hexDigitToInt
c1
)
input
=
(
IntToken
"0"
,
charBack
(
charBack
input
))
|
isOctDigit
c
=
ScanOctNumeral
(~
(
digitToInt
c
)
)
input
|
isOctDigit
c
=
Scan
Negative
OctNumeral
(
digitToInt
c
)
input
|
c
==
'.'
=
TestFraction
n
input
chars
=
(
IntToken
"0"
,
charBack
input
)
ScanNumeral
n
input
chars
...
...
@@ -1016,19 +1016,39 @@ ScanExponent n input chars
[
c
:_]
|
IsDigit
c
->
(
RealToken
(
revCharListToString
n
chars
),
charBack
input
)
_
->
(
ErrorToken
(
"Digit expected after "
+
revCharListToString
n
chars
),
charBack
input
)
ScanHexNumeral
::
!
Int
!
Input
->
(!
Token
,
!
Input
)
ScanHexNumeral
::
!
Int
!
Input
->
(!
Token
,
!
Input
)
ScanHexNumeral
n
input
#
(
n
,
input
)
=
ReadHexNumeral
n
input
=
(
IntToken
(
toString
n
),
input
)
ScanNegativeHexNumeral
::
!
Int
!
Input
->
(!
Token
,
!
Input
)
ScanNegativeHexNumeral
n
input
#
(
n
,
input
)
=
ReadHexNumeral
n
input
=
(
IntToken
(
toString
(~
n
)),
input
)
ReadHexNumeral
::
!
Int
!
Input
->
(!
Int
,
!
Input
)
ReadHexNumeral
n
input
#
(
eof
,
c
,
input
)
=
ReadNormalChar
input
|
eof
=
(
IntToken
(
toString
n
)
,
input
)
|
isHexDigit
c
=
Scan
HexNumeral
(
n
*
16
+
hexDigitToInt
c
)
input
=
(
IntToken
(
toString
n
)
,
charBack
input
)
|
eof
=
(
n
,
input
)
|
isHexDigit
c
=
Read
HexNumeral
(
n
*
16
+
hexDigitToInt
c
)
input
=
(
n
,
charBack
input
)
ScanOctNumeral
::
!
Int
!
Input
->
(!
Token
,
!
Input
)
ScanOctNumeral
::
!
Int
!
Input
->
(!
Token
,
!
Input
)
ScanOctNumeral
n
input
#
(
n
,
input
)
=
ReadOctNumeral
n
input
=
(
IntToken
(
toString
n
),
input
)
ScanNegativeOctNumeral
::
!
Int
!
Input
->
(!
Token
,
!
Input
)
ScanNegativeOctNumeral
n
input
#
(
n
,
input
)
=
ReadOctNumeral
n
input
=
(
IntToken
(
toString
(~
n
)),
input
)
ReadOctNumeral
::
!
Int
!
Input
->
(!
Int
,
!
Input
)
ReadOctNumeral
n
input
#
(
eof
,
c
,
input
)
=
ReadNormalChar
input
|
eof
=
(
IntToken
(
toString
n
)
,
input
)
|
isOctDigit
c
=
Scan
OctNumeral
(
n
*
8
+
digitToInt
c
)
input
=
(
IntToken
(
toString
n
)
,
charBack
input
)
|
eof
=
(
n
,
input
)
|
isOctDigit
c
=
Read
OctNumeral
(
n
*
8
+
digitToInt
c
)
input
=
(
n
,
charBack
input
)
ScanChar
::
!
Input
->
(!
Token
,
!
Input
)
ScanChar
input
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment