1 | module Idris.IDEMode.TokenLine
3 | import Parser.Lexer.Source
4 | import Libraries.Text.Lexer
28 | toString : SourcePart -> String
29 | toString (Whitespace str) = str
30 | toString (Name n) = n
31 | toString (HoleName n) = "?" ++ n
32 | toString LBrace = "{"
33 | toString RBrace = "}"
34 | toString Equal = "="
35 | toString AsPattern = "@"
36 | toString (Other str) = str
43 | holeIdent = is '?' <+> identNormal
45 | srcTokens : TokenMap SourcePart
47 | [(identNormal, Name),
48 | (holeIdent, \x => HoleName (assert_total (prim__strTail x))),
49 | (space, Whitespace),
50 | (is '{', const LBrace),
51 | (is '}', const RBrace),
52 | (is '=', const Equal),
53 | (is '@', const AsPattern),
57 | tokens : String -> List SourcePart
59 | = case lex srcTokens str of
62 | (srctoks, (l, c, rest)) =>
63 | map val srctoks ++ (if rest == "" then [] else [Other rest])