}
public final Grammar class_def(
String file, Hierarchy hier
) throws RecognitionException, TokenStreamException {
Grammar gr;
Token preamble = null;
Token sub = null;
Token sup = null;
Token tk = null;
Token memberA = null;
gr=null;
IndexedVector rules = new IndexedVector(100);
IndexedVector classOptions = null;
try { // for error handling
{
switch ( LA(1)) {
case ACTION:
{
preamble = LT(1);
match(ACTION);
break;
}
case LITERAL_class:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
match(LITERAL_class);
sub = LT(1);
match(ID);
match(LITERAL_extends);
sup = LT(1);
match(ID);
match(SEMI);
gr = (Grammar)hier.getGrammar(sub.getText());
if ( gr!=null ) {
// antlr.Tool.toolError("redefinition of grammar "+gr.getName()+" ignored");
gr=null;
throw new SemanticException("redefinition of grammar "+sub.getText(), file, sub.getLine(), sub.getColumn());
}
else {
gr = new Grammar(hier.getTool(), sub.getText(), sup.getText(), rules);
if ( preamble!=null ) {
gr.setPreambleAction(preamble.getText());
}
}
{
switch ( LA(1)) {
case OPTIONS_START:
{
classOptions=optionSpec(gr);
break;
}
case ACTION:
case ID:
case TOKENS_SPEC:
case LITERAL_protected:
case LITERAL_private:
case LITERAL_public:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
if ( gr!=null ) {
gr.setOptions(classOptions);
}
{
switch ( LA(1)) {
case TOKENS_SPEC:
{
tk = LT(1);
match(TOKENS_SPEC);
gr.setTokenSection(tk.getText());
break;
}
case ACTION:
case ID:
case LITERAL_protected:
case LITERAL_private:
case LITERAL_public:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
{
switch ( LA(1)) {
case ACTION:
{
memberA = LT(1);
match(ACTION);
gr.setMemberAction(memberA.getText());
break;
}
case ID:
case LITERAL_protected:
case LITERAL_private: