public void declare() { Token type1=(Token)match(input,TYPE); Token id1=(Token)match(input, ID); Token semi=(Token)match(input,SEMI_ID); }
match '{' while the next token is the start token of declare() declare1=declare(); end match '}'
classBody: fieldDef | methodDef ; fieldDef: 'int' ID ';' ; methodDef: 'int' ID '{' '}' ;
void classBody() { if next tokens match: 'int' ID ';' then fieldDef(); if next tokens match: 'int' ID '{' then methodDef(); otherwise, throw NoViableAltException }