예제 #1
0
        private static ParseResult Match_PublicKeyValue(InputStream input)
        {
            var seq = Enumerable.Repeat <Func <InputStream, ParseResult> >(Match_HexDigit, 16)
                      .Concat(new Func <InputStream, ParseResult>[] { Match_Spacing });

            return(ParseBuilder.Sequence(seq.ToArray())(input));
        }
예제 #2
0
        private static ParseResult Match_LangTagPart(InputStream input)
        {
            var isAlpha  = ParseBuilder.Match(ch => "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".Contains(ch));
            var optAlpha = ParseBuilder.ZeroOrOne(isAlpha);

            return(ParseBuilder.Sequence(isAlpha, optAlpha, optAlpha, optAlpha, optAlpha, optAlpha, optAlpha, optAlpha,
                                         optAlpha, optAlpha, optAlpha, optAlpha, optAlpha, optAlpha, optAlpha, optAlpha)(input));
        }
예제 #3
0
 private static ParseResult Match_QuotedChar(InputStream input)
 {
     return(ParseBuilder.WithAction(
                ParseBuilder.Sequence(Match_Backslash, ParseBuilder.Any),
                result =>
     {
         string ch = new SequenceResult(result)[1].MatchedString;
         return new ParseResult(ch);
     })(input));
 }
예제 #4
0
 private static ParseResult Match_GenericTypeParameter(InputStream input)
 {
     return(ParseBuilder.FirstOf(
                ParseBuilder.WithAction(Match_UnqualifiedName, r =>
     {
         var result = new TypeNameInfo();
         InitializeTypeNameInfo((ParsedUnqualifiedName)r.ResultData, result);
         return new ParseResult(r.MatchedString, result);
     }),
                ParseBuilder.WithAction(
                    ParseBuilder.Sequence(Match_LeftBracket, Match_TypeName, Match_RightBracket),
                    r => new SequenceResult(r)[1]))(
                input));
 }
예제 #5
0
        private static ParseResult Match_CLRSyntax(InputStream input)
        {
            var         resultData = new GenericParameters();
            ParseResult result     = ParseBuilder.Sequence(Match_Backquote,
                                                           WithAction(OneOrMore(Match_Digit),
                                                                      r =>
            {
                resultData.IsOpenGeneric = true;
                int numParameters        = int.Parse(r.MatchedString, CultureInfo.InvariantCulture);
                for (int i = 0; i < numParameters; ++i)
                {
                    resultData.Parameters.Add(null);
                }
            }))(input);

            if (result.Matched)
            {
                return(new ParseResult(result.MatchedString, resultData));
            }
            return(result);
        }
예제 #6
0
 private static ParseResult Match_Id(InputStream input)
 {
     return(ParseBuilder.Sequence(Match_IdStart, ParseBuilder.ZeroOrMore(Match_IdContinuation))(input));
 }
예제 #7
0
 private static ParseResult Match_AssemblyNameStart(InputStream input)
 {
     return(ParseBuilder.Sequence(ParseBuilder.Not(Match_Dot), Match_AssemblyNameChar)(input));
 }
예제 #8
0
 private static ParseResult Match_PublicKeyToken(InputStream input)
 {
     return(ParseBuilder.Sequence(ParseBuilder.Match("PublicKeyToken"), Match_Spacing, Match_Equals, Match_PublicKeyValue)(input));
 }
예제 #9
0
 private static ParseResult Match_NestedName(InputStream input)
 {
     return(ParseBuilder.Sequence(Match_Plus, Match_Id)(input));
 }
예제 #10
0
 private static ParseResult Match_Equals(InputStream input)
 {
     return(ParseBuilder.Sequence(ParseBuilder.Match('='), Match_Spacing)(input));
 }
예제 #11
0
 private static ParseResult Match_Version(InputStream input)
 {
     return(ParseBuilder.Sequence(ParseBuilder.Match("Version"), Match_Spacing, Match_Equals, Match_VersionNumber, Match_Spacing)(input));
 }
예제 #12
0
 private static ParseResult Match_LanguageTag(InputStream input)
 {
     return(ParseBuilder.Sequence(Match_LangTagPart, ParseBuilder.ZeroOrOne(ParseBuilder.Sequence(ParseBuilder.Match('-'), Match_LangTagPart)), Match_Spacing)(input));
 }
예제 #13
0
 private static ParseResult Match_Culture(InputStream input)
 {
     return(ParseBuilder.Sequence(ParseBuilder.Match("Culture"), Match_Spacing, Match_Equals, Match_LanguageTag)(input));
 }
예제 #14
0
 private static ParseResult Match_SimpleName(InputStream input)
 {
     return(ParseBuilder.Sequence(Match_AssemblyNameStart, ParseBuilder.ZeroOrMore(Match_AssemblyNameContinuation), Match_Spacing)(input));
 }
예제 #15
0
 private static ParseResult Match_Int(InputStream input)
 {
     return(ParseBuilder.WithAction(ParseBuilder.Sequence(Match_Digit, ParseBuilder.ZeroOrMore(Match_Digit)),
                                    r => new ParseResult(r.MatchedString, int.Parse(r.MatchedString, CultureInfo.InvariantCulture)))(input));
 }
예제 #16
0
 private static ParseResult Match_VersionNumber(InputStream input)
 {
     return
         (ParseBuilder.Sequence(Match_Int, Match_Dot, Match_Int, Match_Dot, Match_Int, Match_Dot, Match_Int)(input));
 }
예제 #17
0
 private static ParseResult Match_RightBracket(InputStream input)
 {
     return(ParseBuilder.Sequence(ParseBuilder.Match(']'), Match_Spacing)(input));
 }
예제 #18
0
 private static ParseResult Match_PublicKey(InputStream input)
 {
     return
         (ParseBuilder.Sequence(ParseBuilder.Match("PublicKey"), Match_Spacing, Match_Equals, ParseBuilder.OneOrMore(Match_HexDigit), Match_Spacing)(
              input));
 }
예제 #19
0
 private static ParseResult Match_AssemblyName(InputStream input)
 {
     return(ParseBuilder.Sequence(Match_SimpleName, ParseBuilder.ZeroOrMore(ParseBuilder.Sequence(Match_Comma, Match_AssemblyNamePart)))(input));
 }
예제 #20
0
 private static ParseResult Match_RootName(InputStream input)
 {
     return(ParseBuilder.Sequence(Match_Id, ParseBuilder.ZeroOrMore(Match_NestedName))(input));
 }