Changeset 10091 for src/Pugs/Lexer.hs

Show
Ignore:
Timestamp:
04/26/06 19:30:03 (3 years ago)
Author:
audreyt
Message:

* Pugs.Lexer: Accept all Ps/Pe and BidiMirroring? pairs, as

defined in the freshly-tweaked-by-yours-truly S02, as
valid quoting pairs.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Lexer.hs

    r10086 r10091  
    6262maybeParens p = choice [ parens p, p ] 
    6363 
    64 parens     :: RuleParser a -> RuleParser a 
    65 parens     = P.parens     perl6Lexer 
     64parens p        = between (symbol "(") (symbol ")") p 
     65braces p        = between (symbol "{") (symbol "}") p 
     66angles p        = between (symbol "<") (symbol ">") p 
     67brackets p      = between (symbol "[") (symbol "]") p 
     68 
     69mandatoryWhiteSpace :: RuleParser () 
     70mandatoryWhiteSpace = skipMany1 (satisfy isSpace) 
     71 
    6672whiteSpace :: RuleParser () 
    6773whiteSpace = P.whiteSpace perl6Lexer 
    68 mandatoryWhiteSpace :: RuleParser () 
    69 mandatoryWhiteSpace = skipMany1 (oneOf " \t\n")  -- XXX unicode and whatnot 
    7074lexeme     :: RuleParser a -> RuleParser a 
    7175lexeme     = P.lexeme     perl6Lexer 
    7276identifier :: RuleParser String 
    7377identifier = P.identifier perl6Lexer 
    74 braces     :: RuleParser a -> RuleParser a 
    75 braces     = P.braces     perl6Lexer 
    76 brackets   :: RuleParser a -> RuleParser a 
    77 brackets   = P.brackets   perl6Lexer 
    78 angles     :: RuleParser a -> RuleParser a 
    79 angles     = P.angles     perl6Lexer 
    80 balanced   :: RuleParser String 
    81 balanced   = P.balanced 
    82 balancedDelim :: Char -> Char 
    83 balancedDelim = P.balancedDelim 
    8478decimal    :: RuleParser Integer 
    8579decimal    = P.decimal    perl6Lexer 
     80 
     81balancedDelim :: Char -> Char 
     82balancedDelim c = case c of 
     83    '\x0028' -> '\x0029'; '\x003C' -> '\x003E'; '\x005B' -> '\x005D'; 
     84    '\x007B' -> '\x007D'; '\x00AB' -> '\x00BB'; '\x0F3A' -> '\x0F3B'; 
     85    '\x0F3C' -> '\x0F3D'; '\x169B' -> '\x169C'; '\x2039' -> '\x203A'; 
     86    '\x2045' -> '\x2046'; '\x207D' -> '\x207E'; '\x208D' -> '\x208E'; 
     87    '\x2208' -> '\x220B'; '\x2209' -> '\x220C'; '\x220A' -> '\x220D'; 
     88    '\x2215' -> '\x29F5'; '\x223C' -> '\x223D'; '\x2243' -> '\x22CD'; 
     89    '\x2252' -> '\x2253'; '\x2254' -> '\x2255'; '\x2264' -> '\x2265'; 
     90    '\x2266' -> '\x2267'; '\x2268' -> '\x2269'; '\x226A' -> '\x226B'; 
     91    '\x226E' -> '\x226F'; '\x2270' -> '\x2271'; '\x2272' -> '\x2273'; 
     92    '\x2274' -> '\x2275'; '\x2276' -> '\x2277'; '\x2278' -> '\x2279'; 
     93    '\x227A' -> '\x227B'; '\x227C' -> '\x227D'; '\x227E' -> '\x227F'; 
     94    '\x2280' -> '\x2281'; '\x2282' -> '\x2283'; '\x2284' -> '\x2285'; 
     95    '\x2286' -> '\x2287'; '\x2288' -> '\x2289'; '\x228A' -> '\x228B'; 
     96    '\x228F' -> '\x2290'; '\x2291' -> '\x2292'; '\x2298' -> '\x29B8'; 
     97    '\x22A2' -> '\x22A3'; '\x22A6' -> '\x2ADE'; '\x22A8' -> '\x2AE4'; 
     98    '\x22A9' -> '\x2AE3'; '\x22AB' -> '\x2AE5'; '\x22B0' -> '\x22B1'; 
     99    '\x22B2' -> '\x22B3'; '\x22B4' -> '\x22B5'; '\x22B6' -> '\x22B7'; 
     100    '\x22C9' -> '\x22CA'; '\x22CB' -> '\x22CC'; '\x22D0' -> '\x22D1'; 
     101    '\x22D6' -> '\x22D7'; '\x22D8' -> '\x22D9'; '\x22DA' -> '\x22DB'; 
     102    '\x22DC' -> '\x22DD'; '\x22DE' -> '\x22DF'; '\x22E0' -> '\x22E1'; 
     103    '\x22E2' -> '\x22E3'; '\x22E4' -> '\x22E5'; '\x22E6' -> '\x22E7'; 
     104    '\x22E8' -> '\x22E9'; '\x22EA' -> '\x22EB'; '\x22EC' -> '\x22ED'; 
     105    '\x22F0' -> '\x22F1'; '\x22F2' -> '\x22FA'; '\x22F3' -> '\x22FB'; 
     106    '\x22F4' -> '\x22FC'; '\x22F6' -> '\x22FD'; '\x22F7' -> '\x22FE'; 
     107    '\x2308' -> '\x2309'; '\x230A' -> '\x230B'; '\x2329' -> '\x232A'; 
     108    '\x23B4' -> '\x23B5'; '\x2768' -> '\x2769'; '\x276A' -> '\x276B'; 
     109    '\x276C' -> '\x276D'; '\x276E' -> '\x276F'; '\x2770' -> '\x2771'; 
     110    '\x2772' -> '\x2773'; '\x2774' -> '\x2775'; '\x27C3' -> '\x27C4'; 
     111    '\x27C5' -> '\x27C6'; '\x27D5' -> '\x27D6'; '\x27DD' -> '\x27DE'; 
     112    '\x27E2' -> '\x27E3'; '\x27E4' -> '\x27E5'; '\x27E6' -> '\x27E7'; 
     113    '\x27E8' -> '\x27E9'; '\x27EA' -> '\x27EB'; '\x2983' -> '\x2984'; 
     114    '\x2985' -> '\x2986'; '\x2987' -> '\x2988'; '\x2989' -> '\x298A'; 
     115    '\x298B' -> '\x298C'; '\x298D' -> '\x298E'; '\x298F' -> '\x2990'; 
     116    '\x2991' -> '\x2992'; '\x2993' -> '\x2994'; '\x2995' -> '\x2996'; 
     117    '\x2997' -> '\x2998'; '\x29C0' -> '\x29C1'; '\x29C4' -> '\x29C5'; 
     118    '\x29CF' -> '\x29D0'; '\x29D1' -> '\x29D2'; '\x29D4' -> '\x29D5'; 
     119    '\x29D8' -> '\x29D9'; '\x29DA' -> '\x29DB'; '\x29F8' -> '\x29F9'; 
     120    '\x29FC' -> '\x29FD'; '\x2A2B' -> '\x2A2C'; '\x2A2D' -> '\x2A2E'; 
     121    '\x2A34' -> '\x2A35'; '\x2A3C' -> '\x2A3D'; '\x2A64' -> '\x2A65'; 
     122    '\x2A79' -> '\x2A7A'; '\x2A7D' -> '\x2A7E'; '\x2A7F' -> '\x2A80'; 
     123    '\x2A81' -> '\x2A82'; '\x2A83' -> '\x2A84'; '\x2A8B' -> '\x2A8C'; 
     124    '\x2A91' -> '\x2A92'; '\x2A93' -> '\x2A94'; '\x2A95' -> '\x2A96'; 
     125    '\x2A97' -> '\x2A98'; '\x2A99' -> '\x2A9A'; '\x2A9B' -> '\x2A9C'; 
     126    '\x2AA1' -> '\x2AA2'; '\x2AA6' -> '\x2AA7'; '\x2AA8' -> '\x2AA9'; 
     127    '\x2AAA' -> '\x2AAB'; '\x2AAC' -> '\x2AAD'; '\x2AAF' -> '\x2AB0'; 
     128    '\x2AB3' -> '\x2AB4'; '\x2ABB' -> '\x2ABC'; '\x2ABD' -> '\x2ABE'; 
     129    '\x2ABF' -> '\x2AC0'; '\x2AC1' -> '\x2AC2'; '\x2AC3' -> '\x2AC4'; 
     130    '\x2AC5' -> '\x2AC6'; '\x2ACD' -> '\x2ACE'; '\x2ACF' -> '\x2AD0'; 
     131    '\x2AD1' -> '\x2AD2'; '\x2AD3' -> '\x2AD4'; '\x2AD5' -> '\x2AD6'; 
     132    '\x2AEC' -> '\x2AED'; '\x2AF7' -> '\x2AF8'; '\x2AF9' -> '\x2AFA'; 
     133    '\x2E02' -> '\x2E03'; '\x2E04' -> '\x2E05'; '\x2E09' -> '\x2E0A'; 
     134    '\x2E0C' -> '\x2E0D'; '\x2E1C' -> '\x2E1D'; '\x3008' -> '\x3009'; 
     135    '\x300A' -> '\x300B'; '\x300C' -> '\x300D'; '\x300E' -> '\x300F'; 
     136    '\x3010' -> '\x3011'; '\x3014' -> '\x3015'; '\x3016' -> '\x3017'; 
     137    '\x3018' -> '\x3019'; '\x301A' -> '\x301B'; '\x301D' -> '\x301E'; 
     138    '\xFD3E' -> '\xFD3F'; '\xFE17' -> '\xFE18'; '\xFE35' -> '\xFE36'; 
     139    '\xFE37' -> '\xFE38'; '\xFE39' -> '\xFE3A'; '\xFE3B' -> '\xFE3C'; 
     140    '\xFE3D' -> '\xFE3E'; '\xFE3F' -> '\xFE40'; '\xFE41' -> '\xFE42'; 
     141    '\xFE43' -> '\xFE44'; '\xFE47' -> '\xFE48'; '\xFE59' -> '\xFE5A'; 
     142    '\xFE5B' -> '\xFE5C'; '\xFE5D' -> '\xFE5E'; '\xFF08' -> '\xFF09'; 
     143    '\xFF1C' -> '\xFF1E'; '\xFF3B' -> '\xFF3D'; '\xFF5B' -> '\xFF5D'; 
     144    '\xFF5F' -> '\xFF60'; '\xFF62' -> '\xFF63'; other    -> other 
     145 
     146-- balanced: parses an open/close delimited expression of any non-alphanumeric character 
     147balanced :: RuleParser String 
     148balanced = do 
     149    notFollowedBy alphaNum 
     150    opendelim <- anyChar  
     151    contents <- many $ satisfy (/= balancedDelim opendelim) 
     152    char $ balancedDelim opendelim 
     153    return contents 
    86154 
    87155{-|