Re: [Spirit-general] Problem with Parsing
Hi,
Have you tried using the Spirit debugger?
Cheers,
--
Joel de Guzman
joel at boost-consulting.com
http://www.boost-consulting.com
http://spirit.sf.net
Surinder Pal Singh
Hi, I am trying to use Spirit (in the latest Boost 1_30_0) for a project. I want to parse a file whose structure is the following:
section1 { something; }
I am using the file_iterator to iterate on the input file and then define comment as well as the grammar. I am at my wits end why my parser keeps failing. (When this simple grammar works, I want to make the parser more complex.) My code is attached below. (Note: I used the example in the distribution c_grammar.cpp as the starting point for it.)
Thanks.
-surinder I have attempted to join the spirit mail list, but have not received the confirmation so far, but please feel free to respond to me at: sps22_at_yahoo_dot_com
PS: This input file structure is going to be, of course, more complicated than the example shown above. Inside the setions, I would like to pass on flags and statements to the code. If it is better for me to use another approach to parse this file structure, please suggest me.
[snip]
Joel:
On your suggestion, I used the debugging and found that if I replace
FILE >> LEFT_BRACE >> *(anychar_p) >> RIGHT_BRACE
by a real rule like
FILE >> LEFT_BRACE >> A_REAL_RULE >> RIGHT_BRACE
then it works OK. What was strange was that the debugger indicated
that the entire input file was consumed by the first original code
and all that was left was "" and it still said parser failed. Any
insight into it?
Thanks.
-Surinder
PS: Could not post the response to the Spirit mailing list.
--- In Boost-Users@yahoogroups.com, "Joel de Guzman"
Hi,
Have you tried using the Spirit debugger?
Cheers, -- Joel de Guzman joel at boost-consulting.com http://www.boost-consulting.com http://spirit.sf.net
Surinder Pal Singh
wrote: Hi, I am trying to use Spirit (in the latest Boost 1_30_0) for a project. I want to parse a file whose structure is the following:
section1 { something; }
I am using the file_iterator to iterate on the input file and then define comment as well as the grammar. I am at my wits end why my parser keeps failing. (When this simple grammar works, I want to make the parser more complex.) My code is attached below. (Note: I used the example in the distribution c_grammar.cpp as the starting point for it.)
Thanks.
-surinder I have attempted to join the spirit mail list, but have not received the confirmation so far, but please feel free to respond to me at: sps22_at_yahoo_dot_com
PS: This input file structure is going to be, of course, more complicated than the example shown above. Inside the setions, I would like to pass on flags and statements to the code. If it is better for me to use another approach to parse this file structure, please suggest me.
[snip]
*(anychar_p) will grab characters until the cows comes home (e.g. you run
out of input). You need to remove RIGHT_BRACE from the set of characters
that it will accept. I don't recall the exact syntax but it will be in the
docs somewhere, basically it looks like a subtraction.
Dave
----- Original Message -----
From: "sps22"
Joel:
On your suggestion, I used the debugging and found that if I replace
FILE >> LEFT_BRACE >> *(anychar_p) >> RIGHT_BRACE
by a real rule like
FILE >> LEFT_BRACE >> A_REAL_RULE >> RIGHT_BRACE
then it works OK. What was strange was that the debugger indicated that the entire input file was consumed by the first original code and all that was left was "" and it still said parser failed. Any insight into it?
Thanks. -Surinder PS: Could not post the response to the Spirit mailing list.
--- In Boost-Users@yahoogroups.com, "Joel de Guzman"
wrote: Hi,
Have you tried using the Spirit debugger?
Cheers, -- Joel de Guzman joel at boost-consulting.com http://www.boost-consulting.com http://spirit.sf.net
Surinder Pal Singh
wrote: Hi, I am trying to use Spirit (in the latest Boost 1_30_0) for a project. I want to parse a file whose structure is the following:
section1 { something; }
I am using the file_iterator to iterate on the input file and then define comment as well as the grammar. I am at my wits end why my parser keeps failing. (When this simple grammar works, I want to make the parser more complex.) My code is attached below. (Note: I used the example in the distribution c_grammar.cpp as the starting point for it.)
Thanks.
-surinder I have attempted to join the spirit mail list, but have not received the confirmation so far, but please feel free to respond to me at: sps22_at_yahoo_dot_com
PS: This input file structure is going to be, of course, more complicated than the example shown above. Inside the setions, I would like to pass on flags and statements to the code. If it is better for me to use another approach to parse this file structure, please suggest me.
[snip]
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
That explains it, but not fully. I was using *(anychar_p) just for
seeing whether my parser gets the two braces or not. When I did:
FILE >> LEFT_BRACE >> RIGHT_BRACE
It did not parse either the input file:
"file { }"
-Surinder
--- In Boost-Users@yahoogroups.com, Dave Gomboc
*(anychar_p) will grab characters until the cows comes home (e.g. you run out of input). You need to remove RIGHT_BRACE from the set of characters that it will accept. I don't recall the exact syntax but it will be in the docs somewhere, basically it looks like a subtraction.
Dave
----- Original Message ----- From: "sps22"
To: Sent: Friday, August 01, 2003 11:03 AM Subject: [Boost-Users] Re: [Spirit-general] Problem with Parsing Joel:
On your suggestion, I used the debugging and found that if I replace
FILE >> LEFT_BRACE >> *(anychar_p) >> RIGHT_BRACE
by a real rule like
FILE >> LEFT_BRACE >> A_REAL_RULE >> RIGHT_BRACE
then it works OK. What was strange was that the debugger indicated that the entire input file was consumed by the first original code and all that was left was "" and it still said parser failed. Any insight into it?
Thanks. -Surinder PS: Could not post the response to the Spirit mailing list.
--- In Boost-Users@yahoogroups.com, "Joel de Guzman"
wrote: Hi,
Have you tried using the Spirit debugger?
Cheers, -- Joel de Guzman joel at boost-consulting.com http://www.boost-consulting.com http://spirit.sf.net
Surinder Pal Singh
wrote: Hi, I am trying to use Spirit (in the latest Boost 1_30_0) for a project. I want to parse a file whose structure is the following:
section1 { something; }
I am using the file_iterator to iterate on the input file and then define comment as well as the grammar. I am at my wits end why my parser keeps failing. (When this simple grammar works, I want to make the parser more complex.) My code is attached below. (Note: I used the example in the distribution c_grammar.cpp as the starting point for it.)
Thanks.
-surinder I have attempted to join the spirit mail list, but have not received the confirmation so far, but please feel free to respond to me at: sps22_at_yahoo_dot_com
PS: This input file structure is going to be, of course, more complicated than the example shown above. Inside the setions, I would like to pass on flags and statements to the code. If it is better for me to use another approach to parse this file structure, please suggest me.
[snip]
Info: http://www.boost.org Wiki: <http://www.crystalclearsoftware.com/cgi- bin/boost_wiki/wiki.pl> Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
sps22
That explains it, but not fully. I was using *(anychar_p) just for seeing whether my parser gets the two braces or not. When I did:
FILE >> LEFT_BRACE >> RIGHT_BRACE
It did not parse either the input file:
"file { }"
How about: FILE >> LEFT_BRACE >> *(anychar_p - RIGHT_BRACE) >> RIGHT_BRACE Cheers, -- Joel de Guzman joel at boost-consulting.com http://www.boost-consulting.com http://spirit.sf.net
participants (3)
-
Dave Gomboc
-
Joel de Guzman
-
sps22