On Thu, Aug 12, 2010 at 7:10 AM, Victor Giordano
<power_gio...@yahoo.com.ar>wrote:

> ...
>
> The question is: How i can do this, without definig the class inside the
> @menbers section. That class, in fact, is one of my program.. so i only
> want to reuse that. ...
>

Hi Victor,

Define a class LinearExpr like this:

package foo;

public class LinearExpr {

    // ... the rest of your class...
}


and in your grammar, import that class like this:

grammar LinearExpression;

@header {
    import foo.LinearExpression;
}

// ... the rest of your grammar ...


@header will automatically put everything you define in there at the start
of your parser class. It does the same as:

@parser::header {
    import foo.LinearExpression;
}


// ... the rest of your grammar ...


If you want your lexer and parser to be in the same package, say foo.parse for
example, do something like this:

grammar LinearExpression;

@parser::header {
    package foo.parse;
    import foo.LinearExpression;
}

@lexer::header {
    package foo.parse;
    import foo.LinearExpression;
}

// ... the rest of your grammar ...


Regards,

Bart.

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to