[svn:parrot] r46958 - trunk/compilers/opsc/src/Ops/Compiler
bacek at svn.parrot.org
bacek at svn.parrot.org
Mon May 24 12:05:58 UTC 2010
Author: bacek
Date: Mon May 24 12:05:58 2010
New Revision: 46958
URL: https://trac.parrot.org/parrot/changeset/46958
Log:
Speed up opsc parsing process by rewriting body_word rule and avoid capturing C<panic> nodes.
It's bring prove t/compilers/opsc down to 85 seconds from 96 on my box.
Modified:
trunk/compilers/opsc/src/Ops/Compiler/Grammar.pm
Modified: trunk/compilers/opsc/src/Ops/Compiler/Grammar.pm
==============================================================================
--- trunk/compilers/opsc/src/Ops/Compiler/Grammar.pm Mon May 24 10:50:41 2010 (r46957)
+++ trunk/compilers/opsc/src/Ops/Compiler/Grammar.pm Mon May 24 12:05:58 2010 (r46958)
@@ -8,7 +8,7 @@
rule TOP {
<body>
- [ $ || <panic: 'Syntax error'> ]
+ [ $ || <.panic: 'Syntax error'> ]
}
rule body {
@@ -35,9 +35,9 @@
rule op {
<op_type>? 'op' <op_name=identifier>
- [ '(' <signature> ')' || <panic: "Fail to parse signature"> ]
+ [ '(' <signature> ')' || <.panic: "Fail to parse signature"> ]
<op_flag>*
- [ <op_body> || <panic: "Fail to parse op body"> ]
+ [ <op_body> || <.panic: "Fail to parse op body"> ]
{*}
}
@@ -89,11 +89,11 @@
#Process op body by breaking it into "words" consisting entirely of whitespace,
#alnums or a single punctuation, then checking for interesting macros (e.g $1
#or goto NEXT() ) in the midst of the words.
-regex body_word {
+token body_word {
[
- || <macro_param>
- || <op_macro>
- || $<word>=[<alnum>+|<punct>|<space>+]
+ || <.ws> <macro_param> <.ws>
+ || <.ws> <op_macro> <.ws>
+ || $<word>=[ [<alnum>+|<punct>]? <ws> ]
]
}
More information about the parrot-commits
mailing list