public override ParseResult Parse()
        {
            var element = new ClassSubroutineDeclarationElement();

            element
            .Add(ParseKeyword(Keywords.Constructor, Keywords.Function, Keywords.Method))
            .Add(TypeParser.IsValid(Tokens.FirstOrDefault())
                    ? ParseElement(ElementCategory.Type)
                    : ParseKeyword(Keywords.Void))
            .Add(ParseIdentifier())
            .Add(ParseSymbol(Symbols.OpeningBrace))
            .Add(ParseOptional(
                     ParameterListParser.IsValid,
                     ElementCategory.ParameterList,
                     new ParameterListElement()))
            .Add(ParseSymbol(Symbols.ClosingBrace))
            .Add(ParseElement(ElementCategory.SubroutineBody));

            return(new ParseResult(ConsumedTokensCount, element));
        }
 public static bool IsValid(IToken token)
 {
     return(TypeParser.IsValid(token));
 }