I am trying to use yply to generate a parser off of an existing parser
written with bison/flex.
The parser code is here:
https://android.googlesource.com/platform/external/checkpolicy/
The parser is for the SELinux policy files and converts them into binary
form to load into the kernel
A lot of this is still smoke and mirrors, I am new to this world of
parsing, but I really liked the idea
of yply in that I don't need to keep separate definitions of the parser, it
can live in checkpolicy
like it always has.
With that said, I ran into Python throwing a syntax error on the generated
output when the expanded
prod ended with a single quote. I was able to correct this via the attached
patch (raw-diff only sorry).
Not sure if thats the best fix, I can upload this to GitHub as a pull
request if desired.
I was able to run the generate code, but then got errors from ply:
<snip>
ERROR: new.py:416: Symbol 'names' used, but not defined as a token or a rule
ERROR: new.py:416: Symbol 'names' used, but not defined as a token or a rule
ERROR: new.py:416: Symbol 'names' used, but not defined as a token or a rule
ERROR: new.py:416: Symbol 'names' used, but not defined as a token or a rule
WARNING: Token 'SAMEUSER' defined, but not used
WARNING: Token 'IPV4_ADDR' defined, but not used
ERROR: Infinite recursion detected for symbol 'default_user_def'
ERROR: Infinite recursion detected for symbol 'cond_stmt_def'
ERROR: Infinite recursion detected for symbol 'dominance'
ERROR: Infinite recursion detected for symbol 'common_perms'
ERROR: Infinite recursion detected for symbol 'level_def'
ERROR: Infinite recursion detected for symbol 'policy'
ERROR: Infinite recursion detected for symbol 'mlsvalidatetrans_def'
ERROR: Infinite recursion detected for symbol 'sensitivities'
ERROR: Infinite recursion detected for symbol 'default_range_def'
</snip>
Any help, is this tool officially supported by the project?
--
You received this message because you are subscribed to the Google Groups
"ply-hack" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ply-hack/9caf9dd4-55c4-4f64-bba5-49ee32a1300c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/example/yply/yparse.py b/example/yply/yparse.py
index ab5b884..d1f60ff 100644
--- a/example/yply/yparse.py
+++ b/example/yply/yparse.py
@@ -138,7 +138,12 @@ def p_rules(p):
embed_count += 1
else:
prod.append(item)
- print " '''%s : %s'''" % (rulename, " ".join(prod))
+
+ prod = " ".join(prod)
+ if prod.endswith('\''):
+ prod = prod[:-1] + "\\'"
+
+ print " '''%s : %s'''" % (rulename, prod)
# Emit code
print_code(prodcode,4)
print