Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clean-sapl
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clean-and-itasks
clean-sapl
Commits
3ae4b4d4
Commit
3ae4b4d4
authored
Apr 28, 2016
by
Jurriën Stutterheim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Somewhat better index checking in the tokenizer
parent
8de10300
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
28 deletions
+36
-28
src/Sapl/SaplTokenizer.icl
src/Sapl/SaplTokenizer.icl
+36
-28
No files found.
src/Sapl/SaplTokenizer.icl
View file @
3ae4b4d4
...
...
@@ -18,11 +18,16 @@ not_eol c = not (c == '\n')
find_first_string
::
!
String
!
Int
(
Char
String
Int
->
Bool
)
->
Int
find_first_string
line
start
f
|
start
==
size
line
=
size
line
|
f
line
.[
start
-1
]
line
start
=
find_first_string
line
(
start
+
1
)
f
=
start
#
lineSz
=
size
line
|
start
==
lineSz
=
lineSz
#
newPos
=
start
-
1
|
newPos
>=
lineSz
=
abort
"find_first_string newPos >= lineSz"
|
f
line
.[
newPos
]
line
start
=
find_first_string
line
(
start
+
1
)
f
|
otherwise
=
start
read_string_lit
::
!
Char
!
Int
!
String
->
(!
Int
,
!
UString
)
read_string_lit
qc
start
str
...
...
@@ -30,27 +35,29 @@ read_string_lit qc start str
=
(
nextbase
,
reverse
l
)
where
decode
p
cs
|
eof
p
=
(
p
,
cs
)
|
str
.[
p
]
==
qc
=
(
p
+1
,
cs
)
|
str
.[
p
]
==
'\\'
=
let
(
n
,
c
)
=
decodeBSChar
(
p
+1
)
in
decode
n
[
c
:
cs
]
=
decode
(
p
+1
)
[
fromChar
str
.[
p
]:
cs
]
|
eof
p
=
(
p
,
cs
)
#
strP
=
str
.[
p
]
|
strP
==
qc
=
(
p
+1
,
cs
)
|
strP
==
'\\'
=
let
(
n
,
c
)
=
decodeBSChar
(
p
+1
)
in
decode
n
[
c
:
cs
]
|
otherwise
=
decode
(
p
+1
)
[
fromChar
strP
:
cs
]
decodeBSChar
p
|
eof
p
=
(
p
,
fromChar
'\\'
)
|
str
.[
p
]
==
'0'
=
(
p
+1
,
fromInt
0
)
|
str
.[
p
]
==
'a'
=
(
p
+1
,
fromInt
7
)
|
str
.[
p
]
==
'b'
=
(
p
+1
,
fromChar
'\b'
)
|
str
.[
p
]
==
'f'
=
(
p
+1
,
fromChar
'\f'
)
|
str
.[
p
]
==
'n'
=
(
p
+1
,
fromChar
'\n'
)
|
str
.[
p
]
==
'r'
=
(
p
+1
,
fromChar
'\r'
)
|
str
.[
p
]
==
't'
=
(
p
+1
,
fromChar
'\t'
)
|
str
.[
p
]
==
'v'
=
(
p
+1
,
fromChar
'\v'
)
|
str
.[
p
]
==
'\''
=
(
p
+1
,
fromChar
'\''
)
|
str
.[
p
]
==
'"'
=
(
p
+1
,
fromChar
'"'
)
|
str
.[
p
]
==
'x'
=
decodeHex
2
2
0
|
str
.[
p
]
==
'u'
=
decodeHex
4
4
0
|
str
.[
p
]
==
'U'
=
decodeHex
8
8
0
=
(
p
+1
,
fromChar
str
.[
p
])
// skip the backslash otherwise
|
eof
p
=
(
p
,
fromChar
'\\'
)
#
strP
=
str
.[
p
]
|
strP
==
'0'
=
(
p
+1
,
fromInt
0
)
|
strP
==
'a'
=
(
p
+1
,
fromInt
7
)
|
strP
==
'b'
=
(
p
+1
,
fromChar
'\b'
)
|
strP
==
'f'
=
(
p
+1
,
fromChar
'\f'
)
|
strP
==
'n'
=
(
p
+1
,
fromChar
'\n'
)
|
strP
==
'r'
=
(
p
+1
,
fromChar
'\r'
)
|
strP
==
't'
=
(
p
+1
,
fromChar
'\t'
)
|
strP
==
'v'
=
(
p
+1
,
fromChar
'\v'
)
|
strP
==
'\''
=
(
p
+1
,
fromChar
'\''
)
|
strP
==
'"'
=
(
p
+1
,
fromChar
'"'
)
|
strP
==
'x'
=
decodeHex
2
2
0
|
strP
==
'u'
=
decodeHex
4
4
0
|
strP
==
'U'
=
decodeHex
8
8
0
|
otherwise
=
(
p
+1
,
fromChar
strP
)
// skip the backslash otherwise
where
decodeHex
::
!
Int
!
Int
!
Int
->
(!
Int
,
!
UChar
)
decodeHex
len
s
acc
...
...
@@ -140,12 +147,13 @@ read_token base line
"select"
=
return
(
TSelectKeyword
,
stop
)
"let"
=
return
(
TLetKeyword
,
stop
)
"in"
=
return
(
TInKeyword
,
stop
)
str
=
if
(
str
.[
0
]
==
'!'
)
(
return
(
TStrictIdentifier
(
str
%
(
1
,
size
str
)),
stop
))
(
return
(
TIdentifier
str
,
stop
))
str
#
strSz
=
size
str
|
strSz
>
0
&&
str
.[
0
]
==
'!'
=
return
(
TStrictIdentifier
(
str
%
(
1
,
strSz
)),
stop
)
|
otherwise
=
return
(
TIdentifier
str
,
stop
)
where
tstr
stop
=
line
%
(
start
,
stop
-
1
)
start
=
(
skipChars
line
base
is_space
)
start
=
skipChars
line
base
is_space
rnoarg
t
length
=
(
start
,
start
+
length
,
t
)
return
(
a
,
newbase
)
=
(
start
,
newbase
,
a
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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