org.antlr.runtime.tree.CommonTreeAdaptor Java Examples
The following examples show how to use
org.antlr.runtime.tree.CommonTreeAdaptor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if (currentEvent instanceof EvalExprEvent) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if (currentEvent instanceof EvalTemplateEvent) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size() - 1); } if (templateEvent != null) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #2
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #3
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #4
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #5
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #6
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #7
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #8
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #9
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #10
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #11
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #12
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #13
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #14
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #15
Source File: SparqlParserUtilities.java From quetzal with Eclipse Public License 2.0 | 5 votes |
private static Query getQueryExt(CharStream sparqlFile) throws RecognitionException { // System.out.println("Parsing: "+sparqlFile+"\n"); IbmSparqlExtLexer lex = new IbmSparqlExtLexer(sparqlFile); CommonTokenStream tokens = new CommonTokenStream(lex); IbmSparqlExtParser parser = new IbmSparqlExtParser(tokens); parser.setTreeAdaptor(new CommonTreeAdaptor() { @Override public Object create(Token t) { return new XTree(t); } }); IbmSparqlExtParser.queryUnit_return ret = parser.queryUnit(); CommonTree ast = (CommonTree) ret.getTree(); // System.out.println(ast.toStringTree()); // SparqlParserUtilities.dump_tree(ast, tokens, 0); BufferedTreeNodeStream nodes = new BufferedTreeNodeStream(ast); nodes.setTokenStream(tokens); IbmSparqlExtAstWalker walker = new IbmSparqlExtAstWalker(nodes); QueryExt query = walker.queryUnit(); return query; }
Example #16
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #17
Source File: SparqlParserUtilities.java From quetzal with Eclipse Public License 2.0 | 5 votes |
static XTree getParseTree(CharStream sparqlFile) throws RecognitionException { IbmSparqlLexer lex = new IbmSparqlLexer(sparqlFile); CommonTokenStream tokens = new CommonTokenStream(lex); IbmSparqlParser parser = new IbmSparqlParser(tokens); parser.setTreeAdaptor(new CommonTreeAdaptor() { @Override public Object create(Token t) { return new XTree(t); } }); IbmSparqlParser.queryUnit_return ret = parser.queryUnit(); XTree ast = (XTree) ret.getTree(); return ast; }
Example #18
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #19
Source File: TestExt.java From quetzal with Eclipse Public License 2.0 | 5 votes |
public static void runParser(String sparqlFile) throws IOException { //System.out.println("Parsing: "+sparqlFile+"\n"); IbmSparqlLexer lex = new IbmSparqlLexer(new ANTLRFileStream(sparqlFile, "UTF8")); CommonTokenStream tokens = new CommonTokenStream(lex); IbmSparqlParser parser = new IbmSparqlParser(tokens); parser.setTreeAdaptor(new CommonTreeAdaptor(){ @Override public Object create(Token t) { return new XTree(t); } }); try { IbmSparqlParser.queryUnit_return ret = parser.queryUnit(); XTree ast = (XTree) ret.getTree(); // System.out.println(ast.toStringTree()); //SparqlParserUtilities.dump_tree(ast, tokens, 0); BufferedTreeNodeStream nodes = new BufferedTreeNodeStream(ast); nodes.setTokenStream(tokens); IbmSparqlAstWalker walker = new IbmSparqlAstWalker(nodes); Query query = walker.queryUnit(); // System.out.println(query.toString()); } catch (Exception e) { e.printStackTrace(); } }
Example #20
Source File: STViz.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
Example #21
Source File: TestExt.java From quetzal with Eclipse Public License 2.0 | 5 votes |
public static void runParserExt(String sparqlFile) throws IOException { //System.out.println("Parsing: "+sparqlFile+"\n"); IbmSparqlExtLexer lex = new IbmSparqlExtLexer(new ANTLRFileStream(sparqlFile, "UTF8")); CommonTokenStream tokens = new CommonTokenStream(lex); IbmSparqlExtParser parser = new IbmSparqlExtParser(tokens); parser.setTreeAdaptor(new CommonTreeAdaptor(){ @Override public Object create(Token t) { return new XTree(t); } }); try { IbmSparqlExtParser.queryUnit_return ret = parser.queryUnit(); CommonTree ast = (CommonTree) ret.getTree(); // System.out.println(ast.toStringTree()); //SparqlParserUtilities.dump_tree(ast, tokens, 0); BufferedTreeNodeStream nodes = new BufferedTreeNodeStream(ast); nodes.setTokenStream(tokens); IbmSparqlExtAstWalker walker = new IbmSparqlExtAstWalker(nodes); QueryExt query = walker.queryUnit(); //query. // System.out.println(query.toString()); } catch (Exception e) { e.printStackTrace(); } }
Example #22
Source File: JTreeASTModel.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
public JTreeASTModel(Object root) { this.adaptor = new CommonTreeAdaptor(); this.root = root; }
Example #23
Source File: JTreeASTModel.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
public JTreeASTModel(Object root) { this.adaptor = new CommonTreeAdaptor(); this.root = root; }
Example #24
Source File: JTreeASTModel.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
public JTreeASTModel(Object root) { this.adaptor = new CommonTreeAdaptor(); this.root = root; }
Example #25
Source File: ASTReferenceGraph.java From legstar-core2 with GNU Affero General Public License v3.0 | 4 votes |
/** * Produce a graph of all possible attributes. */ public void testGraphProd() { DOTTreeGenerator gen = new DOTTreeGenerator(); CommonTree ast = new CommonTree(); TreeAdaptor adaptor = new CommonTreeAdaptor(); /* * Data description entries. */ Object dataItem = adaptor.create(CobolStructureParser.DATA_ITEM, "DATA_ITEM"); addAttribute(adaptor, dataItem, CobolStructureParser.LEVEL, "LEVEL", "level"); addAttribute(adaptor, dataItem, CobolStructureParser.NAME, "NAME", "name | FILLER"); addAttribute(adaptor, dataItem, CobolStructureParser.REDEFINES, "REDEFINES", "dataItemName"); /* Usage keyword */ addAttribute(adaptor, dataItem, CobolStructureParser.USAGE, "USAGE", "BINARY | SINGLEFLOAT | DOUBLEFLOAT | PACKEDDECIMAL | NATIVEBINARY | DISPLAY | DISPLAY1" + " | INDEX | NATIONAL | POINTER | PROCEDUREPOINTER | FUNCTIONPOINTER"); /* Picture keyword */ addAttribute(adaptor, dataItem, CobolStructureParser.PICTURE, "PICTURE", "pictureSymbols"); /* Value keyword */ addAttribute(adaptor, dataItem, CobolStructureParser.VALUE, "VALUE" , "INT | SIGNED_INT | FLOAT_LITERAL | DECIMAL_LITERAL" + " | ALPHANUM_LITERAL_STRING | HEX_LITERAL_STRING | ZERO_LITERAL_STRING" + " | DBCS_LITERAL_STRING | NATIONAL_LITERAL_STRING | NATIONAL_HEX_LITERAL_STRING" + " | ZERO_CONSTANT | SPACE_CONSTANT | HIGH_VALUE_CONSTANT | LOW_VALUE_CONSTANT" + " | QUOTE_CONSTANT | ALL_CONSTANT | NULL_CONSTANT"); /* Date format clause */ addAttribute(adaptor, dataItem, CobolStructureParser.DATEFORMAT, "DATEFORMAT", "datePattern"); /* Array types */ Object fixedArrayNode = addAttribute(adaptor, dataItem, CobolStructureParser.FIXEDARRAY, "FIXEDARRAY", null); addAttribute(adaptor, fixedArrayNode, CobolStructureParser.HBOUND, "HBOUND", "highBound"); addAttribute(adaptor, fixedArrayNode, CobolStructureParser.KEY, "KEY", "dataItemName"); addAttribute(adaptor, fixedArrayNode, CobolStructureParser.INDEX, "INDEX", "name"); Object variableArrayNode = addAttribute(adaptor, dataItem, CobolStructureParser.VARARRAY, "VARARRAY", null); addAttribute(adaptor, variableArrayNode, CobolStructureParser.LBOUND, "LBOUND", "lowBound"); Object highBoundNode = addAttribute( adaptor, variableArrayNode, CobolStructureParser.HBOUND, "HBOUND", "highBound"); addAttribute(adaptor, highBoundNode, CobolStructureParser.DEPENDINGON, "DEPENDINGON", "dataItemName"); addAttribute(adaptor, variableArrayNode, CobolStructureParser.KEY, "KEY", "name"); addAttribute(adaptor, variableArrayNode, CobolStructureParser.INDEX, "INDEX", "name"); /* Sign clause elementary types */ Object signNode = addAttribute(adaptor, dataItem, CobolStructureParser.SIGN, "SIGN", null); Object leadingNode = addAttribute(adaptor, signNode, CobolStructureParser.LEADING, "LEADING", null); addAttribute(adaptor, leadingNode, CobolStructureParser.SEPARATE, "SEPARATE", null); Object trailingNode = addAttribute(adaptor, signNode, CobolStructureParser.TRAILING, "TRAILING", null); addAttribute(adaptor, trailingNode, CobolStructureParser.SEPARATE, "SEPARATE", null); /* Other attributes */ addAttribute(adaptor, dataItem, CobolStructureParser.BLANKWHENZERO, "BLANKWHENZERO", null); addAttribute(adaptor, dataItem, CobolStructureParser.EXTERNAL, "EXTERNAL", null); addAttribute(adaptor, dataItem, CobolStructureParser.GLOBAL, "GLOBAL", null); addAttribute(adaptor, dataItem, CobolStructureParser.GROUPUSAGENATIONAL, "GROUPUSAGENATIONAL", null); addAttribute(adaptor, dataItem, CobolStructureParser.JUSTIFIEDRIGHT, "JUSTIFIEDRIGHT", null); addAttribute(adaptor, dataItem, CobolStructureParser.SYNCHRONIZED, "SYNCHRONIZED", "LEFT | RIGHT"); adaptor.addChild(ast, dataItem); /* * Rename entries. */ Object renameItem = adaptor.create(CobolStructureParser.RENAME, "RENAME"); addAttribute(adaptor, renameItem, CobolStructureParser.LEVEL, "LEVEL", "66"); addAttribute(adaptor, renameItem, CobolStructureParser.NAME, "NAME", "name"); addAttribute(adaptor, renameItem, CobolStructureParser.RANGE, "RANGE", "fromDataItemName | toDataItemName"); addAttribute(adaptor, renameItem, CobolStructureParser.LITERAL, "LITERAL", "dataItemName"); adaptor.addChild(ast, renameItem); /* * Condition entries. */ Object conditionItem = adaptor.create(CobolStructureParser.CONDITION, "CONDITION"); addAttribute(adaptor, conditionItem, CobolStructureParser.LEVEL, "LEVEL", "88"); addAttribute(adaptor, conditionItem, CobolStructureParser.NAME, "NAME", "name"); addAttribute(adaptor, conditionItem, CobolStructureParser.RANGE, "RANGE", "fromValue | toValue"); addAttribute(adaptor, conditionItem, CobolStructureParser.LITERAL, "LITERAL", "value"); adaptor.addChild(ast, conditionItem); StringTemplate st = gen.toDOT(ast); _log.info(st.toString()); }
Example #26
Source File: JTreeASTModel.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
public JTreeASTModel(Object root) { this.adaptor = new CommonTreeAdaptor(); this.root = root; }
Example #27
Source File: JTreeASTModel.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
public JTreeASTModel(Object root) { this.adaptor = new CommonTreeAdaptor(); this.root = root; }
Example #28
Source File: JTreeASTModel.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
public JTreeASTModel(Object root) { this.adaptor = new CommonTreeAdaptor(); this.root = root; }
Example #29
Source File: JTreeASTModel.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
public JTreeASTModel(Object root) { this.adaptor = new CommonTreeAdaptor(); this.root = root; }
Example #30
Source File: JTreeASTModel.java From codebuff with BSD 2-Clause "Simplified" License | 4 votes |
public JTreeASTModel(Object root) { this.adaptor = new CommonTreeAdaptor(); this.root = root; }