// $ANTLR start "assignment" // DefRef.g:107:1: assignment : ^(eq= '=' member . ) ; public final void assignment() throws RecognitionException { CommonTree eq = null; Type member6 = null; try { // DefRef.g:108:5: ( ^(eq= '=' member . ) ) // DefRef.g:108:9: ^(eq= '=' member . ) { eq = (CommonTree) match(input, 27, FOLLOW_27_in_assignment473); if (state.failed) return; match(input, Token.DOWN, null); if (state.failed) return; pushFollow(FOLLOW_member_in_assignment475); member6 = member(); state._fsp--; if (state.failed) return; matchAny(input); if (state.failed) return; match(input, Token.UP, null); if (state.failed) return; if (state.backtracking == 1) { System.out.println("line " + eq.getLine() + ": assign to type " + member6.getName()); } } } catch (RecognitionException re) { reportError(re); recover(input, re); } finally { } return; }
// $ANTLR start "member" // DefRef.g:118:1: member returns [Type type] : ( ^( '.' m= member ID ) | ID ); public final Type member() throws RecognitionException { Type type = null; CommonTree ID7 = null; CommonTree ID8 = null; Type m = null; try { // DefRef.g:119:5: ( ^( '.' m= member ID ) | ID ) int alt6 = 2; int LA6_0 = input.LA(1); if ((LA6_0 == 30)) { alt6 = 1; } else if ((LA6_0 == ID)) { alt6 = 2; } else { if (state.backtracking > 0) { state.failed = true; return type; } NoViableAltException nvae = new NoViableAltException("", 6, 0, input); throw nvae; } switch (alt6) { case 1: // DefRef.g:119:7: ^( '.' m= member ID ) { match(input, 30, FOLLOW_30_in_member527); if (state.failed) return type; match(input, Token.DOWN, null); if (state.failed) return type; pushFollow(FOLLOW_member_in_member531); m = member(); state._fsp--; if (state.failed) return type; ID7 = (CommonTree) match(input, ID, FOLLOW_ID_in_member533); if (state.failed) return type; match(input, Token.UP, null); if (state.failed) return type; if (state.backtracking == 1) { StructSymbol scope = (StructSymbol) m; // get scope of expr Symbol s = scope.resolveMember((ID7 != null ? ID7.getText() : null)); // resolve ID in scope System.out.println( "line " + ID7.getLine() + ": ref " + m.getName() + "." + (ID7 != null ? ID7.getText() : null) + "=" + s); if (s != null) type = s.type; // return ID's type } } break; case 2: // DefRef.g:127:7: ID { ID8 = (CommonTree) match(input, ID, FOLLOW_ID_in_member550); if (state.failed) return type; if (state.backtracking == 1) { Symbol s = currentScope.resolve((ID8 != null ? ID8.getText() : null)); System.out.println( "line " + ID8.getLine() + ": ref " + (ID8 != null ? ID8.getText() : null) + "=" + s); if (s != null) type = s.type; } } break; } } catch (RecognitionException re) { reportError(re); recover(input, re); } finally { } return type; }