Where does nom's “$i” macro argument come from? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Casting pthread's start_routine argument with a macroOverloading Macro on Number of ArgumentsHow to implement a macro system into my LISPUnderstanding DEFER and OBSTRUCT macrosMacro call vs macro definition environment in JuliaStrange definitions of TRUE and FALSE macrosFixing “no rules expected the token” macro errorWhy does avr-gcc tell me about missing argument while expanding my [fancy] macro?How to use a type (ty) within a macro to construct a struct instance in Rust?PHP Internals: How does TSRMLS_FETCH Work?
What is the ongoing value of the Kanban board to the developers as opposed to management
Is Diceware more secure than a long passphrase?
"Rubric" as meaning "signature" or "personal mark" -- is this accepted usage?
What to do with someone that cheated their way through university and a PhD program?
Why does the Cisco show run command not show the full version, while the show version command does?
Check if a string is entirely made of the same substring
Passing args from the bash script to the function in the script
Flash for group photos near wall
Retract an already submitted recommendation letter (written for an undergrad student)
c++ diamond problem - How to call base method only once
How long after the last departure shall the airport stay open for an emergency return?
Where did Arya get these scars?
PIC mathematical operations weird problem
Is Electric Central Heating worth it if using Solar Panels?
Seek and ye shall find
Married in secret, can marital status in passport be changed at a later date?
Why did C use the -> operator instead of reusing the . operator?
Can you stand up from being prone using Skirmisher outside of your turn?
How to count in linear time worst-case?
"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?
What is it called when you ride around on your front wheel?
Trumpet valves, lengths, and pitch
What is the term for a person whose job is to place products on shelves in stores?
What is this word supposed to be?
Where does nom's “$i” macro argument come from?
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Casting pthread's start_routine argument with a macroOverloading Macro on Number of ArgumentsHow to implement a macro system into my LISPUnderstanding DEFER and OBSTRUCT macrosMacro call vs macro definition environment in JuliaStrange definitions of TRUE and FALSE macrosFixing “no rules expected the token” macro errorWhy does avr-gcc tell me about missing argument while expanding my [fancy] macro?How to use a type (ty) within a macro to construct a struct instance in Rust?PHP Internals: How does TSRMLS_FETCH Work?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm trying to understand how Rust macro captures work and am looking at the nom parser library.
Location nom/src/bytes.rs declares macro tag! which captures with ($i:expr, $tag: expr).
However throughout the places where tag! is used it is used with only one argument, i.e. tag!("+").
Example: nom-lua52/op.rs. I've read tutorials about macros however this construct seems to be special.
It seems like the input $i is somehow implicit?
macros rust nom
add a comment |
I'm trying to understand how Rust macro captures work and am looking at the nom parser library.
Location nom/src/bytes.rs declares macro tag! which captures with ($i:expr, $tag: expr).
However throughout the places where tag! is used it is used with only one argument, i.e. tag!("+").
Example: nom-lua52/op.rs. I've read tutorials about macros however this construct seems to be special.
It seems like the input $i is somehow implicit?
macros rust nom
add a comment |
I'm trying to understand how Rust macro captures work and am looking at the nom parser library.
Location nom/src/bytes.rs declares macro tag! which captures with ($i:expr, $tag: expr).
However throughout the places where tag! is used it is used with only one argument, i.e. tag!("+").
Example: nom-lua52/op.rs. I've read tutorials about macros however this construct seems to be special.
It seems like the input $i is somehow implicit?
macros rust nom
I'm trying to understand how Rust macro captures work and am looking at the nom parser library.
Location nom/src/bytes.rs declares macro tag! which captures with ($i:expr, $tag: expr).
However throughout the places where tag! is used it is used with only one argument, i.e. tag!("+").
Example: nom-lua52/op.rs. I've read tutorials about macros however this construct seems to be special.
It seems like the input $i is somehow implicit?
macros rust nom
macros rust nom
edited Mar 22 at 16:22
loganfsmyth
107k21229188
107k21229188
asked Jul 16 '18 at 18:08
Konrad EiseleKonrad Eisele
1,058816
1,058816
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The trick is that the tag!() macro call is inside the value! macro, which will match against tag! and pass it an additional parameter. This is described in the file implementing tag!.
1
Thanks, Now I see the trick:$submac!($i, $($args)*).
– Konrad Eisele
Jul 16 '18 at 18:28
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51367781%2fwhere-does-noms-i-macro-argument-come-from%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The trick is that the tag!() macro call is inside the value! macro, which will match against tag! and pass it an additional parameter. This is described in the file implementing tag!.
1
Thanks, Now I see the trick:$submac!($i, $($args)*).
– Konrad Eisele
Jul 16 '18 at 18:28
add a comment |
The trick is that the tag!() macro call is inside the value! macro, which will match against tag! and pass it an additional parameter. This is described in the file implementing tag!.
1
Thanks, Now I see the trick:$submac!($i, $($args)*).
– Konrad Eisele
Jul 16 '18 at 18:28
add a comment |
The trick is that the tag!() macro call is inside the value! macro, which will match against tag! and pass it an additional parameter. This is described in the file implementing tag!.
The trick is that the tag!() macro call is inside the value! macro, which will match against tag! and pass it an additional parameter. This is described in the file implementing tag!.
answered Jul 16 '18 at 18:24
starbluestarblue
45.7k1178138
45.7k1178138
1
Thanks, Now I see the trick:$submac!($i, $($args)*).
– Konrad Eisele
Jul 16 '18 at 18:28
add a comment |
1
Thanks, Now I see the trick:$submac!($i, $($args)*).
– Konrad Eisele
Jul 16 '18 at 18:28
1
1
Thanks, Now I see the trick:
$submac!($i, $($args)*).– Konrad Eisele
Jul 16 '18 at 18:28
Thanks, Now I see the trick:
$submac!($i, $($args)*).– Konrad Eisele
Jul 16 '18 at 18:28
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51367781%2fwhere-does-noms-i-macro-argument-come-from%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown