|
From: | Fernando Ferreira |
Subject: | Re: my problem is "$" |
Date: | Sat, 30 Jun 2007 17:16:07 +0100 |
User-agent: | Thunderbird 2.0.0.0 (X11/20070525) |
hoanglong1712 wrote:
Hi, as it can be seen on the Flex Manual (http://www.gnu.org/software/flex/manual/html_mono/flex.html#SEC15), yyleng is a global variable generated by Flex that holds the size (in characters) of the currently matched token.good day everyonei don't understand this source code, please helpchar stemp[100] extern int yyleng strncpy(stemp,$1,yyleng) and here is my question : why must we declare extern what is yyleng what is the role of $1 in the above functionthat is all my questions . thank you for your kind attention
Without more details about the structure of your source code, there is no way exactly to tell why it must be declared as an external variable, but one can suppose that it is because you are linking against a foreign object, created by Flex, and yyleng is declared there, thus the necessity of the "extern" declaration.
$1, if you are using it inside an action, (as it is explained here: http://www.gnu.org/software/bison/manual/html_mono/bison.html#Actions), refers to the semantic value of the first symbol on the right hand side of the rule.
This particular snippet of source code seems to be copying the first token on the right side of the rule to the stemp variable, but without seeing more code, that is just speculation.
Hope it helps, Fernando Ferreira
[Prev in Thread] | Current Thread | [Next in Thread] |