8 public BuildIR(State state) {
11 public void buildtree() {
12 for(Iterator it=state.parsetrees.iterator();it.hasNext();) {
13 ParseNode pn=(ParseNode)it.next();
18 /** Parse the classes in this file */
19 public void parseFile(ParseNode pn) {
20 ParseNode tpn=pn.getChild("type_declaration_list");
22 ParseNodeVector pnv=tpn.getChildren();
23 for(int i=0;i<pnv.size();i++) {
24 ParseNode type_pn=pnv.elementAt(i);
25 if (isEmpty(type_pn)) /* Skip the semicolon */
27 if (isNode(type_pn,"class_declaration")) {
28 ClassDescriptor cn=parseTypeDecl(type_pn);
30 } else if (isNode(type_pn,"task_declaration")) {
31 TaskDescriptor td=parseTaskDecl(type_pn);
34 throw new Error(type_pn.getLabel());
40 public TaskDescriptor parseTaskDecl(ParseNode pn) {
41 TaskDescriptor td=new TaskDescriptor(pn.getChild("name").getTerminal());
42 ParseNode bodyn=pn.getChild("body");
43 BlockNode bn=parseBlock(bodyn);
44 parseParameterList(td, pn);
45 state.addTreeCode(td,bn);
46 if (pn.getChild("flag_effects_list")!=null)
47 td.addFlagEffects(parseFlags(pn.getChild("flag_effects_list")));
51 public Vector parseFlags(ParseNode pn) {
52 Vector vfe=new Vector();
53 ParseNodeVector pnv=pn.getChildren();
54 for(int i=0;i<pnv.size();i++) {
55 ParseNode fn=pnv.elementAt(i);
56 FlagEffects fe=parseFlagEffects(fn);
62 public FlagEffects parseFlagEffects(ParseNode pn) {
63 if (isNode(pn,"flag_effect")) {
64 String flagname=pn.getChild("name").getTerminal();
65 FlagEffects fe=new FlagEffects(flagname);
66 parseFlagEffect(fe, pn.getChild("flag_list"));
68 } else throw new Error();
71 public void parseFlagEffect(FlagEffects fes, ParseNode pn) {
72 ParseNodeVector pnv=pn.getChildren();
73 for(int i=0;i<pnv.size();i++) {
74 ParseNode pn2=pnv.elementAt(i);
76 if (isNode(pn2,"not")) {
78 pn2=pn2.getChild("name");
80 String name=pn2.getTerminal();
81 fes.addEffect(new FlagEffect(name,status));
85 public FlagExpressionNode parseFlagExpression(ParseNode pn) {
86 if (pn.getChild("or")!=null) {
87 ParseNodeVector pnv=pn.getChild("or").getChildren();
88 ParseNode left=pnv.elementAt(0);
89 ParseNode right=pnv.elementAt(1);
90 return new FlagOpNode(parseFlagExpression(left), parseFlagExpression(right), new Operation(Operation.LOGIC_OR));
91 } else if (pn.getChild("and")!=null) {
92 ParseNodeVector pnv=pn.getChild("and").getChildren();
93 ParseNode left=pnv.elementAt(0);
94 ParseNode right=pnv.elementAt(1);
95 return new FlagOpNode(parseFlagExpression(left), parseFlagExpression(right), new Operation(Operation.LOGIC_AND));
96 } else if (pn.getChild("not")!=null) {
97 ParseNodeVector pnv=pn.getChild("not").getChildren();
98 ParseNode left=pnv.elementAt(0);
99 return new FlagOpNode(parseFlagExpression(left), new Operation(Operation.LOGIC_NOT));
101 } else if (pn.getChild("name")!=null) {
102 return new FlagNode(pn.getChild("name").getTerminal());
103 } else throw new Error();
106 public Vector parseChecks(ParseNode pn) {
107 Vector ccs=new Vector();
108 ParseNodeVector pnv=pn.getChildren();
109 for(int i=0;i<pnv.size();i++) {
110 ParseNode fn=pnv.elementAt(i);
111 ConstraintCheck cc=parseConstraintCheck(fn);
117 public ConstraintCheck parseConstraintCheck(ParseNode pn) {
118 if (isNode(pn,"cons_check")) {
119 String varname=pn.getChild("name").getTerminal();
120 String specname=pn.getChild("spec").getTerminal();
121 ConstraintCheck cc=new ConstraintCheck(varname, specname);
123 } else throw new Error();
126 public void parseParameterList(TaskDescriptor td, ParseNode pn) {
127 ParseNode paramlist=pn.getChild("task_parameter_list");
130 ParseNodeVector pnv=paramlist.getChildren();
131 for(int i=0;i<pnv.size();i++) {
132 ParseNode paramn=pnv.elementAt(i);
133 TypeDescriptor type=parseTypeDescriptor(paramn);
135 ParseNode tmp=paramn;
136 while (tmp.getChild("single")==null) {
137 type=type.makeArray(state);
138 tmp=tmp.getChild("array");
140 String paramname=tmp.getChild("single").getTerminal();
141 FlagExpressionNode fen=parseFlagExpression(paramn.getChild("flag"));
143 td.addParameter(type,paramname,fen);
147 public ClassDescriptor parseTypeDecl(ParseNode pn) {
148 ClassDescriptor cn=new ClassDescriptor(pn.getChild("name").getTerminal());
149 if (!isEmpty(pn.getChild("super").getTerminal())) {
150 /* parse superclass name */
151 ParseNode snn=pn.getChild("super").getChild("type").getChild("class").getChild("name");
152 NameDescriptor nd=parseName(snn);
153 cn.setSuper(nd.toString());
155 if (!cn.getSymbol().equals(TypeUtil.ObjectClass))
156 cn.setSuper(TypeUtil.ObjectClass);
158 cn.setModifiers(parseModifiersList(pn.getChild("modifiers")));
159 parseClassBody(cn, pn.getChild("classbody"));
163 private void parseClassBody(ClassDescriptor cn, ParseNode pn) {
164 ParseNode decls=pn.getChild("class_body_declaration_list");
166 ParseNodeVector pnv=decls.getChildren();
167 for(int i=0;i<pnv.size();i++) {
168 ParseNode decl=pnv.elementAt(i);
169 if (isNode(decl,"member")) {
170 parseClassMember(cn,decl);
171 } else if (isNode(decl,"constructor")) {
172 parseConstructorDecl(cn,decl.getChild("constructor_declaration"));
173 } else if (isNode(decl,"block")) {
174 } else throw new Error();
179 private void parseClassMember(ClassDescriptor cn, ParseNode pn) {
180 ParseNode fieldnode=pn.getChild("field");
182 if (fieldnode!=null) {
183 parseFieldDecl(cn,fieldnode.getChild("field_declaration"));
186 ParseNode methodnode=pn.getChild("method");
187 if (methodnode!=null) {
188 parseMethodDecl(cn,methodnode.getChild("method_declaration"));
191 ParseNode flagnode=pn.getChild("flag");
192 if (flagnode!=null) {
193 parseFlagDecl(cn, flagnode.getChild("flag_declaration"));
199 private TypeDescriptor parseTypeDescriptor(ParseNode pn) {
200 ParseNode tn=pn.getChild("type");
202 String type_st=tn.getTerminal();
203 if(type_st.equals("byte")) {
204 return state.getTypeDescriptor(TypeDescriptor.BYTE);
205 } else if(type_st.equals("short")) {
206 return state.getTypeDescriptor(TypeDescriptor.SHORT);
207 } else if(type_st.equals("boolean")) {
208 return state.getTypeDescriptor(TypeDescriptor.BOOLEAN);
209 } else if(type_st.equals("int")) {
210 return state.getTypeDescriptor(TypeDescriptor.INT);
211 } else if(type_st.equals("long")) {
212 return state.getTypeDescriptor(TypeDescriptor.LONG);
213 } else if(type_st.equals("char")) {
214 return state.getTypeDescriptor(TypeDescriptor.CHAR);
215 } else if(type_st.equals("float")) {
216 return state.getTypeDescriptor(TypeDescriptor.FLOAT);
217 } else if(type_st.equals("double")) {
218 return state.getTypeDescriptor(TypeDescriptor.DOUBLE);
219 } else if(type_st.equals("class")) {
220 ParseNode nn=tn.getChild("class");
221 return state.getTypeDescriptor(parseName(nn.getChild("name")));
222 } else if(type_st.equals("array")) {
223 ParseNode nn=tn.getChild("array");
224 TypeDescriptor td=parseTypeDescriptor(nn.getChild("basetype"));
225 Integer numdims=(Integer)nn.getChild("dims").getLiteral();
226 for(int i=0;i<numdims.intValue();i++)
227 td=td.makeArray(state);
234 private NameDescriptor parseName(ParseNode nn) {
235 ParseNode base=nn.getChild("base");
236 ParseNode id=nn.getChild("identifier");
238 return new NameDescriptor(id.getTerminal());
239 return new NameDescriptor(parseName(base.getChild("name")),id.getTerminal());
243 private void parseFlagDecl(ClassDescriptor cn,ParseNode pn) {
244 String name=pn.getChild("name").getTerminal();
245 cn.addFlag(new FlagDescriptor(name));
248 private void parseFieldDecl(ClassDescriptor cn,ParseNode pn) {
249 ParseNode mn=pn.getChild("modifier");
250 Modifiers m=parseModifiersList(mn);
252 ParseNode tn=pn.getChild("type");
253 TypeDescriptor t=parseTypeDescriptor(tn);
254 ParseNode vn=pn.getChild("variables").getChild("variable_declarators_list");
255 ParseNodeVector pnv=vn.getChildren();
256 for(int i=0;i<pnv.size();i++) {
257 ParseNode vardecl=pnv.elementAt(i);
260 ParseNode tmp=vardecl;
261 TypeDescriptor arrayt=t;
262 while (tmp.getChild("single")==null) {
263 arrayt=arrayt.makeArray(state);
264 tmp=tmp.getChild("array");
266 String identifier=tmp.getChild("single").getTerminal();
268 ParseNode epn=vardecl.getChild("initializer");
270 ExpressionNode en=null;
272 en=parseExpression(epn.getFirstChild());
274 cn.addField(new FieldDescriptor(m,arrayt,identifier, en));
279 private ExpressionNode parseExpression(ParseNode pn) {
280 if (isNode(pn,"assignment"))
281 return parseAssignmentExpression(pn);
282 else if (isNode(pn,"logical_or")||isNode(pn,"logical_and")||
283 isNode(pn,"bitwise_or")||isNode(pn,"bitwise_xor")||
284 isNode(pn,"bitwise_and")||isNode(pn,"equal")||
285 isNode(pn,"not_equal")||isNode(pn,"comp_lt")||
286 isNode(pn,"comp_lte")||isNode(pn,"comp_gt")||
287 isNode(pn,"comp_gte")||isNode(pn,"leftshift")||
288 isNode(pn,"rightshift")||isNode(pn,"sub")||
289 isNode(pn,"add")||isNode(pn,"mult")||
290 isNode(pn,"div")||isNode(pn,"mod")) {
291 ParseNodeVector pnv=pn.getChildren();
292 ParseNode left=pnv.elementAt(0);
293 ParseNode right=pnv.elementAt(1);
294 Operation op=new Operation(pn.getLabel());
295 return new OpNode(parseExpression(left),parseExpression(right),op);
296 } else if (isNode(pn,"unaryplus")||
297 isNode(pn,"unaryminus")||
299 ParseNode left=pn.getFirstChild();
300 Operation op=new Operation(pn.getLabel());
301 return new OpNode(parseExpression(left),op);
302 } else if (isNode(pn,"postinc")||
303 isNode(pn,"postdec")) {
304 ParseNode left=pn.getFirstChild();
305 AssignOperation op=new AssignOperation(pn.getLabel());
306 return new AssignmentNode(parseExpression(left),null,op);
308 } else if (isNode(pn,"preinc")||
309 isNode(pn,"predec")) {
310 ParseNode left=pn.getFirstChild();
311 AssignOperation op=isNode(pn,"preinc")?new AssignOperation(AssignOperation.PLUSEQ):new AssignOperation(AssignOperation.MINUSEQ);
312 return new AssignmentNode(parseExpression(left),
313 new LiteralNode("integer",new Integer(1)),op);
314 } else if (isNode(pn,"literal")) {
315 String literaltype=pn.getTerminal();
316 ParseNode literalnode=pn.getChild(literaltype);
317 Object literal_obj=literalnode.getLiteral();
318 return new LiteralNode(literaltype, literal_obj);
319 } else if (isNode(pn,"createobject")) {
320 TypeDescriptor td=parseTypeDescriptor(pn);
321 Vector args=parseArgumentList(pn);
322 CreateObjectNode con=new CreateObjectNode(td);
323 for(int i=0;i<args.size();i++) {
324 con.addArgument((ExpressionNode)args.get(i));
326 /* Could have flag set here */
327 if (pn.getChild("flag_list")!=null) {
328 FlagEffects fe=new FlagEffects(null);
329 parseFlagEffect(fe, pn.getChild("flag_list"));
330 con.addFlagEffects(fe);
333 } else if (isNode(pn,"createarray")) {
334 System.out.println(pn.PPrint(3,true));
335 TypeDescriptor td=parseTypeDescriptor(pn);
336 Vector args=parseDimExprs(pn);
338 if (pn.getChild("dims_opt").getLiteral()!=null)
339 num=((Integer)pn.getChild("dims_opt").getLiteral()).intValue();
340 for(int i=0;i<(args.size()+num);i++)
341 td=td.makeArray(state);
342 CreateObjectNode con=new CreateObjectNode(td);
343 for(int i=0;i<args.size();i++) {
344 con.addArgument((ExpressionNode)args.get(i));
347 } else if (isNode(pn,"name")) {
348 NameDescriptor nd=parseName(pn);
349 return new NameNode(nd);
350 } else if (isNode(pn,"this")) {
351 NameDescriptor nd=new NameDescriptor("this");
352 return new NameNode(nd);
353 } else if (isNode(pn,"methodinvoke1")) {
354 NameDescriptor nd=parseName(pn.getChild("name"));
355 Vector args=parseArgumentList(pn);
356 MethodInvokeNode min=new MethodInvokeNode(nd);
357 for(int i=0;i<args.size();i++) {
358 min.addArgument((ExpressionNode)args.get(i));
361 } else if (isNode(pn,"methodinvoke2")) {
362 String methodid=pn.getChild("id").getTerminal();
363 ExpressionNode exp=parseExpression(pn.getChild("base").getFirstChild());
364 Vector args=parseArgumentList(pn);
365 MethodInvokeNode min=new MethodInvokeNode(methodid,exp);
366 for(int i=0;i<args.size();i++) {
367 min.addArgument((ExpressionNode)args.get(i));
370 } else if (isNode(pn,"fieldaccess")) {
371 ExpressionNode en=parseExpression(pn.getChild("base").getFirstChild()); String fieldname=pn.getChild("field").getTerminal();
372 return new FieldAccessNode(en,fieldname);
373 } else if (isNode(pn,"arrayaccess")) {
374 ExpressionNode en=parseExpression(pn.getChild("base").getFirstChild());
375 ExpressionNode index=parseExpression(pn.getChild("index").getFirstChild());
376 return new ArrayAccessNode(en,index);
377 } else if (isNode(pn,"cast1")) {
378 return new CastNode(parseTypeDescriptor(pn.getChild("type")),parseExpression(pn.getChild("exp").getFirstChild()));
379 } else if (isNode(pn,"cast2")) {
380 return new CastNode(parseExpression(pn.getChild("type").getFirstChild()),parseExpression(pn.getChild("exp").getFirstChild()));
382 System.out.println("---------------------");
383 System.out.println(pn.PPrint(3,true));
388 private Vector parseDimExprs(ParseNode pn) {
389 Vector arglist=new Vector();
390 ParseNode an=pn.getChild("dim_exprs");
391 if (an==null) /* No argument list */
393 ParseNodeVector anv=an.getChildren();
394 for(int i=0;i<anv.size();i++) {
395 arglist.add(parseExpression(anv.elementAt(i)));
400 private Vector parseArgumentList(ParseNode pn) {
401 Vector arglist=new Vector();
402 ParseNode an=pn.getChild("argument_list");
403 if (an==null) /* No argument list */
405 ParseNodeVector anv=an.getChildren();
406 for(int i=0;i<anv.size();i++) {
407 arglist.add(parseExpression(anv.elementAt(i)));
412 private ExpressionNode parseAssignmentExpression(ParseNode pn) {
413 AssignOperation ao=new AssignOperation(pn.getChild("op").getTerminal());
414 ParseNodeVector pnv=pn.getChild("args").getChildren();
416 AssignmentNode an=new AssignmentNode(parseExpression(pnv.elementAt(0)),parseExpression(pnv.elementAt(1)),ao);
421 private void parseMethodDecl(ClassDescriptor cn, ParseNode pn) {
422 ParseNode headern=pn.getChild("method_header");
423 ParseNode bodyn=pn.getChild("body");
424 MethodDescriptor md=parseMethodHeader(headern);
425 BlockNode bn=parseBlock(bodyn);
427 state.addTreeCode(md,bn);
430 private void parseConstructorDecl(ClassDescriptor cn, ParseNode pn) {
431 ParseNode mn=pn.getChild("modifiers");
432 Modifiers m=parseModifiersList(mn);
433 ParseNode cdecl=pn.getChild("constructor_declarator");
434 String name=cdecl.getChild("name").getChild("identifier").getTerminal();
435 MethodDescriptor md=new MethodDescriptor(m, name);
436 ParseNode paramnode=cdecl.getChild("parameters");
437 parseParameterList(md,paramnode);
438 ParseNode bodyn0=pn.getChild("body");
439 ParseNode bodyn=bodyn0.getChild("constructor_body");
441 BlockNode bn=parseBlock(bodyn);
442 state.addTreeCode(md,bn);
445 public BlockNode parseBlock(ParseNode pn) {
446 if (pn==null||isEmpty(pn.getTerminal()))
447 return new BlockNode();
448 ParseNode bsn=pn.getChild("block_statement_list");
449 return parseBlockHelper(bsn);
452 private BlockNode parseBlockHelper(ParseNode pn) {
453 ParseNodeVector pnv=pn.getChildren();
454 BlockNode bn=new BlockNode();
455 for(int i=0;i<pnv.size();i++) {
456 Vector bsv=parseBlockStatement(pnv.elementAt(i));
457 for(int j=0;j<bsv.size();j++) {
458 bn.addBlockStatement((BlockStatementNode)bsv.get(j));
464 public BlockNode parseSingleBlock(ParseNode pn) {
465 BlockNode bn=new BlockNode();
466 Vector bsv=parseBlockStatement(pn);
467 for(int j=0;j<bsv.size();j++) {
468 bn.addBlockStatement((BlockStatementNode)bsv.get(j));
470 bn.setStyle(BlockNode.NOBRACES);
474 public Vector parseBlockStatement(ParseNode pn) {
475 Vector blockstatements=new Vector();
476 if (isNode(pn,"local_variable_declaration")) {
477 TypeDescriptor t=parseTypeDescriptor(pn);
478 ParseNode vn=pn.getChild("variable_declarators_list");
479 ParseNodeVector pnv=vn.getChildren();
480 for(int i=0;i<pnv.size();i++) {
481 ParseNode vardecl=pnv.elementAt(i);
484 ParseNode tmp=vardecl;
485 TypeDescriptor arrayt=t;
486 while (tmp.getChild("single")==null) {
487 arrayt=arrayt.makeArray(state);
488 tmp=tmp.getChild("array");
490 String identifier=tmp.getChild("single").getTerminal();
492 ParseNode epn=vardecl.getChild("initializer");
495 ExpressionNode en=null;
497 en=parseExpression(epn.getFirstChild());
499 blockstatements.add(new DeclarationNode(new VarDescriptor(arrayt, identifier),en));
501 } else if (isNode(pn,"nop")) {
503 } else if (isNode(pn,"expression")) {
504 blockstatements.add(new BlockExpressionNode(parseExpression(pn.getFirstChild())));
505 } else if (isNode(pn,"ifstatement")) {
506 blockstatements.add(new IfStatementNode(parseExpression(pn.getChild("condition").getFirstChild()),
507 parseSingleBlock(pn.getChild("statement").getFirstChild()),
508 pn.getChild("else_statement")!=null?parseSingleBlock(pn.getChild("else_statement").getFirstChild()):null));
509 } else if (isNode(pn,"taskexit")) {
511 if (pn.getChild("flag_effects_list")!=null)
512 vfe=parseFlags(pn.getChild("flag_effects_list"));
514 if (pn.getChild("cons_checks")!=null)
515 ccs=parseChecks(pn.getChild("cons_checks"));
517 blockstatements.add(new TaskExitNode(vfe, ccs));
518 } else if (isNode(pn,"return")) {
519 if (isEmpty(pn.getTerminal()))
520 blockstatements.add(new ReturnNode());
522 ExpressionNode en=parseExpression(pn.getFirstChild());
523 blockstatements.add(new ReturnNode(en));
525 } else if (isNode(pn,"block_statement_list")) {
526 BlockNode bn=parseBlockHelper(pn);
527 blockstatements.add(new SubBlockNode(bn));
528 } else if (isNode(pn,"empty")) {
530 } else if (isNode(pn,"statement_expression_list")) {
531 ParseNodeVector pnv=pn.getChildren();
532 BlockNode bn=new BlockNode();
533 for(int i=0;i<pnv.size();i++) {
534 ExpressionNode en=parseExpression(pnv.elementAt(i));
535 blockstatements.add(new BlockExpressionNode(en));
537 bn.setStyle(BlockNode.EXPRLIST);
538 } else if (isNode(pn,"forstatement")) {
539 BlockNode init=parseSingleBlock(pn.getChild("initializer").getFirstChild());
540 BlockNode update=parseSingleBlock(pn.getChild("update").getFirstChild());
541 ExpressionNode condition=parseExpression(pn.getChild("condition").getFirstChild());
542 BlockNode body=parseSingleBlock(pn.getChild("statement").getFirstChild());
543 blockstatements.add(new LoopNode(init,condition,update,body));
544 } else if (isNode(pn,"whilestatement")) {
545 ExpressionNode condition=parseExpression(pn.getChild("condition").getFirstChild());
546 BlockNode body=parseSingleBlock(pn.getChild("statement").getFirstChild());
547 blockstatements.add(new LoopNode(condition,body,LoopNode.WHILELOOP));
548 } else if (isNode(pn,"dowhilestatement")) {
549 ExpressionNode condition=parseExpression(pn.getChild("condition").getFirstChild());
550 BlockNode body=parseSingleBlock(pn.getChild("statement").getFirstChild());
551 blockstatements.add(new LoopNode(condition,body,LoopNode.DOWHILELOOP));
553 System.out.println("---------------");
554 System.out.println(pn.PPrint(3,true));
557 return blockstatements;
560 public MethodDescriptor parseMethodHeader(ParseNode pn) {
561 ParseNode mn=pn.getChild("modifiers");
562 Modifiers m=parseModifiersList(mn);
564 ParseNode tn=pn.getChild("returntype");
565 TypeDescriptor returntype;
567 returntype=parseTypeDescriptor(tn);
569 returntype=new TypeDescriptor(TypeDescriptor.VOID);
571 ParseNode pmd=pn.getChild("method_declarator");
572 String name=pmd.getChild("name").getTerminal();
573 MethodDescriptor md=new MethodDescriptor(m, returntype, name);
575 ParseNode paramnode=pmd.getChild("parameters");
576 parseParameterList(md,paramnode);
580 public void parseParameterList(MethodDescriptor md, ParseNode pn) {
581 ParseNode paramlist=pn.getChild("formal_parameter_list");
584 ParseNodeVector pnv=paramlist.getChildren();
585 for(int i=0;i<pnv.size();i++) {
586 ParseNode paramn=pnv.elementAt(i);
587 TypeDescriptor type=parseTypeDescriptor(paramn);
589 ParseNode tmp=paramn;
590 while (tmp.getChild("single")==null) {
591 type=type.makeArray(state);
592 tmp=tmp.getChild("array");
594 String paramname=tmp.getChild("single").getTerminal();
596 md.addParameter(type,paramname);
600 public Modifiers parseModifiersList(ParseNode pn) {
601 Modifiers m=new Modifiers();
602 ParseNode modlist=pn.getChild("modifier_list");
604 ParseNodeVector pnv=modlist.getChildren();
605 for(int i=0;i<pnv.size();i++) {
606 ParseNode modn=pnv.elementAt(i);
607 if (isNode(modn,"public"))
608 m.addModifier(Modifiers.PUBLIC);
609 if (isNode(modn,"protected"))
610 m.addModifier(Modifiers.PROTECTED);
611 if (isNode(modn,"private"))
612 m.addModifier(Modifiers.PRIVATE);
613 if (isNode(modn,"static"))
614 m.addModifier(Modifiers.STATIC);
615 if (isNode(modn,"final"))
616 m.addModifier(Modifiers.FINAL);
617 if (isNode(modn,"native"))
618 m.addModifier(Modifiers.NATIVE);
624 private boolean isNode(ParseNode pn, String label) {
625 if (pn.getLabel().equals(label))
630 private static boolean isEmpty(ParseNode pn) {
631 if (pn.getLabel().equals("empty"))
637 private static boolean isEmpty(String s) {
638 if (s.equals("empty"))
644 /** Throw an exception if something is unexpected */
645 private void check(ParseNode pn, String label) {
647 throw new Error(pn+ "IE: Expected '" + label + "', got null");
649 if (! pn.getLabel().equals(label)) {
650 throw new Error(pn+ "IE: Expected '" + label + "', got '"+pn.getLabel()+"'");