-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various issue with recursive tokens #257
Comments
@fdedinec, thank you for the feedback. I read your comment, but I still don't understand this issue, yet... Could you please show me the smallest possible PEG grammar and the shortest source text for the grammar to reveal the problem that you experienced? That will help me to understand this issue fully and I can give you a more meaningful comment. Thanks a lot! |
I might be wasting your time.
Upon attempting to build a minimal example, it seems the problem occurs because I sometimes have
DAGparser["name"] = [](const peg::SemanticValues &vs) {...}
instead of
DAGparser["name"] = [&](const peg::SemanticValues &vs) {...}
(missing the &)
This is what happens when you cutnpaste unfinished student code.
Sorry.
So your minimal example would be
DAGparser["name"] = [](const peg::SemanticValues &vs) {
cerr << this << endl;
return 0;
};
but you won't care.
I was tricked because the empty function
DAGparser["name"] = [](const peg::SemanticValues &vs) {
return 0;
};
compiles OK:
Thanks again for peglib.
From: "yhirose" ***@***.***>
To: "yhirose/cpp-peglib" ***@***.***>
Cc: "fdedinec" ***@***.***>, "Mention" ***@***.***>
Sent: Saturday, 10 December, 2022 16:05:11
Subject: Re: [yhirose/cpp-peglib] Various issue with recursive tokens (Issue #257)
[ https://github.com/fdedinec | @fdedinec ] , thank you for the feedback. I read your comment, but I still don't understand it... Could you please show me the smallest possible PEG grammar and the shortest source text for the grammar? That will help me to understand fully what you are talking about. Thanks a lot!
—
Reply to this email directly, [ #257 (comment) | view it on GitHub ] , or [ https://github.com/notifications/unsubscribe-auth/AD4UX3L4VLOP6ANWQS5ENGLWMSL2PANCNFSM6AAAAAAS2JLP5I | unsubscribe ] .
You are receiving this because you were mentioned. Message ID: <yhirose/cpp-peglib/issues/257/1345283246 @ github . com>
|
@fdedinec sorry that I still don't understand what the problem is... Anyway, it seems like it's not an issue anymore. Hope your project will go smoothly! |
Hello,
I suspect that issue 44 is a consequence of this one.
Below is my grammar (sorry for the mess, work in progress).
I have two issues with the various typeName->name
One is #44 : I have to remove the whitespaces in a c++ post-prrocessing pass.
The second is that the following code doesn't work:
(...) error: ‘this’ was not captured for this lambda function
(which prevents these functions to do the housekeeping they were intended for)
while DAGparser["nameValuePair"] = [&](const peg::SemanticValues &vs) {
cerr << this << endl;
(...) }
compiles OK.
I am not sure I understand why some rules are special.
If it is a feature of PEG (I come from yacc then antlr) please close this bug stating so.
I'll be avoiding this situation in between, it makes the grammar less verbose but also less explicit.
Thanks for cpp-peglib.
Florent
-- Bug reports are love letters.
dag <- command*
command <- parameterDeclaration / fileName / operatorDeclaration / InputDeclaration / OutputDeclaration / Assignment / LineComment/ EndOfLine
fileName <- 'Name' entityName ';'
parameterDeclaration <- 'Param' paramName '=' number ';'
operatorDeclaration <- 'Operator' instanceName ':' entityName nameValuePair* ';'
nameValuePair <- name '=' value
InputDeclaration <- 'Input' signalName ':' typeName '(' value ',' value ')' ';'
OutputDeclaration <- 'Output' signalName ':' typeName '(' value ',' value ')' ';'
Assignment <- signalName '=' instance ';'
instance <- instanceName '(' arg (',' arg)* ')'
arg <- instance / signalName
typeName <- name
instanceName <- name
entityName <- name
paramName <- name
signalName <- name
value <- string / number / paramValue
string <- < '"' (!'"' .)* '"' >
number <- < '-'? [0-9]+ >
name <- < [a-zA-Z] [a-zA-Z0-9-_]* >
paramValue <- '$' name
%whitespace <- [ \t\n]*
Endl <- EndOfLine / EndOfFile
EndOfLine <- '\r\n' / '\n' / '\r'
EndOfFile <- !.
LineComment <- ('#' / '//') (!Endl .)* &Endl
The text was updated successfully, but these errors were encountered: