This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: (PR11207) Macroprocessor discussion
On 06/14/2012 01:49 PM, Serguei Makarov wrote:
> # Token-Based Approach
[...]
> - Correct Handling of Brackets - mostly done for us by the lexer. We
> still have to handle bracket balancing, EITHER counting bracket depth
> (and introducing a special mechanism to emit unmatched brackets) OR
> using some distinct bracketing syntax such as %begin ... %end,
On IRC, I was trying to suggest %( %) as this bracketing syntax, since
it already exists for conditionals. Then you don't have to worry about
balancing at all for ( ) { } tokens inside. You do still have to
balance preprocessor conditionals inside, but I think that's more
logically associated.
> # Text-Based Approach
[...]
> Proposed Syntax
> - %define(foo,param1,param2,...)
> - %macro foo(param1, param2, ...) { ... }
I don't like having such different syntax for nearly the same thing. Is
the main difference here meant to be multiline? Also, consider the
possibility of 0-parameter, e.g. %foo and %foo() -- the difference is
minimal, but the author can use this to hint what the macro is doing.
So, how about single-line is without brackets, and multi-line uses
brackets. Like:
%define foo1(...) contents until end of line
%define foo2(...) %( contents can
go as long as you
like %)
%define bar1 another one-liner, no parameters
%define bar2 %(
multiple lines with
no parameters
%)
I think this can work for both the token- and text-based approaches.
Josh