/** * Adds a Macro to this Preprocessor. * * The given {@link Macro} object encapsulates both the name * and the expansion. */ public void addMacro(Macro m) throws LexerException { // System.out.println("Macro " + m); String name = m.getName(); /* Already handled as a source error in macro(). */ if ("defined".equals(name)) throw new LexerException("Cannot redefine name 'defined'"); macros.put(m.getName(), m); }
/** * Adds a Macro to this Preprocessor. * * The given {@link Macro} object encapsulates both the name * and the expansion. */ public void addMacro(Macro m) throws LexerException { // System.out.println("Macro " + m); String name = m.getName(); /* Already handled as a source error in macro(). */ if ("defined".equals(name)) throw new LexerException("Cannot redefine name 'defined'"); macros.put(m.getName(), m); }
@Override public String toString() { StringBuilder buf = new StringBuilder(); buf.append("expansion of ").append(macro.getName()); Source parent = getParent(); if (parent != null) buf.append(" in ").append(String.valueOf(parent)); return buf.toString(); } }
public String toString() { StringBuilder buf = new StringBuilder(); buf.append("expansion of ").append(macro.getName()); Source parent = getParent(); if (parent != null) buf.append(" in ").append(String.valueOf(parent)); return buf.toString(); } }
/** * Adds a Macro to this Preprocessor. * * The given {@link Macro} object encapsulates both the name * and the expansion. * * @throws LexerException if the definition fails or is otherwise illegal. */ public void addMacro(@Nonnull Macro m) throws LexerException { // System.out.println("Macro " + m); String name = m.getName(); /* Already handled as a source error in macro(). */ if ("defined".equals(name)) throw new LexerException("Cannot redefine name 'defined'"); macros.put(m.getName(), m); }
public String toString() { StringBuilder buf = new StringBuilder(); buf.append("expansion of ").append(macro.getName()); Source parent = getParent(); if (parent != null) buf.append(" in ").append(String.valueOf(parent)); return buf.toString(); } }
public Preprocessor() { this.inputs = new ArrayList<Source>(); this.macros = createMacro(); macros.put(__LINE__.getName(), __LINE__); macros.put(__FILE__.getName(), __FILE__); macros.put(__COUNTER__.getName(), __COUNTER__); this.states = new Stack<State>(); states.push(new State()); this.source = null; this.counter = 0; this.quoteincludepath = new ArrayList<String>(); this.sysincludepath = new ArrayList<String>(); this.frameworkspath = new ArrayList<String>(); this.features = EnumSet.noneOf(Feature.class); this.warnings = EnumSet.noneOf(Warning.class); this.filesystem = new JavaFileSystem(); this.listener = null; }
public Preprocessor() { this.inputs = new ArrayList<Source>(); this.macros = createMacro(); macros.put(__LINE__.getName(), __LINE__); macros.put(__FILE__.getName(), __FILE__); macros.put(__COUNTER__.getName(), __COUNTER__); this.states = new Stack<State>(); states.push(new State()); this.source = null; this.counter = 0; this.quoteincludepath = new ArrayList<String>(); this.sysincludepath = new ArrayList<String>(); this.frameworkspath = new ArrayList<String>(); this.features = EnumSet.noneOf(Feature.class); this.warnings = EnumSet.noneOf(Warning.class); this.filesystem = new JavaFileSystem(); this.listener = null; }
public Preprocessor() { this.inputs = new ArrayList<Source>(); this.macros = new HashMap<String, Macro>(); macros.put(__LINE__.getName(), __LINE__); macros.put(__FILE__.getName(), __FILE__); macros.put(__COUNTER__.getName(), __COUNTER__); this.states = new Stack<State>(); states.push(new State()); this.source = null; this.counter = 0; this.quoteincludepath = new ArrayList<String>(); this.sysincludepath = new ArrayList<String>(); this.frameworkspath = new ArrayList<String>(); this.features = EnumSet.noneOf(Feature.class); this.warnings = EnumSet.noneOf(Warning.class); this.filesystem = new JavaFileSystem(); this.listener = null; }
private Token undef() throws IOException, LexerException { Token tok = source_token_nonwhite(); if (tok.getType() != IDENTIFIER) { error(tok, "Expected identifier, not " + tok.getText()); if (tok.getType() == NL || tok.getType() == EOF) return tok; } else { Macro m = macros.get(tok.getText()); if (m != null) { /* XXX error if predefined */ macros.remove(m.getName()); } } return source_skipline(true); }
private Token undef() throws IOException, LexerException { Token tok = source_token_nonwhite(); if (tok.getType() != IDENTIFIER) { error(tok, "Expected identifier, not " + tok.getText()); if (tok.getType() == NL || tok.getType() == EOF) return tok; } else { Macro m = macros.get(tok.getText()); if (m != null) { /* XXX error if predefined */ macros.remove(m.getName()); } } return source_skipline(true); }
@Nonnull private Token undef() throws IOException, LexerException { Token tok = source_token_nonwhite(); if (tok.getType() != IDENTIFIER) { error(tok, "Expected identifier, not " + tok.getText()); if (tok.getType() == NL || tok.getType() == EOF) return tok; } else { Macro m = getMacro(tok.getText()); if (m != null) { /* XXX error if predefined */ macros.remove(m.getName()); } } return source_skipline(true); }
"macro " + m.getName() + " has " + m.getArgs() + " parameters " + "but given " + args.size() + " args");
"macro " + m.getName() + " has " + m.getArgs() + " parameters " + "but given " + args.size() + " args");