Exemplo n.º 1
0
        public WhiteSpace(LanguageDef def)
            :
            base(
                inp =>
        {
            var simpleSpace = Tok.SimpleSpace();

            if (String.IsNullOrEmpty(def.CommentLine) && String.IsNullOrEmpty(def.CommentStart))
            {
                return(Prim.SkipMany(
                           simpleSpace.Fail("")
                           ).Parse(inp));
            }
            else if (String.IsNullOrEmpty(def.CommentLine))
            {
                return(Prim.SkipMany <Unit>(
                           simpleSpace | Tok.MultiLineComment(def).Fail("")
                           ).Parse(inp));
            }
            else if (String.IsNullOrEmpty(def.CommentStart))
            {
                return(Prim.SkipMany <Unit>(
                           simpleSpace | Tok.OneLineComment(def).Fail("")
                           )
                       .Parse(inp));
            }
            else
            {
                return(Prim.SkipMany <Unit>(
                           simpleSpace | Tok.OneLineComment(def) | Tok.MultiLineComment(def).Fail("")
                           )
                       .Parse(inp));
            }
        }
                )
        { }