Exemplo n.º 1
0
        private static List <ActionAttributesDisplayArray> GetActionAttributesDisplayArray(Genero4glParser parser)
        {
            List <ActionAttributesDisplayArray> result = new List <ActionAttributesDisplayArray>();

            // get the optional attributes
            if (parser.PeekToken(TokenKind.AttributesKeyword) || parser.PeekToken(TokenKind.AttributeKeyword))
            {
                parser.NextToken();
                if (parser.PeekToken(TokenKind.LeftParenthesis))
                {
                    parser.NextToken();
                    ActionAttributesDisplayArray attrib;
                    while (ActionAttributesDisplayArray.TryParseNode(parser, out attrib))
                    {
                        result.Add(attrib);
                        if (!parser.PeekToken(TokenKind.Comma))
                        {
                            break;
                        }
                        parser.NextToken();
                    }

                    if (parser.PeekToken(TokenKind.RightParenthesis))
                    {
                        parser.NextToken();
                    }
                    else
                    {
                        parser.ReportSyntaxError("Expecting right-paren in display attributes section.");
                    }
                }
                else
                {
                    parser.ReportSyntaxError("Expecting left-paren in display attributes section.");
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        public static bool TryParseNode(Genero4glParser parser, out ActionAttributesDisplayArray node)
        {
            node            = new ActionAttributesDisplayArray();
            node.StartIndex = parser.Token.Span.Start;
            bool result = true;

            switch (parser.PeekToken().Kind)
            {
            case TokenKind.TextKeyword:
            case TokenKind.CommentKeyword:
            case TokenKind.ImageKeyword:
            case TokenKind.AcceleratorKeyword:
            {
                parser.NextToken();
                if (parser.PeekToken(TokenKind.Equals))
                {
                    parser.NextToken();
                }
                else
                {
                    parser.ReportSyntaxError("Expected equals token in display attribute.");
                }

                // get the help number
                StringExpressionNode stringExpressionNode;
                if (!StringExpressionNode.TryGetExpressionNode(parser, out stringExpressionNode))
                {
                    parser.ReportSyntaxError("Invalid string expression found in action attribute.");
                }
            }
            break;

            case TokenKind.DefaultViewKeyword:
            case TokenKind.ContextMenuKeyword:
            {
                parser.NextToken();
                if (parser.PeekToken(TokenKind.Equals))
                {
                    var tokKind = parser.NextToken().Kind;
                    if (tokKind != TokenKind.YesKeyword ||
                        tokKind != TokenKind.NoKeyword ||
                        tokKind != TokenKind.AutoKeyword)
                    {
                        parser.ReportSyntaxError("Invalid token found in action attribute.");
                    }
                }
                else
                {
                    parser.ReportSyntaxError("Expected equals token in display attribute.");
                }
            }
            break;

            case TokenKind.RowboundKeyword:
                parser.NextToken();
                break;

            default:
                result = false;
                break;
            }

            return(result);
        }