Commit f9e401c1 authored by John van Groningen's avatar John van Groningen

use a record instead of a tuple for type Info

parent df221f6c
......@@ -25,7 +25,7 @@ export TextAnnot Void, SyncInf, ConsInf
*/
:: LineAnnot :== Info
dummyLineAnnot :== (0,False,False,0,False)
dummyLineAnnot :== {comment_level=0,is_typedef=False,is_typedecl=False,offside_level=0,flush=False}
annotLine :== slMap (\s->(dummyLineAnnot,s))
annotWhole :== firstParse
annotPart :== quickParse
......
......@@ -94,7 +94,7 @@ optDrawS :== pictdrawstring // use non-optimised versions
optDrawC :== pictdrawchar // "
tabDrawStringC :: !Point2 !(!Info,!String) !FontInfo !*Picture -> *Picture
tabDrawStringC point ((clevel,typedef,typedecl,_,_),string)
tabDrawStringC point ({comment_level=clevel,is_typedef=typedef,is_typedecl=typedecl},string)
{tabSize,charWidth,thefont, showTabs, syntaxColours={textColour, backgroundColour,tabColour, commentColour, stringColour, charColour, keywordColour, typedefColour, typedeclColour}}
picture
#! strings = splitAtTabs string
......
......@@ -5,15 +5,15 @@ definition module syncol
import StdString
import StrictList
:: Info :==
(!Int // comment nesting level at start of line
// ,!Bool // in typedef at start of line
,!Bool // is typedef line
// ,!Bool // in typedecl at start of line
,!Bool // is typedecl line
,!Int // context offside level
,!Bool // flush accu
)
:: Info =
{comment_level::!Int // comment nesting level at start of line
// ,!Bool // in typedef at start of line
,is_typedef::!Bool // is typedef line
// ,!Bool // in typedecl at start of line
,is_typedecl::!Bool // is typedecl line
,offside_level::!Int // context offside level
,flush::!Bool // flush accu
}
// pack bools into bitfield?
firstParse :: !(StrictList String) -> StrictList (!Info,!String)
......
......@@ -56,12 +56,17 @@ where
= res acc
backpatch state res acc old=:[(state`,line):lines]
# flush = state`.has_content || (not (state.typedecl) && state`.typedecl)
# info = ((state.level,state`.typedef,state`.typedecl,state`.offside,flush),line)
#! info = { comment_level=state.level,
is_typedef=state`.typedef,
is_typedecl=state`.typedecl,
offside_level=state`.offside,
flush=flush}
# info_and_line = (info,line)
| state`.has_content
= backpatch state` (copy res acc) [info] lines
= backpatch state` (copy res acc) [info_and_line] lines
| not (state.typedecl) && state`.typedecl
= backpatch state` (patch res acc) [info] lines
= backpatch state` res (accum acc info) lines
= backpatch state` (patch res acc) [info_and_line] lines
= backpatch state` res (accum acc info_and_line) lines
/*
quickParse: (first modified line) (last modified line) textlines
......@@ -76,7 +81,7 @@ quickParse beg end lines
where
before idx res state reversed_acc SNil
= (0,0,res (reverse reversed_acc))
before idx res state reversed_acc old=:(SCons (info=:(level,def,dec,off,flush),line) lines)
before idx res state reversed_acc old=:(SCons (info=:{comment_level=level,is_typedef=def,is_typedecl=dec,offside_level=off,flush=flush},line) lines)
| idx < beg
| flush
= before (inc idx) res state [(info,line):reversed_acc] lines
......@@ -91,12 +96,16 @@ where
= after beg idx state res acc old
# state` = parseLine state line
# flush = state`.has_content || (not (state.typedecl) && state`.typedecl)
# info = ((state.level,state`.typedef,state`.typedecl,state`.offside,state`.has_content),line)
# info_and_line = ({comment_level=state.level,
is_typedef=state`.typedef,
is_typedecl=state`.typedecl,
offside_level=state`.offside,
flush=state`.has_content},line)
| state`.has_content
= during beg (inc idx) state` (copy res acc) [info] lines
= during beg (inc idx) state` (copy res acc) [info_and_line] lines
| not (state.typedecl) && state`.typedecl
= during beg idx {state & typedecl=True} (patch res acc) [] old
= during beg (inc idx) state` res (acc++[info]) lines
= during beg (inc idx) state` res (acc++[info_and_line]) lines
after beg idx state res acc SNil
= (beg,dec idx,res acc)
......@@ -104,7 +113,11 @@ where
// kan stoppen als na flush info's gelijk zijn...
# state` = parseLine state line
# flush` = state`.has_content || (not (state.typedecl) && state`.typedecl)
# info` = (state.level,state`.typedef,state`.typedecl,state`.offside,flush`)
# info` = { comment_level=state.level,
is_typedef=state`.typedef,
is_typedecl=state`.typedecl,
offside_level=state`.offside,
flush=flush`}
| state`.has_content
| eqInfo info info`
= (beg, idx,res (acc ++ (slToList old)))
......@@ -117,13 +130,14 @@ copy res acc rest
= res (acc ++ rest)
patch res acc rest
= res ((map (\((c,t,d,o,h),l)->((c,False,True,o,h),l)) acc) ++ rest)
= res ((map (\ (info,l) = ({info & is_typedef=False,is_typedecl=True},l)) acc) ++ rest)
accum acc info
= acc ++ [info]
eqInfo :: !Info !Info -> Bool
eqInfo (a,b,c,d,e) (a`,b`,c`,d`,e`) = a==a` && b==b` && c==c` && d==d` && e==e`
eqInfo {comment_level=a,is_typedef=b,is_typedecl=c,offside_level=d,flush=e} {comment_level=a`,is_typedef=b`,is_typedecl=c`,offside_level=d`,flush=e`}
= a==a` && b==b` && c==c` && d==d` && e==e`
instance == ParseState where
(==) StartOfBlock StartOfBlock = True
......
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