> This attribute was added to the CSharp3 target in CL 6464 while fixing an
> issue with delegate grammars.
That explains the next error I get when removing/outcommenting the hasDelegates
stuff. Considering the explanation, I think the best course of action is to add
at least a dummy version of hasDelegates and getCharPositionInLine to the Java
target (and whatever is still unknown - just run ANTLR with CSharp2 as target).
At least I know now where I got the code from. :)
Johannes
>
> I tried adding a CSharp3Target.java file, but ran into the following
> problems:
>
> 1. The Java version of the tool doesn't implement rule visibility (despite
> having it as part of the grammars). It results in all rule methods in the
> grammar being private (the default in C#).
> 2. GrammarAST needed a getCharPositionInLine() method added to be
> compatible
> with the v3 grammars I'm using.
> 3. Grammar needed a getHasDelegates() method:
>
> public boolean getHasDelegates() {
> return !getDelegates().isEmpty();
> }
>
> 4. The Java version of the tool doesn't implement actions for attribute
> scopes. In the C# version, you can have scopes like the following:
>
> scope S @scopeinit{$S::value=true;} {boolean value;}
>
> ==== On a side note, the token constants can be stabilized by (it really
> cleans up the output):
>
> 1. Use TreeMap for AssignTokenTypesBehavior.stringLiterals, tokens, and
> aliases
> 1. Use a TreeMap for CompositeGrammar.tokenIDToTypeMap and
> stringLiteralToTypeMap
> 2. In CodeGenerator.genTokenTypeConstants, output the list in order by
> value. I believe you could use the code from genTokenTypeNames, but I did
> the following:
>
> protected void genTokenTypeConstants(StringTemplate code) {
> // make constants for the token types
> Set<Map.Entry<String, Integer>> tokens =
> grammar.composite.tokenIDToTypeMap.entrySet();
> ArrayList<Map.Entry<String, Integer>> sortedTokens = new
> ArrayList<Map.Entry<String, Integer>>(tokens);
> Collections.sort(sortedTokens, new EntryValueComparer<Integer>());
> for (Map.Entry<String, Integer> entry : sortedTokens){
> int tokenType = entry.getValue();
> // don't do FAUX labels 'cept EOF
> if (tokenType == Label.EOF || tokenType >= Label.MIN_TOKEN_TYPE)
> code.setAttribute("tokens.{name,type}", entry.getKey(),
> entry.getValue());
> }
> }
>
> private static class EntryValueComparer<TValue extends Comparable<TValue>>
> implements Comparator<Map.Entry<?, TValue>> {
> public int compare(Map.Entry<?, TValue> o1, Map.Entry<?, TValue> o2) {
> return o1.getValue().compareTo(o2.getValue());
> }
> }
>
> Sam
>
> -----Original Message-----
> From: Terence Parr [mailto:[email protected]]
> Sent: Sunday, November 21, 2010 5:39 PM
> To: Johannes Luber; Sam Harwell
> Cc: [email protected] Dev
> Subject: please remove hasDelegates
>
> Hi. checking all version of code via:
>
> ~/antlr/code/antlr $ find . -name '*.java' -exec grep -i hasDelegates {}
> \;
>
> I see no mention of a field/method at all so we can probably kill this in
> the templates.
>
> <if(grammar.hasDelegates)>
> public override ICharStream CharStream
> {
> get
> {
> return base.CharStream;
> }
> set
> {
> base.CharStream = value;
> <grammar.directDelegates:
> {g|<g:delegateName()> = new
> <g.recognizerName>(input, state<trunc(g.delegators):{p|,
> <p:delegateName()>}>, this);}; separator="\n">
> <grammar.delegators:
> {g|this.<g:delegateName()> = <g:delegateName()>;};
> separator="\n">
> <last(grammar.delegators):{g|gParent =
> <g:delegateName()>;}>
> }
> }
>
> <endif>
>
> Ter
>
> On Nov 21, 2010, at 12:16 PM, Terence Parr wrote:
>
> > Hi. yeah, templates have changed as have a few runtime files. changes
> file
> should have info. I had to change to get real profiling data out for a
> paper. sorry! we can skype and discuss if you want...
> >
> > hasDelegates sounds like a new one. but why would *old* templates ref
> new
> method?
> >
> > OH! i see C# refs them but java doesn't
> >
> > <if(grammar.hasDelegates)>
> >
> > Apparently I *removed* a method...
> >
> > Ter
> >
> > On Nov 21, 2010, at 12:09 PM, Johannes Luber wrote:
> >
> >> I have to eat my own words. *grr* My main PC and my notebook, which I
> have installed maven and JDK still don't work. And only my main PC does
> have
> the rest of the developing chain on it. I don't know why, I deleted .m2,
> updated the workspaces, did "mvn -N install" and "mvn
> -Dmaven.test.skip=true
> package assembly:assembly" to get the output I've attached.
> >>
> >> And I don't have access to the PC where it works till next weekend...
> So
> I thought: As I only need jars for some last tests, why not download the
> latest snapshot? But I've ended up with the following error:
> >>
> >> "[exec] error(10): internal error: Class org.antlr.tool.Grammar has
> no
> such attribute: hasDelegates in template context [outputFile lexer] :
> java.lang.NoSuchFieldException: hasDelegates"
> >>
> >> Did you change the templates in some incompatible way, Ter? Seems I
> >> have to catch up with the latest changes then. :/
> >>
> >> Johannes
> >>
> >>> Hooray! The paper I just submitted refers to 3.3; I'm hoping that
> >>> the peer review won't review anything until after I release 3.3 ;)
> >>> I definitely want to do before Thanksgiving break, so that means
> >>> Wednesday. would that be okay with you guys?
> >>> T
> >>>
> >>> On Nov 20, 2010, at 3:45 PM, Johannes Luber wrote:
> >>>
> >>>>
> >>>>> I don't think that there are bugs, otherwise Ter could not build
> >>>>> it either. Delete your maven repository and start again I think. I
> >>>>> will
> >>> double check
> >>>>> here.
> >>>>>
> >>>>> Jim
> >>>>
> >>>> One of the PCs which failed before works now. Have to check others,
> >>>> too,
> >>> but things look good so far. :)
> >>>>
> >>>> Johannes
> >>>>>
> >>>>>> -----Original Message-----
> >>>>>> From: Johannes Luber [mailto:[email protected]]
> >>>>>> Sent: Friday, November 19, 2010 7:21 AM
> >>>>>> To: Terence Parr; [email protected]
> >>>>>> Cc: [email protected]
> >>>>>> Subject: Re: [antlr-dev] antlr 3.3 release
> >>>>>>
> >>>>>>> Hi. anybody want changes in for 3.3, please get them in soon.
> >>>>>>> likely this weekend or early next week I will push 3.3
> >>>>>>>
> >>>>>>> Ter
> >>>>>>
> >>>>>> Hi,
> >>>>>>
> >>>>>> I would love to make a official 3.3 release for the C# target,
> >>>>>> but for weeks my build PCs fail to generate the jars (2 reals,
> >>>>>> one VM). I have asked Jim to fix the bug(s), but he hasn't had time
> yet to do so.
> >>> Until
> >>>>>> then I can't fix at least the bugs, which cause compile errors
> >>>>>> for generated files. :(
> >>>>>>
> >>>>>> Johannes
> >>>>>> --
> >>>>>> GRATIS! Movie-FLAT mit über 300 Videos.
> >>>>>> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome
> >>>>>
> >>>>> _______________________________________________
> >>>>> antlr-dev mailing list
> >>>>> [email protected]
> >>>>> http://www.antlr.org/mailman/listinfo/antlr-dev
> >>>>
> >>>> --
> >>>> GMX DSL Doppel-Flat ab 19,99 €/mtl.! Jetzt auch mit gratis
> >>>> Notebook-Flat! http://portal.gmx.net/de/go/dsl
> >>>
> >>
> >> --
> >> GMX DSL Doppel-Flat ab 19,99 €/mtl.! Jetzt auch mit gratis
> >> Notebook-Flat! http://portal.gmx.net/de/go/dsl <mvn.out>
> >
> > _______________________________________________
> > antlr-dev mailing list
> > [email protected]
> > http://www.antlr.org/mailman/listinfo/antlr-dev
>
>
--
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail
_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org/mailman/listinfo/antlr-dev