From 0dc3cd6da4a9ef818cd3b86afdbc775f72c14735 Mon Sep 17 00:00:00 2001 From: yhirose Date: Sun, 8 Feb 2015 09:43:49 -0500 Subject: [PATCH] Corrected documentation. --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 07e0a90..2ca9b78 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ assert(ret == true); assert(val == -3); ``` -It may be helpful to keep in mind that the action behavior is similar to the YACC semantic action model ($$ = $1, $2, ...). +It may be helpful to keep in mind that the action behavior is similar to the YACC semantic action model ($$, $1, $2, ...). In this example, the actions return values. These samentic values will be pushed up to the parent definition which can be referred to in the parent action `[](const vector& v)`. In other words, when a certain definition has been accepted, we can find all semantic values which are associated with the child definitions in `const vector& v`. The values are wrapped by peblib::Any class which is like `boost::any`. We can retrieve the value by using `get` method where `T` is the actual type of the value. If no value is returned in an action, an undefined `Any` will be pushed up to the parent. Finally, the resulting value of the root definition is received in the out parameter of `parse` method in the parser. `long val` is the resulting value in this case. @@ -121,9 +121,8 @@ Instead of makeing a parser by parsing PEG syntax text, we can also construct a using namespace peglib; using namespace std; -Definition ROOT, TAG, TAG_NAME, _; -ROOT = seq(_, zom(TAG)); -TAG = seq(chr('['), TAG_NAME, chr(']'), _); +Definition ROOT, TAG_NAME, _; +ROOT = seq(_, zom(seq(chr('['), TAG_NAME, chr(']'), _))); TAG_NAME = oom(seq(npd(chr(']')), any())); _ = zom(cls(" \t"));