Rui Barreiroadded jsonbb6aaad6 years agoHistory
63 lines · 1.5 KB · Text
RawDownload
module Language.JSON.String.Tokens import Data.String.Extraimport Text.Token %default total public exportdata JSONStringTokenKind  = JSTQuote  | JSTChar  | JSTSimpleEscape  | JSTUnicodeEscape public exportJSONStringToken : TypeJSONStringToken = Token JSONStringTokenKind public exportEq JSONStringTokenKind where  (==) JSTQuote JSTQuote = True  (==) JSTChar JSTChar = True  (==) JSTSimpleEscape JSTSimpleEscape = True  (==) JSTUnicodeEscape JSTUnicodeEscape = True  (==) _ _ = False privatecharValue : String -> CharcharValue x = case index 0 x of                   Nothing => '\NUL'                   Just c  => c privatesimpleEscapeValue : String -> CharsimpleEscapeValue x  = case index 1 x of         Nothing => '\NUL'         Just c => case c of                        '"'  => '"'                        '\\' => '\\'                        '/'  => '/'                        'b'  => '\b'                        'f'  => '\f'                        'n'  => '\n'                        'r'  => '\r'                        't'  => '\t'                        _    => '\NUL' privateunicodeEscapeValue : String -> CharunicodeEscapeValue x = chr $ cast ("0x" ++ drop 2 x) public exportTokenKind JSONStringTokenKind where  TokType JSTQuote = ()  TokType JSTChar = Char  TokType JSTSimpleEscape = Char  TokType JSTUnicodeEscape = Char   tokValue JSTQuote = const ()  tokValue JSTChar = charValue  tokValue JSTSimpleEscape = simpleEscapeValue  tokValue JSTUnicodeEscape = unicodeEscapeValue

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t