osdir.com
mailing list archive
Mozy Online Backup: 2GB Free. Automatic. Secure.

Subject: Deterministic parser backend for spirit - msg#00008

List: parsers.spirit.devel

Date: Prev Next Index Thread: Prev Next Index
I have been developing a deterministic parser backend for spirit.
Is there any interest for this?

Here is what it is:
It is implemented as a separate rule type, deterministic_rule.
A parser is assigned to the rule, e.g.
rule=real_p;
and a function: build_expression is called on the parser. This
function will build a deterministic parse graph. As I understand it,
this approach will fit well with the new spirit2.
A node in this graph has the following data:
1. A range map between e.g. char and a new node. (May point to itself)
2. A node builder to support rules referring to other rules
3. A separate node to support recursion

Each rule holds a root node and a set of end node references.
If the input is exhausted at an end node reference, and we are not
inside a recursion,
the parsing is successful. Otherwise it fails.

The following parsers are supported so far:
alternative, |
difference, -
primitives, char_p,str_p,space_p etc.
sequence, >>
looping, *,+
optional,!
numerics, real_p,int_p,etc
directives,lexeme_d
other rules.
In addition, skip parsers can be used. Currently this must be added to
the rule type.

The following is a partial implementation (from memory) of a c++ literal.
I added two exceptions (keywords) as well, to show that it works as expected.

typedef deterministic_rule<std::string::iterator,int> rule_t;
uint_parser<unsigned, 16,4,4> hex_quad;
rule_t rule;
rule=(
(
alpha_p
| '_'
| ("\\b" >> hex_quad)
) >>
*(
alnum_p
| '_'
| ("\\b" >> hex_quad)
)
) - (str_p("int")|str_p("if"))
;
rule.simplify_nodes();

Simplifying a rule is not necessary. It removes duplicate brances,
increasing the clarity of the parse graph. In this case, it removed 6
nodes.

When combining rules, we need to build a temporary node builder in
place of the actual node unification process (serial join,parallel
join or imprint)
The node builder does not need to be expanded until that path is
traversed during parsing.

I also attach the output of the calculator grammar (with a skip
parser). This is not optimal with respect to the number of nodes
(Extra nodes generated in '(' >> expression >> ')')
Due to the complexity of this tree, I have not been able to fully
verify its validity. Only actual parsing will prove if it works.

What is missing:
Actions. I have some ideas of how to implement at least ast parse tree
node actions, but I need help in a general solution.
Better recursion implementation:
e.g. rule1= rule2 >> *(('+' >> rule2) | ('++' >> rule2)) will
currently not work.
(rule1= rule2 >> *(('+' >> rule2) | ('-' >> rule2)) will work)
Support for unicode range maps.
Testing,testing,testing.

Regards,
Peder Holt

Attachment: numerics.dot.png
Description: PNG image

Attachment: literal.dot.png
Description: PNG image

Attachment: calc.dot.png
Description: PNG image

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642_______________________________________________
Spirit-devel mailing list
Spirit-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: Questions re packaging Spirit 1.6.4

Nicola Musatti wrote: > Comments? Please wait! That is, go ahead for the 1.34 testers but let's wait with the official release. It's likely to be the last one for some compilers, so I'd like to completely revise "trees" first: - the performance fix still needs to be ported to MSVC6.5 (the patch I posted does not affect MSVC6 - there's a "workaround version" in a separate file) - guessing from the source, no_node_d is likely to cause compile errors in some situations (there's no testing for these cases) - no_node_d reportedly produces empty nodes (recent support request on spirit.general) These are two many bugs to include in a release, IMO. Regards, Tobias ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

Next Message by Date: click to view message preview

Re: Deterministic parser backend for spirit

Peder Holt wrote: > I have been developing a deterministic parser backend for spirit. > Is there any interest for this? > > Here is what it is: Amazing! I'm interested. Some simple questions for now: * How long does it take to build the calculator graph? * How much memory did it consume? * Did you do any benchmarks to compare the speeds? Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

Previous Message by Thread: click to view message preview

Questions re packaging Spirit 1.6.4

Hallo, After practicing a little archeology on the Spirit branches of the Boost CVS repository I have a few ideas/questions concerning what should go into Spirit 1.6.4: I believe I should update Miniboost to the current state of the RC_1_34_0 branch of the Boost CVS repository. Should I be ready before Boost 1.34 we might consider keeping around a 1.6.4 beta until Boost 1.34 comes out and resynchronize. Updating Miniboost entails moving 1.6.4 to Boost.Build v2. What should go into Miniboost? I noticed that contents do not match between Spirit 1.6.3 and the current SPIRIT_1_6 branch, nor between Spirit 1.8.4 and the current SPIRIT_MINIBOOST in CVS. I tried using the bcp tool, but that brings in almost all of Boost. One approach could be to put in the union of what's in each of the above. This would be reasonable if additional 1.8.x releases are going to be extracted from the RC_1_34_0 branch and/or Boost CVS before it is moved to Subversion, otherwise it might be more sensible to stick to what was included in 1.6.3 . Comments? Cheers, Nicola Musatti ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

Next Message by Thread: click to view message preview

Re: Deterministic parser backend for spirit

Peder Holt wrote: > I have been developing a deterministic parser backend for spirit. > Is there any interest for this? > > Here is what it is: Amazing! I'm interested. Some simple questions for now: * How long does it take to build the calculator graph? * How much memory did it consume? * Did you do any benchmarks to compare the speeds? Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by