Permalink
Browse files

Perlito5 - grammar - optimize

  • Loading branch information...
1 parent 39fbeed commit 5a122ec0d43edd14aae43ced98ccd0b963d8992d @fglock committed Aug 15, 2013
Showing with 18 additions and 18 deletions.
  1. +6 −6 html/perlito5.js
  2. +6 −6 perlito5.pl
  3. +6 −6 src5/lib/Perlito5/Grammar/Precedence.pm
View
@@ -1927,9 +1927,9 @@ var p5100 = p5pkg['main'];
if ( (v_End_token)._hash_.hasOwnProperty(v_term) ) {
(function () {
var v_c1;
- (v_c1 = (p5pkg["Perlito5::Grammar::Precedence"].substr([v_str, ((p5num(v_pos) + p5pkg["Perlito5::Grammar::Precedence"].length([v_term], 0)) - 1), 1], 0)));
+ (v_c1 = (p5pkg["Perlito5::Grammar::Precedence"].substr([v_str, ((p5num(v_pos) + p5num(v_len)) - 1), 1], 0)));
var v_c2;
- (v_c2 = (p5pkg["Perlito5::Grammar::Precedence"].substr([v_str, (p5num(v_pos) + p5pkg["Perlito5::Grammar::Precedence"].length([v_term], 0)), 1], 0)));
+ (v_c2 = (p5pkg["Perlito5::Grammar::Precedence"].substr([v_str, (p5num(v_pos) + p5num(v_len)), 1], 0)));
if ( (!( (p5bool(p5pkg["Perlito5::Grammar::Precedence"].is_ident_middle([v_c1], 0)) && p5bool(p5pkg["Perlito5::Grammar::Precedence"].is_ident_middle([v_c2], 0)))) && !( ((p5str(v_c1) == '<') && (p5str(v_c2) == '<')))) ) {
throw((new p5HashRef(p5a_to_h(p5list_to_a('str', v_str, 'from', v_pos, 'to', v_pos, 'capture', (new p5ArrayRef(['end', v_term])))))));
};
@@ -1943,9 +1943,9 @@ var p5100 = p5pkg['main'];
if ( (Hash_Term).hasOwnProperty(v_term) ) {
(function () {
var v_c1;
- (v_c1 = (p5pkg["Perlito5::Grammar::Precedence"].substr([v_str, ((p5num(v_pos) + p5pkg["Perlito5::Grammar::Precedence"].length([v_term], 0)) - 1), 1], 0)));
+ (v_c1 = (p5pkg["Perlito5::Grammar::Precedence"].substr([v_str, ((p5num(v_pos) + p5num(v_len)) - 1), 1], 0)));
var v_c2;
- (v_c2 = (p5pkg["Perlito5::Grammar::Precedence"].substr([v_str, (p5num(v_pos) + p5pkg["Perlito5::Grammar::Precedence"].length([v_term], 0)), 1], 0)));
+ (v_c2 = (p5pkg["Perlito5::Grammar::Precedence"].substr([v_str, (p5num(v_pos) + p5num(v_len)), 1], 0)));
if ( ((p5bool(p5pkg["Perlito5::Grammar::Precedence"].is_num([v_c1], 0)) || !( p5bool(p5pkg["Perlito5::Grammar::Precedence"].is_ident_middle([v_c1], 0)))) || !( p5bool(p5pkg["Perlito5::Grammar::Precedence"].is_ident_middle([v_c2], 0)))) ) {
(function () {
var v_m;
@@ -1978,9 +1978,9 @@ var p5100 = p5pkg['main'];
if ( (Hash_Op).hasOwnProperty(v_op) ) {
(function () {
var v_c1;
- (v_c1 = (p5pkg["Perlito5::Grammar::Precedence"].substr([v_str, ((p5num(v_pos) + p5pkg["Perlito5::Grammar::Precedence"].length([v_op], 0)) - 1), 1], 0)));
+ (v_c1 = (p5pkg["Perlito5::Grammar::Precedence"].substr([v_str, ((p5num(v_pos) + p5num(v_len)) - 1), 1], 0)));
var v_c2;
- (v_c2 = (p5pkg["Perlito5::Grammar::Precedence"].substr([v_str, (p5num(v_pos) + p5pkg["Perlito5::Grammar::Precedence"].length([v_op], 0)), 1], 0)));
+ (v_c2 = (p5pkg["Perlito5::Grammar::Precedence"].substr([v_str, (p5num(v_pos) + p5num(v_len)), 1], 0)));
if ( (!( (p5bool(p5pkg["Perlito5::Grammar::Precedence"].is_ident_middle([v_c1], 0)) && p5bool(p5pkg["Perlito5::Grammar::Precedence"].is_ident_middle([v_c2], 0)))) && !( ((p5str(v_c1) == '&') && (p5str(v_c2) == '&')))) ) {
if ( ((((v_Operator || (v_Operator = new p5HashRef({})))._hash_.p5hget('infix'))._hash_.hasOwnProperty(v_op) && !( ((v_Operator || (v_Operator = new p5HashRef({})))._hash_.p5hget('prefix'))._hash_.hasOwnProperty(v_op))) && !( p5bool(v_last_is_term))) ) {
null;
View
@@ -338,8 +338,8 @@ sub Perlito5::Grammar::Precedence::op_parse {
for my $len (@{$End_token_chars}) {
((my $term) = substr($str, $pos, $len));
if (exists($End_token->{$term})) {
- ((my $c1) = substr($str, (($pos + length($term)) - 1), 1));
- ((my $c2) = substr($str, ($pos + length($term)), 1));
+ ((my $c1) = substr($str, (($pos + $len) - 1), 1));
+ ((my $c2) = substr($str, ($pos + $len), 1));
if ((!(((is_ident_middle($c1) && is_ident_middle($c2)))) && !(((($c1 eq '<') && ($c2 eq '<')))))) {
return ({'str', $str, 'from', $pos, 'to', $pos, 'capture', ['end', $term]})
}
@@ -349,8 +349,8 @@ sub Perlito5::Grammar::Precedence::op_parse {
for my $len (@Term_chars) {
((my $term) = substr($str, $pos, $len));
if (exists($Term{$term})) {
- ((my $c1) = substr($str, (($pos + length($term)) - 1), 1));
- ((my $c2) = substr($str, ($pos + length($term)), 1));
+ ((my $c1) = substr($str, (($pos + $len) - 1), 1));
+ ((my $c2) = substr($str, ($pos + $len), 1));
if (((is_num($c1) || !(is_ident_middle($c1))) || !(is_ident_middle($c2)))) {
((my $m) = $Term{$term}->($str, $pos));
if ($m) {
@@ -372,8 +372,8 @@ sub Perlito5::Grammar::Precedence::op_parse {
for my $len (@Op_chars) {
((my $op) = substr($str, $pos, $len));
if (exists($Op{$op})) {
- ((my $c1) = substr($str, (($pos + length($op)) - 1), 1));
- ((my $c2) = substr($str, ($pos + length($op)), 1));
+ ((my $c1) = substr($str, (($pos + $len) - 1), 1));
+ ((my $c2) = substr($str, ($pos + $len), 1));
if ((!(((is_ident_middle($c1) && is_ident_middle($c2)))) && !(((($c1 eq '&') && ($c2 eq '&')))))) {
if (((exists($Operator->{'infix'}->{$op}) && !(exists($Operator->{'prefix'}->{$op}))) && !($last_is_term))) {
@@ -82,8 +82,8 @@ sub op_parse {
for my $len ( @$End_token_chars ) {
my $term = substr($str, $pos, $len);
if (exists($End_token->{$term})) {
- my $c1 = substr($str, $pos + length($term) - 1, 1);
- my $c2 = substr($str, $pos + length($term), 1);
+ my $c1 = substr($str, $pos + $len - 1, 1);
+ my $c2 = substr($str, $pos + $len, 1);
if ( !(is_ident_middle($c1) && is_ident_middle($c2) )
&& !($c1 eq '<' && $c2 eq '<')
)
@@ -104,8 +104,8 @@ sub op_parse {
for my $len ( @Term_chars ) {
my $term = substr($str, $pos, $len);
if (exists($Term{$term})) {
- my $c1 = substr($str, $pos + length($term) - 1, 1);
- my $c2 = substr($str, $pos + length($term), 1);
+ my $c1 = substr($str, $pos + $len - 1, 1);
+ my $c2 = substr($str, $pos + $len, 1);
if ( is_num($c1) || !is_ident_middle($c1) || !is_ident_middle($c2) ) {
my $m = $Term{$term}->($str, $pos);
return $m if $m;
@@ -126,8 +126,8 @@ sub op_parse {
for my $len ( @Op_chars ) {
my $op = substr($str, $pos, $len);
if (exists($Op{$op})) {
- my $c1 = substr($str, $pos + length($op) - 1, 1);
- my $c2 = substr($str, $pos + length($op), 1);
+ my $c1 = substr($str, $pos + $len - 1, 1);
+ my $c2 = substr($str, $pos + $len, 1);
if (
!(is_ident_middle($c1) && is_ident_middle($c2))
&& !($c1 eq '&' && $c2 eq '&')

0 comments on commit 5a122ec

Please sign in to comment.