develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34452 - trunk/compilers/pct/src/PCT

From:
pmichaud
Date:
December 27, 2008 14:29
Subject:
[svn:parrot] r34452 - trunk/compilers/pct/src/PCT
Message ID:
20081227222907.A7ACFCBA12@x12.develooper.com
Author: pmichaud
Date: Sat Dec 27 14:29:07 2008
New Revision: 34452

Modified:
   trunk/compilers/pct/src/PCT/Grammar.pir

Log:
[pct]:  Add smarter version of FAILGOAL rule for grammars.


Modified: trunk/compilers/pct/src/PCT/Grammar.pir
==============================================================================
--- trunk/compilers/pct/src/PCT/Grammar.pir	(original)
+++ trunk/compilers/pct/src/PCT/Grammar.pir	Sat Dec 27 14:29:07 2008
@@ -51,6 +51,28 @@
 .end
 
 
+=item FAILGOAL($goal [, 'dba'=>dba])
+
+Invoked when goal matching fails to find the goal.  Builds an appropriate
+error message and delegates the rest to C<panic>.
+
+=cut
+
+.sub 'FAILGOAL' :method
+    .param string goal
+    .param pmc options         :named :slurpy
+    .local string dba
+    dba = options['dba']
+    if dba goto have_dba
+    ##  if no dba supplied, use the name of the caller sub
+    $P0 = getinterp
+    $P0 = $P0['sub';1]
+    dba = $P0
+  have_dba:
+    .tailcall self.'panic'("Unable to parse ", dba, "; couldn't find final ", goal)
+.end
+    
+
 =item item()
 
 Here we overload the item() method from PGE::Match to



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About