Commit 40eb6617 authored by Diederik van Arkel's avatar Diederik van Arkel

typedecl colouring

parent a849a1f8
......@@ -8,6 +8,9 @@ from EdPosition import :: LineNr
import syncol
import Platform
//import dodebug
trace_n` _ f :== f
//-- stuff we want to parametrise...
/*
class TextAnnot a // b
......@@ -22,7 +25,7 @@ export TextAnnot Void, SyncInf, ConsInf
*/
:: LineAnnot :== Info
dummyLineAnnot :== (0,False,False)
dummyLineAnnot :== (0,False,False,0)
annotLine :== slMap (\s->(dummyLineAnnot,s))
annotWhole :== firstParse
annotPart :== quickParse
......@@ -283,5 +286,4 @@ updateLine lineNr string text=:{ nrLines, blocks }
# after = SCons (pl,string) (slTail after)
#! lines = slAppend before after
# (st,fin,lines) = annotPart lineNr lineNr lines
= (st,fin,{blocks = group BlockSize lines, nrLines = nrLines})
= trace_n` ("updateLine",st,fin) (st,fin,{blocks = group BlockSize lines, nrLines = nrLines})
......@@ -44,7 +44,7 @@ where
scanFirst :: !Int !Int !Int !.String -> (!Int,!Int,!Int)
scanFirst level index indent line
| index >= line_size = (index,indent,level)
| index >= line_size = (index,-1,level)
# char = line.[index]
| char == ' ' = scanFirst level (inc index) (inc indent) line
| char == '\t' = scanFirst level (inc index) ((inc (indent >> 2)) << 2) line
......@@ -104,17 +104,20 @@ scanfunny i line_size line
//:: String State -> ((Info,String),State)
parseLine :: !.State !.String -> (!Bool,!State)
parseLine state=:(level,typedef,typedecl,offside) line
# (index,indent,level) = scanFirst level 0 0 line
# (typedecl,offside) = if typedecl
(if (index < line_size && indent <= offside)
#! (index,indent,level) = scanFirst level 0 0 line
#! (typedecl,offside) = if typedecl
(if (index < line_size && indent >= 0 && indent <= offside)
(False,indent)
(True,offside)
)
(False,indent)
# state = (level,typedef,typedecl,offside)
# has_content = index < line_size
# not_double_colon = line%(index,dec (scanfunny index line_size line)) <> "::"
= (has_content && if (index > 0) not_double_colon True , pL state index)
(False,if (indent >= 0) indent offside)
#! state = (level,typedef,typedecl,offside)
#! has_content = indent >= 0 && index < line_size
| index > 0
#! not_double_colon = line%(index,dec (scanfunny index line_size line)) <> "::"
= (has_content && not_double_colon, pL state index)
= (has_content, pL state index)
// = (has_content && if (index > 0) not_double_colon True , pL state index)
where
line_size = size line
......@@ -171,7 +174,10 @@ where
no_c` = line_size < 2
c` = line.[1]
scanFunny (level,typedef,typedecl,offside) s i
| i >= line_size = pL (level,typedef,typedecl,offside) line_size
| i >= line_size
| level == 0 && line%(s,dec i) == "::"
= pL (0,typedef,True,offside) i
= pL (level,typedef,typedecl,offside) i
#! c = line.[i]
| funnyChar c = scanFunny (level,typedef,typedecl,offside) s (inc i)
| level == 0 && line%(s,dec i) == "::"
......@@ -203,27 +209,29 @@ WhiteSpace c
*/
firstParse :: !(StrictList String) -> StrictList (!Info,!String)
firstParse lines
= slFromList (fP (0,False,False,0) [] lines)
// = slFromList (fP (0,False,False,0) [] lines)
= fP (0,False,False,0) id [] lines
where
fP i acc SNil
= acc
fP i=:(level,typedef,typedecl,offside) acc (SCons h t)
fP :: !(!Int,!Bool,!Bool,!Int) ((StrictList (!Info,!String)) -> StrictList (!Info,!String)) ![(!(!Int,!Bool,!Bool,!Int),!String)] !(StrictList String) -> StrictList (!Info,!String)
fP i res acc SNil
= res (slFromList acc)
fP i=:(level,typedef,typedecl,offside) res acc (SCons h t)
#! (has_contents,j=:(level`,typedef`,typedecl`,offside`)) = parseLine i h
i` = (level,typedef`,typedecl`)
i` = (level,typedef`,typedecl`,offside`)
| typedecl == False && typedecl` && offside < offside`
| has_contents
= acc ++ (fP j [(i`,h)] t)
= fP j (\r -> res (slFromList` acc r)) [(i`,h)] t
// should be identifier in acc...
# j` = (level,typedef,typedecl`,offside)
= [fun s \\ s<- acc] ++ (fP j` [] (SCons h t))
= fP j` (\r -> res (slFromList` [fun s \\ s <- acc] r)) [] (SCons h t)
with
fun :: (!Info,!String) -> (!Info,!String)
fun ((c,t,d),l) = ((c,False,True),l)
fun ((c,t,d,o),l) = ((c,False,True,o),l)
| has_contents
| isEmpty acc
= fP j [(i`,h)] t
= acc ++ (fP j [(i`,h)] t)
= fP j (acc ++[(i`,h)]) t
= fP j res [(i`,h)] t
= fP j (\r -> res (slFromList` acc r)) [(i`,h)] t
= fP j res (acc ++[(i`,h)]) t
/*
quickParse: (first modified line) (last modified line) textlines
......
Markdown is supported
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