Package com.spoledge.audao.parser.gql

Source Code of com.spoledge.audao.parser.gql.GqlStatic

/*
* Copyright 2010 Spolecne s.r.o. (www.spoledge.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.spoledge.audao.parser.gql;

import org.antlr.runtime.*;

import com.spoledge.audao.parser.gql.impl.GqlStaticLexer;
import com.spoledge.audao.parser.gql.impl.GqlStaticParser;


public class GqlStatic {

    public GqlStatic() {
    }


    public String parse(String indent, String gql, String argnames, String argtypes)
            throws RecognitionException {

        System.out.println("PARSING: '" + gql + "' with params: (" + argnames + "), types: (" + argtypes + ")" );

        String[] args = null;
        String[] targs = null;

        if (argnames != null) {
            if (argnames.startsWith(", ")) argnames = argnames.substring( 2 );
            args = argnames.split(", *");
        }

        if (argtypes != null) {
            if (argtypes.startsWith(", ")) argtypes = argtypes.substring( 2 );
            targs = argtypes.split(", *");
        }

        GqlStaticLexer lexer = new GqlStaticLexer( new ANTLRStringStream( gql ));
        GqlStaticParser parser = new GqlStaticParser( new CommonTokenStream( lexer ));

        return parser.gqlcond( indent, "_query", args, targs );
    }
}
TOP

Related Classes of com.spoledge.audao.parser.gql.GqlStatic

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.