Skip to content
GitLab
Menu
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
63f38c1d
Commit
63f38c1d
authored
Mar 25, 2021
by
John van Groningen
Browse files
refactor, add getCurrentAndPrevious2Positions to scanner
parent
fac04509
Changes
3
Hide whitespace changes
Inline
Side-by-side
frontend/parse.icl
View file @
63f38c1d
...
...
@@ -2206,7 +2206,7 @@ where
gcf_generic_info
=
gcf_generic_info
,
gcf_body
=
GCB_None
,
gcf_kind
=
KindError
,
gcf_generic_instance_deps
=
generic_instance_deps
}
}
=
(
derive_def
,
token
,
pState
)
=
(
derive_def
,
token
,
pState
)
want_derive_class_types
::
Ident
!*
ParseState
->
([
GenericCaseDef
],
!*
ParseState
)
want_derive_class_types
class_ident
pState
...
...
@@ -3312,13 +3312,7 @@ trySimpleType_strictness_ignored attr pState
=
(
result
==
ParseOk
,
atype
,
pState
)
is_tail_strict_list_or_nil
pState
#
(
square_close_position
,
pState
)
=
getPosition
pState
#
pState
=
tokenBack
pState
#
(
exclamation_position
,
pState
)
=
getPosition
pState
#
pState
=
tokenBack
pState
#
(
square_open_position
,
pState
)
=
getPosition
pState
#
(
exclamation_token
,
pState
)
=
nextToken
TypeContext
pState
#
(
square_close_token
,
pState
)
=
nextToken
TypeContext
pState
#
(
square_close_position
,
exclamation_position
,
square_open_position
,
pState
)
=
getCurrentAndPrevious2Positions
pState
|
exclamation_position
.
fp_col
+1
==
square_close_position
.
fp_col
&&
exclamation_position
.
fp_line
==
square_close_position
.
fp_line
&&
(
square_open_position
.
fp_col
+1
<>
exclamation_position
.
fp_col
||
square_open_position
.
fp_line
<>
exclamation_position
.
fp_line
)
=
(
True
,
pState
)
...
...
@@ -4189,7 +4183,7 @@ wantListPatternWithoutDefinitions pState
#
(
token
,
pState
)
=
nextToken
FunctionContext
pState
#
pState
=
appScanState
clearNoNewOffsideForSeqLetBit
pState
#
(
head_strictness
,
token
,
pState
)
=
want_head_strictness
token
pState
|
token
=:
ExclamationToken
&&
(
head_strictness
<
>
HeadOverloaded
&&
head_strictness
<>
HeadUnboxedAndTailStrict
)
|
token
=:
ExclamationToken
&&
head_strictness
<
=
HeadUnboxed
#
(
token
,
pState
)
=
nextToken
FunctionContext
pState
|
token
==
SquareCloseToken
=
(
makeTailStrictNilExpression
head_strictness
cIsAPattern
,
pState
)
...
...
@@ -4286,7 +4280,7 @@ wantListExp is_pattern pState
#
(
token
,
pState
)
=
nextToken
FunctionContext
pState
#
pState
=
appScanState
clearNoNewOffsideForSeqLetBit
pState
#
(
head_strictness
,
token
,
pState
)
=
want_head_strictness
token
pState
|
token
=:
ExclamationToken
&&
(
head_strictness
<
>
HeadOverloaded
&&
head_strictness
<>
HeadUnboxedAndTailStrict
)
|
token
=:
ExclamationToken
&&
head_strictness
<
=
HeadUnboxed
#
(
token
,
pState
)
=
nextToken
FunctionContext
pState
|
token
==
SquareCloseToken
=
(
makeTailStrictNilExpression
head_strictness
is_pattern
,
pState
)
...
...
@@ -5493,6 +5487,12 @@ instance getPosition ParseState
where
getPosition
pState
=
accScanState
getPosition
pState
instance
getCurrentAndPrevious2Positions
ParseState
where
getCurrentAndPrevious2Positions
pState
=:{
ps_scanState
}
#
(
p1
,
p2
,
p3
,
ps_scanState
)
=
getCurrentAndPrevious2Positions
ps_scanState
=
(
p1
,
p2
,
p3
,{
pState
&
ps_scanState
=
ps_scanState
})
warnIfStrictAnnot
NoAnnot
pState
=
pState
warnIfStrictAnnot
(
StrictAnnotWithPosition
position
)
pState
=
parseWarningWithPosition
""
"! ignored"
position
pState
...
...
frontend/scanner.dcl
View file @
63f38c1d
...
...
@@ -153,6 +153,9 @@ instance currentToken ScanState
class
getPosition
state
::
!*
state
->
(!
FilePosition
,!*
state
)
// Position of current Token (or Char)
instance
getPosition
ScanState
class
getCurrentAndPrevious2Positions
state
::
!*
state
->
(!
FilePosition
,!
FilePosition
,!
FilePosition
,!*
state
)
instance
getCurrentAndPrevious2Positions
ScanState
fopenInSearchPaths
::
!{#
Char
}
!{#
Char
}
!
SearchPaths
!
Int
(
ModTimeFunction
*
Files
)
!*
Files
->
(
Optional
(*
File
,
{#
Char
},
{#
Char
}),!*
Files
)
openScanner
::
!*
File
!
String
!
String
->
ScanState
...
...
frontend/scanner.icl
View file @
63f38c1d
...
...
@@ -51,6 +51,11 @@ where
#
(
position
,
scan_state
)
=
getPosition
scan_state
=
(
position
,
ScanState
scan_state
)
instance
getCurrentAndPrevious2Positions
ScanState
where
getCurrentAndPrevious2Positions
scanState
=:(
ScanState
{
ss_tokenBuffer
=
Buffer3
x
y
z
})
=
(
x
.
lt_position
,
y
.
lt_position
,
z
.
lt_position
,
scanState
)
::
*
RScanState
=
{
ss_input
::
ScanInput
,
ss_offsides
::
!
[(
Int
,
Bool
)
]
// (column, defines newDefinition)
...
...
Write
Preview
Supports
Markdown
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