http://codereview.appspot.com/6303052/diff/6012/src/compiler/preprocessor/new/DirectiveParser.cpp File src/compiler/preprocessor/new/DirectiveParser.cpp (right): http://codereview.appspot.com/6303052/diff/6012/src/compiler/preprocessor/new/DirectiveParser.cpp#newcode168 src/compiler/preprocessor/new/DirectiveParser.cpp:168: macro.parameters.push_back(token->value); On 2012/06/13 21:38:02, kbr1 wrote: > I looked ...
11 years, 11 months ago
(2012-06-14 18:29:15 UTC)
#3
http://codereview.appspot.com/6303052/diff/6012/src/compiler/preprocessor/new...
File src/compiler/preprocessor/new/DirectiveParser.cpp (right):
http://codereview.appspot.com/6303052/diff/6012/src/compiler/preprocessor/new...
src/compiler/preprocessor/new/DirectiveParser.cpp:168:
macro.parameters.push_back(token->value);
On 2012/06/13 21:38:02, kbr1 wrote:
> I looked through this loop again and don't understand how it's handling some
of
> the cases in your tests such as MACRO(red fish, blue fish). But it's excellent
> that it does.
Here we are parsing the #define directive, not the macro invocation. So we are
only collecting the macro parameters (which are identifiers), not the actual
arguments.
http://codereview.appspot.com/6303052/diff/6012/src/compiler/preprocessor/new...
File src/compiler/preprocessor/new/MacroExpander.cpp (right):
http://codereview.appspot.com/6303052/diff/6012/src/compiler/preprocessor/new...
src/compiler/preprocessor/new/MacroExpander.cpp:128: context->unget();
On 2012/06/13 21:38:02, kbr1 wrote:
> Does this code need to be robust to the case where the incoming token differs
> from the last one fetched from the MacroContext? ("No" is a fine answer.)
The following asserts make sure that the incoming token is the same.
http://codereview.appspot.com/6303052/diff/6012/src/compiler/preprocessor/new...
src/compiler/preprocessor/new/MacroExpander.cpp:288: // Pre-expand each argument
before substitution.
On 2012/06/13 21:38:02, kbr1 wrote:
> This seems subtle. Could you provide more information about what this step
does?
> Also, does this code handle any necessary recursion (looks like it does, since
> it uses another MacroExpander instance, but just checking)?
Yes it does handle recursion. Added comments.
http://codereview.appspot.com/6303052/diff/6012/src/compiler/preprocessor/new...
src/compiler/preprocessor/new/MacroExpander.cpp:339: // macro replacement token.
On 2012/06/13 21:38:02, kbr1 wrote:
> Just the first one? Not all of them? Noticed similar code earlier in the
review.
Here we are inserting the argument into the macro body. All intermediate tokens
already have fixed padding properties. Only the first one should inherit that
from the macro body.
http://codereview.appspot.com/6303052/diff/6012/tests/preprocessor_tests/defi...
File tests/preprocessor_tests/define_test.cpp (right):
http://codereview.appspot.com/6303052/diff/6012/tests/preprocessor_tests/defi...
tests/preprocessor_tests/define_test.cpp:335: "two(,)\n";
On 2012/06/13 21:38:02, kbr1 wrote:
> Is that really legal?
Yes! When a macro is called without an argument, it can mean one (empty token or
space token) or zero argument.
http://codereview.appspot.com/6303052/diff/6012/tests/preprocessor_tests/defi...
tests/preprocessor_tests/define_test.cpp:421: "\n";
On 2012/06/13 21:38:02, kbr1 wrote:
> Is this really how this behaves?
This test is testing whether macro invocation spanning multiple lines can be
correctly parsed. I changed bar to (a) to make it clearer.
http://codereview.appspot.com/6303052/diff/6012/tests/preprocessor_tests/defi...
tests/preprocessor_tests/define_test.cpp:625: "b*2\n";
On 2012/06/13 21:38:02, kbr1 wrote:
> Wow, that works?
Yup. It does.
Issue 6303052: Implemented macro expansion.
(Closed)
Created 11 years, 11 months ago by Alok Priyadarshi
Modified 11 years, 11 months ago
Reviewers: kbr1
Base URL: http://angleproject.googlecode.com/svn/trunk/
Comments: 24