[antlr-interest] Operator overloading?

vgusev at graphlogic.com vgusev at graphlogic.com
Thu Feb 22 18:03:46 PST 2007


> Vladimir,
>
> On Thursday 22 February 2007 14:02, Vladimir Gusev wrote:
>> Hello,
>>
>> Is there a way to implement in my language operator overloading using
>> ANTLR? I would appreciate any thoughts about this.
>
> Operator overloading is really not a syntactic aspect of any given
> programming language (that I know of). It's more a matter of symbol
> table organization and semantic actions to verify that a fragment of
> code that is (purely) syntactically valid is actually grammatical or
> legal in the larger sense of the rules for valid programs of that
> language.
>
> For example, in Java the methods in a (putative) method overload set
> must each be distinct from all others (in that overload set) without
> regard to their return types (i.e., their argument signatures must all
> be distinct). It would probably not make sense (or even be possible) to
> try to encode this rule syntactically.
>
> Instead, the parser would just make sure the parentheses, argument
> type / argument name pairs, commas, etc. were lexically and
> syntactically valid. Then, once a syntactically correct class
> definition was parsed, a later pass of the compiler (or verifier or
> translator, etc.) would verify the aforementioned rule, along with all
> the other non-syntactic rules governing valid Java programs.
>
>
>> Thanks.
>>
>> Vladimir
>
>
> Randall Schulz
>
Dear Randall,

Thank you for your thoughtful response. I was done with the first phase
you outlined and started on the second, and was stricken by the thought
that I might be missing something obvious, which could save me a lot of
hand coding. It seems I am on the right path. Thanks!

Vladimir




More information about the antlr-interest mailing list