TableGen Operator Names

I just submitted a change to TableGen to make the lisp-like operator
names more readable (as suggested by Gabor a very long time ago).

I would also like to change the way operators are invoked. As I keep
adding more functionality, the bang invocation syntax is making things
hard to read. For example:

!if(!empty(arg),then,else)

Does this mean "if empty," "if not empty" or "not if not empty?" It's
the first but that's less than obvious.

Would anyone object if I changed the syntax from !operator to &operator?
This is at least consistent with Perl, which is not my favorite language
but is familiar to a lot of people. Some viable options are:

!operator (Keep as-is and deal with logical operator confusion)
&operator (Perl-like, no address-of concept in TableGen so less confusion)
@operator (Not a common operator)
#operator (Looks too much like a comment or preprocessor directive)
$operator (Looks too much like a variable)
%operator (Or +,-,/,^,*: could be confused with arithmetic, but not likely)
~operator (Could be confused with logical not)
()operator (Redundant with parameter parens)
\operator ("Escape" into metacode?)

There are plenty of other spellings, I've just tried to present my
thoughts on a few.

At the same time I would try to add syntax-highlighting support for
operators so they stand out better when reading .td files.

Is this a good idea? If so, does anyone have a strong syntax
preference?

                               -Dave

I just submitted a change to TableGen to make the lisp-like operator
names more readable (as suggested by Gabor a very long time ago).

Thanks for doing this!

I would also like to change the way operators are invoked. As I keep
adding more functionality, the bang invocation syntax is making things
hard to read. For example:

!if(!empty(arg),then,else)

Does this mean "if empty," "if not empty" or "not if not empty?" It's
the first but that's less than obvious.

Would anyone object if I changed the syntax from !operator to &operator?

In the absence of a much better proposal, I'd prefer to just keep it the way it is.

-Chris

Chris Lattner <clattner@apple.com> writes:

Would anyone object if I changed the syntax from !operator to &operator?

In the absence of a much better proposal, I'd prefer to just keep it the way it is.

Fair enough. What would make a better proposal? I'd like to keep the
syntax concise. I wonder if there is a way we could get rid of the
"operator" entirely and just specify names, like:

strconcat("this", "that")

instead of

!strconcat("this", "that")

What do you think?

                             -Dave

That would be nice. I haven't looked in years, but I thought that there was a parser ambiguity issue.

-Chris

Chris Lattner <clattner@apple.com> writes:

Fair enough. What would make a better proposal? I'd like to keep the
syntax concise. I wonder if there is a way we could get rid of the
"operator" entirely and just specify names, like:

strconcat("this", "that")

instead of

!strconcat("this", "that")

What do you think?

That would be nice. I haven't looked in years, but I thought that there was a parser ambiguity issue.

I think it would require removing knowledge of operators in the lexer,
just have it return an ID token for the operator name and then have the
parser implement a rule:

Operator : ID '(' ArgList ')'

But I haven't played around with it yet.

                               -Dave