[antlr-interest] parameterized maps as arguments to rules??

Oti ohumbel at gmail.com
Tue Jun 26 11:29:11 PDT 2007


On 6/18/07, David A Weiser <DWEISER at uwyo.edu> wrote:
> Hey all,
>
> I have the beginning of a rule:
> formalParameterDecls returns  [HashMap<String,String> params].
>
> But I get a compilation error because of:
> public static class formalParameters_return extends
> ParserRuleReturnScope {
>         public HashMap<String;
>         public String> params;
>     };
>
> In the java file for the grammar parser.  Am I to assume that java 1.5
> features aren't supported, or am I just going about this wrong?
>

Hi,

just wanted to say that java 1.5 features can be supported. The
following generates and compiles fine:


@parser::members {

private List<String> _collectedErrorMessages = new ArrayList<String>();

public boolean hasCollectedErrorMessages() {
  return getCollectedErrorMessages().size() > 0;
}

public List<String> getCollectedErrorMessages() {
  return _collectedErrorMessages;
}

@Override
public void emitErrorMessage(String msg) {
  super.emitErrorMessage(msg);
  _collectedErrorMessages.add(msg);
}

}


best wishes,
Oti.


More information about the antlr-interest mailing list