MCPcopy Create free account
hub / github.com/apache/pig / expandMacro

Method expandMacro

src/org/apache/pig/parser/QueryParserDriver.java:266–295  ·  view source on GitHub ↗
(Tree ast)

Source from the content-addressed store, hash-verified

264 }
265
266 Tree expandMacro(Tree ast) throws ParserException {
267 LOG.debug("Original macro AST:\n" + ast.toStringTree() + "\n");
268
269 // first insert the import files
270 while (expandImport(ast))
271 ;
272
273 LOG.debug("macro AST after import:\n" + ast.toStringTree() + "\n");
274
275 List<CommonTree> macroNodes = new ArrayList<CommonTree>();
276 List<CommonTree> inlineNodes = new ArrayList<CommonTree>();
277
278 // find all macro def/inline nodes
279 traverse(ast, macroNodes, inlineNodes);
280
281 Map<String, PigMacro> seen = new HashMap<String, PigMacro>();
282 List<PigMacro> macroDefs = new ArrayList<PigMacro>();
283
284 // gether all the def nodes
285 for (CommonTree t : macroNodes) {
286 macroDefs.add(makeMacroDef(t, seen));
287 }
288
289 // inline macros
290 inlineMacro(inlineNodes, macroDefs);
291
292 LOG.debug("Resulting macro AST:\n" + ast.toStringTree() + "\n");
293
294 return ast;
295 }
296
297 private void inlineMacro(List<CommonTree> inlineNodes,
298 List<PigMacro> macroDefs) throws ParserException {

Callers 2

parseMethod · 0.95
processPigMethod · 0.95

Calls 6

expandImportMethod · 0.95
traverseMethod · 0.95
makeMacroDefMethod · 0.95
inlineMacroMethod · 0.95
debugMethod · 0.80
addMethod · 0.65

Tested by

no test coverage detected