All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cqframework.cql.tools.parsetree.Main Maven / Gradle / Ivy

Go to download

The cql-parsetree library for the Clinical Quality Language Java reference implementation

There is a newer version: 3.18.0
Show newest version
package org.cqframework.cql.tools.parsetree;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.antlr.v4.gui.Trees;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.ParserRuleContext;
import org.cqframework.cql.gen.cqlLexer;
import org.cqframework.cql.gen.cqlParser;

/**
 * A simple wrapper around the ANTLR4 testrig.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        String inputFile = null;
        if (args.length > 0) {
            inputFile = args[0];
        }
        InputStream is = System.in;
        if (inputFile != null) {
            is = new FileInputStream(inputFile);
        }
        CharStream input = CharStreams.fromStream(is);
        cqlLexer lexer = new cqlLexer(input);
        CommonTokenStream tokens = new CommonTokenStream(lexer);
        tokens.fill();
        cqlParser parser = new cqlParser(tokens);
        parser.setBuildParseTree(true);
        ParserRuleContext tree = parser.library();
        Trees.inspect(tree, parser);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy