/* Production 38 chapter 3.4 corba 2.3.1 */ public void primary_expr() { /*@bgen(jjtree) primary_expr */ ASTprimary_expr jjtn000 = new ASTprimary_expr(this, IDLParserTreeConstants.JJTPRIMARY_EXPR); bool jjtc000 = true; jjtree.openNodeScope(jjtn000); try { switch ((jj_ntk==-1)?jj_ntk_calc():jj_ntk) { case 21: case IDLParserConstants.ID: scoped_name(); break; case 33: case 46: case 47: case 85: case IDLParserConstants.OCTALINT: case IDLParserConstants.DECIMALINT: case IDLParserConstants.HEXADECIMALINT: case IDLParserConstants.FLOATONE: case IDLParserConstants.FLOATTWO: case IDLParserConstants.CHARACTER: case IDLParserConstants.WIDECHARACTER: case IDLParserConstants.STRING: case IDLParserConstants.WIDESTRING: case IDLParserConstants.FIXED: literal(); break; case 29: jj_consume_token(29); const_exp(); jj_consume_token(30); break; default: jj_la1[45] = jj_gen; jj_consume_token(-1); throw new ParseException(); break; } } catch (Exception jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } {if (true) throw ;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } }
/** * @see parser.IDLParserVisitor#visit(ASTprimary_expr, Object) */ public Object visit(ASTprimary_expr node, Object data) { // possible cases (one child): // scoped_name // literal // const_exp Object result = node.jjtGetChild(0).jjtAccept(this, data); if (result is SymbolValue) { // a scoped name, which points to a symbol containing a value return ((SymbolValue)result).GetValueAsLiteral(); } else if (result is Symbol) { // A Symbol, but no value symbol, TODO: check if this is correct behaviour throw new InvalidIdlException("no valid primary expression: " + result); } else { // a literal: a Literal Value return result; } }