[antlr-interest] How to do real division
Benjamin Niemann
pink at odahoda.de
Fri May 16 13:43:00 PDT 2008
Or you can of course just force at least one operator to be a float...
On Fri, May 16, 2008 at 10:38 PM, Benjamin Niemann <pink at odahoda.de> wrote:
> HI Curtis,
>
> good point, haven't thought about his yet.
> Should be fairly easy to fix, but it may not make it into the upcoming
> V3.1 release.
> If you are not afraid of building antlr yourself:
>
> In src/org/antlr/codegen/templates/Python/Python.stg there's a line
>
> <actions.(actionScope).header>
>
> move it up right before the <@imports> line. Then you should be able to say
>
> @header {
> from __future__ import division
> }
>
> and it should appear where you need it.
>
> As a long term solution I probably have to introduce a separate @
> action, because e.g. when having other things than imports in @header,
> you want these to be after the 'from antlr import *'.
>
> -Ben
>
>
>
> On Fri, May 16, 2008 at 4:19 PM, Curtis Deck <curtis at v-sim.com> wrote:
> >
> >
> >
> >
> > I am writing an expression evaluator using antlr 3 and python. I want to do
> > real division but I cannot use from __future__ import division because it
> > needs to be at the top of the script.
> >
> >
> >
> > Can any one help me please.
> >
> >
> >
> > Thanks in advance!
>
More information about the antlr-interest
mailing list