public int write(STWriter out, STErrorListener listener) { Interpreter interp = new Interpreter(groupThatCreatedThisInstance, new ErrorManager(listener), false); return interp.exec(out, this); }
/** Load a group file with full path {@code fileName}; it's relative to root by {@code prefix}. */ public void loadGroupFile(String prefix, String fileName) { if ( verbose ) System.out.println(this.getClass().getSimpleName()+ ".loadGroupFile(group-file-prefix="+prefix+", fileName="+fileName+")"); GroupParser parser; try { URL f = new URL(fileName); ANTLRInputStream fs = new ANTLRInputStream(f.openStream(), encoding); GroupLexer lexer = new GroupLexer(fs); fs.name = fileName; CommonTokenStream tokens = new CommonTokenStream(lexer); parser = new GroupParser(tokens); parser.group(this, prefix); } catch (Exception e) { errMgr.IOError(null, ErrorType.CANT_LOAD_GROUP_FILE, e, fileName); } }
public void addArgument(List<FormalArgument> args, Token t, Token defaultValueToken) { String name = t.getText(); for (FormalArgument arg : args) { if (arg.name.equals(name)) { group.errMgr.compileTimeError(ErrorType.PARAMETER_REDEFINITION, null, t, name); return; } } args.add(new FormalArgument(name, defaultValueToken)); }
/** Consume if {@code x} is next character on the input stream. */ public void match(char x) { if ( c != x ) { NoViableAltException e = new NoViableAltException("",0,0,input); errMgr.lexerError(input.getSourceName(), "expecting '"+x+"', found '"+str(c)+"'", templateToken, e); } consume(); }
public void error(String msg) { NoViableAltException e = new NoViableAltException("", 0, 0, input); group.errMgr.groupSyntaxError(ErrorType.SYNTAX_ERROR, getSourceName(), e, msg); recover(input, null); }
errMgr.internalError(null, "bad URL: "+root+parent+".stg", e); return null; errMgr.internalError(null, "can't load template file "+name, ioe); errMgr.internalError(null, "can't close template file stream "+name, ioe);
protected void setFirstArgument(ST self, ST st, Object attr) { if ( st.impl.formalArguments==null ) { errMgr.runTimeError(this, self, current_ip, ErrorType.ARGUMENT_COUNT_MISMATCH, 1, st.impl.name, 0); return; } st.locals[0] = attr; }
MismatchedTokenException e = new MismatchedTokenException('}', input); String msg = "missing final '}' in {...} anonymous template"; group.errMgr.groupLexerError(ErrorType.SYNTAX_ERROR, getSourceName(), e, msg); break;
/** Consume if {@code x} is next character on the input stream. */ public void match(char x) { if ( c != x ) { NoViableAltException e = new NoViableAltException("",0,0,input); errMgr.lexerError(input.getSourceName(), "expecting '"+x+"', found '"+str(c)+"'", templateToken, e); } consume(); }
public void error(String msg) { NoViableAltException e = new NoViableAltException("", 0, 0, input); group.errMgr.groupSyntaxError(ErrorType.SYNTAX_ERROR, getSourceName(), e, msg); recover(input, null); }
protected void highlight(JTextComponent comp, int i, int j) { Highlighter highlighter = comp.getHighlighter(); highlighter.removeAllHighlights(); try { highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter); } catch (BadLocationException ble) { errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble); } }
@Override public URL getRootDirURL() { //System.out.println("url of "+fileName+" is "+url.toString()); String parent = Misc.stripLastPathElement(url.toString()); try { return new URL(parent); } catch (MalformedURLException mue) { errMgr.runTimeError(null, null, ErrorType.INVALID_TEMPLATE_NAME, mue, parent); } return null; } }
MismatchedTokenException e = new MismatchedTokenException('}', input); String msg = "missing final '}' in {...} anonymous template"; group.errMgr.groupLexerError(ErrorType.SYNTAX_ERROR, getSourceName(), e, msg); break;
public int write(STWriter out, Locale locale, STErrorListener listener) { Interpreter interp = new Interpreter(groupThatCreatedThisInstance, locale, new ErrorManager(listener), false); return interp.exec(out, this); }
public void addArgument(List<FormalArgument> args, Token t) { String name = t.getText(); for (FormalArgument arg : args) { if (arg.name.equals(name)) { errMgr.compileTimeError(ErrorType.PARAMETER_REDEFINITION, templateToken, t, name); return; } } args.add(new FormalArgument(name)); }
/** Ensure x is next character on the input stream */ public void match(char x) { if ( c != x ) { NoViableAltException e = new NoViableAltException("",0,0,input); errMgr.lexerError(input.getSourceName(), "expecting '"+x+"', found '"+str(c)+"'", templateToken, e); } consume(); }
public void error(String msg) { NoViableAltException e = new NoViableAltException("", 0, 0, input); group.errMgr.groupSyntaxError(ErrorType.SYNTAX_ERROR, getSourceName(), e, msg); recover(input, null); }
errMgr.internalError(null, "bad URL: "+root+parent+GROUP_FILE_EXTENSION, e); return null; errMgr.internalError(null, "can't close template file stream "+name, ioe);
@Override public URL getRootDirURL() { //System.out.println("url of "+fileName+" is "+url.toString()); String parent = Misc.stripLastPathElement(url.toString()); try { return new URL(parent); } catch (MalformedURLException mue) { errMgr.runTimeError(null, null, ErrorType.INVALID_TEMPLATE_NAME, mue, parent); } return null; } }
/** Load a group file with full path {@code fileName}; it's relative to root by {@code prefix}. */ public void loadGroupFile(String prefix, String fileName) { if ( verbose ) System.out.println(this.getClass().getSimpleName()+ ".loadGroupFile(group-file-prefix="+prefix+", fileName="+fileName+")"); GroupParser parser; try { URL f = new URL(fileName); ANTLRInputStream fs = new ANTLRInputStream(f.openStream(), encoding); GroupLexer lexer = new GroupLexer(fs); fs.name = fileName; CommonTokenStream tokens = new CommonTokenStream(lexer); parser = new GroupParser(tokens); parser.group(this, prefix); } catch (Exception e) { errMgr.IOError(null, ErrorType.CANT_LOAD_GROUP_FILE, e, fileName); } }