示例#1
0
        public override bool TryParse(TokenStack tokens, out GraphNode node)
        {
            if (tokens.ExpectAny(EnumMapping.Keys.ToArray()))
            {
                var token = tokens.Pop();
                node = new Value(new[] { token }, EnumMapping[token.TokenType], token.Value);
                return(true);
            }

            node = null;
            return(false);
        }
示例#2
0
        public override bool TryParse(TokenStack tokens, out GraphNode node)
        {
            if (tokens.ExpectAny(TokenType.SignedIntegerTypeKeyword, TokenType.UnsignedIntegerTypeKeyword, TokenType.BitfieldTypeKeyword, TokenType.BitTypeKeyword, TokenType.Identifier))
            {
                var token = tokens.Pop();
                node = new TypeDeclaration(new [] { token }, token.Value);
                return(true);
            }

            // TODO: syntax error
            node = null;
            return(false);
        }
示例#3
0
        public override bool TryParse(TokenStack tokens, out GraphNode node)
        {
            if (tokens.Expect(TokenType.OpenKeyword))
            {
                var source = new List <Token>();
                source.Add(tokens.Pop());

                if (tokens.ExpectAny(TokenType.StringLiteral, TokenType.Identifier))
                {
                    var valueToken = tokens.Pop();
                    source.Add(valueToken);

                    var value = new Value(new [] { valueToken }, valueToken.TokenType == TokenType.Identifier ? ValueType.Identifier : ValueType.String, valueToken.Value);
                    node = new OpenStatement(source, value);
                    return(true);
                }
            }

            // TODO: syntax error
            node = null;
            return(false);
        }