Commit 03c6bc8d authored by John van Groningen's avatar John van Groningen
Browse files

fix parsing of [# with layout rule

parent e02ca6b5
...@@ -2450,7 +2450,9 @@ HeadUnboxedAndTailStrict:==4; ...@@ -2450,7 +2450,9 @@ HeadUnboxedAndTailStrict:==4;
wantListExp :: !Bool !ParseState -> (ParsedExpr, !ParseState) wantListExp :: !Bool !ParseState -> (ParsedExpr, !ParseState)
wantListExp is_pattern pState wantListExp is_pattern pState
# pState=appScanState setNoNewOffsideForSeqLetBit pState
# (token, pState) = nextToken FunctionContext pState # (token, pState) = nextToken FunctionContext pState
# pState=appScanState clearNoNewOffsideForSeqLetBit pState
# (head_strictness,token,pState) = wantHeadStrictness token pState # (head_strictness,token,pState) = wantHeadStrictness token pState
with with
wantHeadStrictness :: Token *ParseState -> *(!Int,!Token,!*ParseState) wantHeadStrictness :: Token *ParseState -> *(!Int,!Token,!*ParseState)
......
...@@ -167,3 +167,6 @@ determinePriority :: !Priority !Priority -> Optional Bool ...@@ -167,3 +167,6 @@ determinePriority :: !Priority !Priority -> Optional Bool
/* ... Sjaak */ /* ... Sjaak */
setNoNewOffsideForSeqLetBit :: !ScanState -> ScanState
clearNoNewOffsideForSeqLetBit :: !ScanState -> ScanState
...@@ -67,6 +67,8 @@ where ...@@ -67,6 +67,8 @@ where
ScanOptionUseLayoutBit :== 1 ScanOptionUseLayoutBit :== 1
ScanOptionUnderscoreIdentsBit :== 2 ScanOptionUnderscoreIdentsBit :== 2
ScanOptionNoNewOffsideForSeqLetBit:==4;
:: * ScanInput :: * ScanInput
= Input Input = Input Input
| PushedToken LongToken ScanInput | PushedToken LongToken ScanInput
...@@ -1557,6 +1559,12 @@ setUseUnderscoreIdents b (ScanState ss) = ScanState (setUseUnderscoreIdents_ b ...@@ -1557,6 +1559,12 @@ setUseUnderscoreIdents b (ScanState ss) = ScanState (setUseUnderscoreIdents_ b
setUseUnderscoreIdents_ :: !Bool !RScanState -> RScanState setUseUnderscoreIdents_ :: !Bool !RScanState -> RScanState
setUseUnderscoreIdents_ b ss=:{ss_scanOptions} = { ss & ss_scanOptions = if b (ss_scanOptions bitor ScanOptionUnderscoreIdentsBit) (ss_scanOptions bitand (bitnot ScanOptionUnderscoreIdentsBit)) } // -->> ("uselayout set to ",b) setUseUnderscoreIdents_ b ss=:{ss_scanOptions} = { ss & ss_scanOptions = if b (ss_scanOptions bitor ScanOptionUnderscoreIdentsBit) (ss_scanOptions bitand (bitnot ScanOptionUnderscoreIdentsBit)) } // -->> ("uselayout set to ",b)
setNoNewOffsideForSeqLetBit :: !ScanState -> ScanState
setNoNewOffsideForSeqLetBit (ScanState ss=:{ss_scanOptions}) = ScanState { ss & ss_scanOptions = ss_scanOptions bitor ScanOptionNoNewOffsideForSeqLetBit};
clearNoNewOffsideForSeqLetBit :: !ScanState -> ScanState
clearNoNewOffsideForSeqLetBit (ScanState ss=:{ss_scanOptions}) = ScanState { ss & ss_scanOptions = ss_scanOptions bitand (bitnot ScanOptionNoNewOffsideForSeqLetBit)};
checkOffside :: !FilePosition !Int !Token !RScanState -> (Token,RScanState) checkOffside :: !FilePosition !Int !Token !RScanState -> (Token,RScanState)
checkOffside pos index token scanState=:{ss_offsides,ss_scanOptions,ss_input} checkOffside pos index token scanState=:{ss_offsides,ss_scanOptions,ss_input}
| (ss_scanOptions bitand ScanOptionUseLayoutBit) == 0 | (ss_scanOptions bitand ScanOptionUseLayoutBit) == 0
...@@ -1629,8 +1637,13 @@ checkOffside pos index token scanState=:{ss_offsides,ss_scanOptions,ss_input} ...@@ -1629,8 +1637,13 @@ checkOffside pos index token scanState=:{ss_offsides,ss_scanOptions,ss_input}
= (token, { scanState & ss_offsides = tl ss_offsides }) = (token, { scanState & ss_offsides = tl ss_offsides })
= newOffside token scanState = newOffside token scanState
where where
newOffside token scanState=:{ss_offsides} newOffside token scanState=:{ss_offsides,ss_scanOptions}
| definesOffside token | definesOffside token
&& ((ss_scanOptions bitand ScanOptionNoNewOffsideForSeqLetBit)==0
|| (case token of
SeqLetToken _ -> False
_ -> True
))
# ( _, scanState ) = nextToken FunctionContext scanState # ( _, scanState ) = nextToken FunctionContext scanState
( os_pos, scanState ) = getPosition scanState // next token defines offside position ( os_pos, scanState ) = getPosition scanState // next token defines offside position
scanState = tokenBack scanState scanState = tokenBack scanState
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment