Comments (5)
A bit more info. There is something odd happening with https://github.com/yhirose/cpp-peglib/blob/master/peglib.h#L2368
The length of the string passed in 's' is 743. But strlen is coming up with 760 hence it fails as ret.len != n.
If I use parse_n(..) the parse succeeds. Hmm. String is ascii.
from cpp-peglib.
Hi Jerry,
Could you make make sure that the 's' is a really null terminated string?
Here is my test code. When I run the code, I successfully got the success
message.
#include <peglib.h>
#include <iostream>
using namespace peg;
using namespace std;
auto syn = R"(
# a grammar to parse the GDB 'machine interface' (GDB/MI)
GDB_MI <- (GDB_ELEMENT EOL)*
GDB_ELEMENT <- (AT_STRING / NEG_STRING / OP_LIST)
AT_STRING <- '@' STRING_LITERAL
NEG_STRING <- '~' STRING_LITERAL
OP_LIST <- OP_CHAR IDENTIFIER ',' (RESULT_LIST)*
OP_CHAR <- ( '~' / '*' / '=' / '+' / '^')
RESULT_LIST <- RESULT (COMMA RESULT)*
RESULT <- (IDENTIFIER (ASSIGNMENT_OP/HASH_OP))? (STRING_LITERAL / LBRACE (RESULT_LIST)* RBRACE / LBRACK (RESULT_LIST)* RBRACK)
~ASSIGNMENT_OP <- < '=' >
HASH_OP <- < '#' >
LBRACE <- < '{' >
RBRACE <- < '}' >
LBRACK <- < '[' >
RBRACK <- < ']' >
~COMMA <- < ',' >
# GDB/MI strings contain escape sequences. The <> ensures the token
# content is captured in the STRING_LITERAL AST node
STRING_LITERAL <- < '"' (('\\"' / '\\t' / '\\n') / (!["] .))* '"' >
# GDB/MI identifiers can contain '-' as in -info-breakpoint
IDENTIFIER <- < [_a-zA-Z] ([_A-Za-z0-9] / '-')* >
# recognize but ignore end of line characters
~EOL <- '\n'
# sent at the end of a sequence
~TERMINATOR <- '(gdb)'
# consume the following during parse. +1!
%whitespace <- [ \t\r]*
)";
auto src = R"(^done,address="0x4000bb28",load-size="116244",transfer-rate="41104",write-rate="369",BreakpointTable={nr_rows="1",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x40003e10",func="main",file="../cyfxbulklpauto.c",fullname="r:\\src\\cypress\\fx3\\usbbulkloopauto\\cyfxbulklpauto.c",line="702",thread-groups=["i1"],times="0",original-location="main"}]}
)";
int main(int argc, const char** argv)
{
parser parser(syn);
parser.enable_ast();
shared_ptr<Ast> ast;
if (parser.parse(src, ast)) {
cout << "success" << endl;
return 0;
}
cout << "syntax error..." << endl;
return -1;
}
from cpp-peglib.
Hi Jerry,
How about this issue now? Is it resolved?
from cpp-peglib.
Hi Yuji, not sure./ Closing. Will re-open if this visits again.
from cpp-peglib.
Thanks for the reply!
from cpp-peglib.
Related Issues (20)
- About macro and actions HOT 2
- .enter/.leave get called twice, but shouldn't. HOT 3
- Unable to parse "special" characters like £¤¥¦§ HOT 5
- vs.choice() always returns 0 when %whitespace is defined. HOT 1
- peg.pdf document isn't a valid PDF HOT 3
- I create a python binding for this great lib
- Assertion failed: (cut_stack.empty()), function ~Context, file peglib.h, line 803 HOT 2
- Compilation error when trying to pass both `any& dt` and an output param to peg::parser::parse() HOT 2
- Providing a base class to AstBase throws exception. HOT 1
- [Question] Is there a way to receive typed errors (not just strings with error messages)?
- Throw from action gets confusing error HOT 2
- Build is broken with clang on macOS 10.7–10.12: Undefined symbols for architecture x86_64: "typeinfo for std::bad_any_cast" HOT 2
- Why "IdentCont" isn't grouped ? HOT 1
- When executing "test-main" I'm getting segfault HOT 8
- [Question] Multiline object with matched deliminators HOT 2
- Need help understanding what my parser is doing :) HOT 2
- QUESTION: How does one use "apd" (and predicate operator) HOT 1
- Tests fail to compile HOT 3
- Performance comparison with boost::spirit, PEGTL etc.? HOT 2
- Tag 1.8.5 needed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpp-peglib.