Author: allison
Date: Sat Jan 7 19:55:19 2006
New Revision: 10977
Modified:
trunk/ (props changed)
trunk/languages/punie/lib/PunieGrammar.pir
trunk/languages/punie/lib/pge2past.g
trunk/languages/punie/lib/post2pir.g
Log:
Extract string value from PGE::Text::bracketed matches.
Modified: trunk/languages/punie/lib/PunieGrammar.pir
==============================================================================
--- trunk/languages/punie/lib/PunieGrammar.pir (original)
+++ trunk/languages/punie/lib/PunieGrammar.pir Sat Jan 7 19:55:19 2006
@@ -6,7 +6,7 @@ PunieGrammar -- A grammar for parsing Pe
.sub _main :main
load_bytecode 'PunieGrammar.pir'
- .local pmc line
+ .local pmc start_rule
.local pmc match
.local string source
@@ -14,10 +14,10 @@ PunieGrammar -- A grammar for parsing Pe
source = 'print 1;'
# Retrieve the start rule
- line = find_global 'PunieGrammar', 'line'
+ start_rule = find_global 'PunieGrammar', 'prog'
# Parse the source and return a match object
- match = line(source)
+ match = prog(source)
... # Do something with the parse tree
Modified: trunk/languages/punie/lib/pge2past.g
==============================================================================
--- trunk/languages/punie/lib/pge2past.g (original)
+++ trunk/languages/punie/lib/pge2past.g Sat Jan 7 19:55:19 2006
@@ -131,6 +131,25 @@ PunieGrammar::term: result(.) = {
# code for this match node
$S2 = node
$I3 = node.from()
- result.set_node($S2,$I3,$S2)
+
+ $S3 = tree.get('value', node, 'PunieGrammar::term')
+
+ result.set_node($S2,$I3,$S3)
.return (result)
}
+
+PunieGrammar::term: value(.) = {
+ .local string value
+
+ # Check if this is a string match
+ $I0 = defined node["PGE::Text::bracketed"]
+ if $I0 goto bracketed_value
+ value = node
+ goto no_bracketed_value
+ bracketed_value:
+ $P1 = node["PGE::Text::bracketed"]
+ $P2 = $P1[0]
+ value = $P2
+ no_bracketed_value:
+ .return (value)
+}
Modified: trunk/languages/punie/lib/post2pir.g
==============================================================================
--- trunk/languages/punie/lib/post2pir.g (original)
+++ trunk/languages/punie/lib/post2pir.g Sat Jan 7 19:55:19 2006
@@ -41,5 +41,7 @@ POST::Op: result(.) = {
POST::Val: result(.) = {
$S1 = node.value()
- .return ($S1)
+ $S2 = '"' . $S1 # temporarily treat all values as strings
+ $S2 .= '"'
+ .return ($S2)
}