blob: 7bd8b82e232f94cd61ca9d7ccc16704153c70fc9 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
<title>manual.html</title>
</head>
<body>
<div style="text-align: center;">&nbsp; <big><big><span
style="font-weight: bold;">DParser FAQ<br>
</span></big></big>
<div style="text-align: left;"><big><br>
<br>
<span style="font-weight: bold;"></span></big><span
style="font-weight: bold;"><span style="font-weight: bold;">1. How do
I access the subnodes for expressions like "S: A*;" ?<br>
<span style="font-weight: bold;"><span style="font-weight: bold;"><span
style="font-weight: bold;"><br>
</span></span></span></span></span>In this case, "A*" is $n0 of type
D_ParseNode.&nbsp; In dparse.h the functions
d_get_number_of_children(D_ParseNode *) and d_get_child(D_ParseNode *,
int) allow you to get the number of children (<span
style="font-weight: bold;">A</span>'s) by calling
d_get_number_of_children(&amp;$n0) and individual children by calling
d_get_child(&amp;$n0, x).<br>
<br>
See the example: tests/g27.test.g<br>
<span style="font-weight: bold;"><br>
<span style="font-weight: bold;">2. Why doesn't '$n0.end_skip' include
the trailing whitespace when $n0 is a string/regex?<br>
<br>
</span></span>Whitespace is not skipped as part of the scan of a
string/regex but is done later (when the new parse state is
created).&nbsp; This makes it possible to change the whitespace parser
as a result of recognition of a particular string/regex.&nbsp; This is
used in the python grammar to handle implicit line joining.<br>
<br>
See the regex-productions LP RP LB RB LC RC in test/python.test.g.<br>
<br>
<span style="font-weight: bold;">3. What is the difference between
DParser and ANTLR?<br>
<span style="font-weight: bold;"></span></span><br>
The basic syntax of DParser and ANTLR grammars is very similar.&nbsp;
In fact, the DParser example ANSI-C grammar was ported from ANTLR in
less than an hour.&nbsp; <br>
<br>
Beyond that there are a number of differences.&nbsp; First of all ANTRL
has been developed for over a decade while DParser is relatively
young.&nbsp; Internally, DParser is a table-driven parser while ANTLR
generates directly executable parsers.&nbsp; DParser is a GLR parser
based on the Tomita algorithm while ANTLR is modified LL(k).&nbsp;
DParser is scannerless while ANTLR uses token streams.&nbsp; In terms
of power, both DParser and ANTLR are very powerful.&nbsp; In theory
DParser can handle any context free grammar, though not necessarily in
linear time.&nbsp; In practice ANTLR is likely to be faster (mostly
because it is more mature).&nbsp;&nbsp; Beyond that you would really
have ask Terance Parr who is more of a hard core parsing theory guru
than I am.<br>
<big><big><span style="font-weight: bold;"></span></big></big></div>
</div>
</body>
</html>