diff options
| author | aarne <unknown> | 2005-02-04 19:17:57 +0000 |
|---|---|---|
| committer | aarne <unknown> | 2005-02-04 19:17:57 +0000 |
| commit | bc05653e825e082b70eebf2f420eb5a97610f56c (patch) | |
| tree | 66ddf9b72422f08f09f1b5a86a1bcd838d92baee /src/GF/Source/LexGF.x | |
| parent | b8b5139a8a8f8b0451061bacefc033b0bc768886 (diff) | |
resources and new instantiation syntax
Diffstat (limited to 'src/GF/Source/LexGF.x')
| -rw-r--r-- | src/GF/Source/LexGF.x | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/GF/Source/LexGF.x b/src/GF/Source/LexGF.x index 0486b0f0e..6d231debb 100644 --- a/src/GF/Source/LexGF.x +++ b/src/GF/Source/LexGF.x @@ -68,20 +68,18 @@ prToken t = case t of _ -> show t +data BTree = N | B String Tok BTree BTree deriving (Show) + eitherResIdent :: (String -> Tok) -> String -> Tok -eitherResIdent tv s = if isResWord s then (TS s) else (tv s) where - isResWord s = isInTree s $ - B "lincat" (B "def" (B "Type" (B "Str" (B "PType" (B "Lin" N N) N) (B "Tok" (B "Strs" N N) N)) (B "cat" (B "case" (B "abstract" N N) N) (B "data" (B "concrete" N N) N))) (B "include" (B "fun" (B "fn" (B "flags" N N) N) (B "in" (B "grammar" N N) N)) (B "interface" (B "instance" (B "incomplete" N N) N) (B "lin" (B "let" N N) N)))) (B "resource" (B "out" (B "of" (B "lintype" (B "lindef" N N) N) (B "oper" (B "open" N N) N)) (B "pattern" (B "param" (B "package" N N) N) (B "printname" (B "pre" N N) N))) (B "union" (B "table" (B "strs" (B "reuse" N N) N) (B "transfer" (B "tokenizer" N N) N)) (B "where" (B "variants" (B "var" N N) N) (B "with" N N)))) - -data BTree = N | B String BTree BTree deriving (Show) - -isInTree :: String -> BTree -> Bool -isInTree x tree = case tree of - N -> False - B a left right - | x < a -> isInTree x left - | x > a -> isInTree x right - | x == a -> True +eitherResIdent tv s = treeFind resWords + where + treeFind N = tv s + treeFind (B a t left right) | s < a = treeFind left + | s > a = treeFind right + | s == a = t + +resWords = b "lincat" (b "def" (b "Type" (b "Str" (b "PType" (b "Lin" N N) N) (b "Tok" (b "Strs" N N) N)) (b "cat" (b "case" (b "abstract" N N) N) (b "data" (b "concrete" N N) N))) (b "include" (b "fun" (b "fn" (b "flags" N N) N) (b "in" (b "grammar" N N) N)) (b "interface" (b "instance" (b "incomplete" N N) N) (b "lin" (b "let" N N) N)))) (b "resource" (b "out" (b "of" (b "lintype" (b "lindef" N N) N) (b "oper" (b "open" N N) N)) (b "pattern" (b "param" (b "package" N N) N) (b "printname" (b "pre" N N) N))) (b "union" (b "table" (b "strs" (b "reuse" N N) N) (b "transfer" (b "tokenizer" N N) N)) (b "where" (b "variants" (b "var" N N) N) (b "with" N N)))) + where b s = B s (TS s) unescapeInitTail :: String -> String unescapeInitTail = unesc . tail where |
