Menu

[r2]: / trunk / python / python.class  Maximize  Restore  History

Download this file

318 lines (302 with data), 5.0 kB

<?php 
class python extends lime_parser {
var $qi = 0;
var $i = array (
  0 => 
  array (
    'exp' => 's 1',
    'var' => 's 15',
    'num' => 's 3',
    '\'(\'' => 's 12',
    'stmt' => 's 18',
    '\'start\'' => 'a \'start\'',
  ),
  1 => 
  array (
    '\'!\'' => 's 2',
    '\'-\'' => 's 6',
    '\'*\'' => 's 8',
    '\'/\'' => 's 10',
    '#' => 'r 0',
  ),
  2 => 
  array (
    'num' => 's 3',
    'var' => 's 4',
    'exp' => 's 5',
    '\'(\'' => 's 12',
  ),
  3 => 
  array (
    '\'!\'' => 'r 2',
    '\'-\'' => 'r 2',
    '\'*\'' => 'r 2',
    '\'/\'' => 'r 2',
    '\')\'' => 'r 2',
    '#' => 'r 2',
  ),
  4 => 
  array (
    '\'!\'' => 'r 3',
    '\'-\'' => 'r 3',
    '\'*\'' => 'r 3',
    '\'/\'' => 'r 3',
    '\')\'' => 'r 3',
    '#' => 'r 3',
  ),
  5 => 
  array (
    '\'!\'' => 's 2',
    '\'-\'' => 's 6',
    '\'*\'' => 's 8',
    '\'/\'' => 's 10',
    '\')\'' => 'r 4',
    '#' => 'r 4',
  ),
  6 => 
  array (
    'num' => 's 3',
    'var' => 's 4',
    'exp' => 's 7',
    '\'(\'' => 's 12',
  ),
  7 => 
  array (
    '\'!\'' => 's 2',
    '\'-\'' => 'r 5',
    '\'*\'' => 's 8',
    '\'/\'' => 's 10',
    '\')\'' => 'r 5',
    '#' => 'r 5',
  ),
  8 => 
  array (
    'num' => 's 3',
    'var' => 's 4',
    'exp' => 's 9',
    '\'(\'' => 's 12',
  ),
  9 => 
  array (
    '\'!\'' => 's 2',
    '\'-\'' => 'r 6',
    '\'*\'' => 'r 6',
    '\'/\'' => 'r 6',
    '\')\'' => 'r 6',
    '#' => 'r 6',
  ),
  10 => 
  array (
    'num' => 's 3',
    'var' => 's 4',
    'exp' => 's 11',
    '\'(\'' => 's 12',
  ),
  11 => 
  array (
    '\'!\'' => 's 2',
    '\'-\'' => 'r 7',
    '\'*\'' => 'r 7',
    '\'/\'' => 'r 7',
    '\')\'' => 'r 7',
    '#' => 'r 7',
  ),
  12 => 
  array (
    'num' => 's 3',
    'var' => 's 4',
    'exp' => 's 13',
    '\'(\'' => 's 12',
  ),
  13 => 
  array (
    '\'!\'' => 's 2',
    '\'-\'' => 's 6',
    '\'*\'' => 's 8',
    '\'/\'' => 's 10',
    '\')\'' => 's 14',
  ),
  14 => 
  array (
    '\'/\'' => 'r 8',
    '\'*\'' => 'r 8',
    '\'-\'' => 'r 8',
    '\'!\'' => 'r 8',
    '\')\'' => 'r 8',
    '#' => 'r 8',
  ),
  15 => 
  array (
    '\'=\'' => 's 16',
    '\'!\'' => 'r 3',
    '\'-\'' => 'r 3',
    '\'*\'' => 'r 3',
    '\'/\'' => 'r 3',
    '#' => 'r 3',
  ),
  16 => 
  array (
    'exp' => 's 17',
    'num' => 's 3',
    'var' => 's 4',
    '\'(\'' => 's 12',
  ),
  17 => 
  array (
    '\'!\'' => 's 2',
    '\'-\'' => 's 6',
    '\'*\'' => 's 8',
    '\'/\'' => 's 10',
    '#' => 'r 1',
  ),
  18 => 
  array (
    '#' => 'r 9',
  ),
);
function reduce_0_stmt_1($tokens, &$result) {
#
# (0) stmt :=  exp
#
$result = reset($tokens);
 echo " -> "; echo $tokens[0]; echo "\n"; 
}

function reduce_1_stmt_2($tokens, &$result) {
#
# (1) stmt :=  var  '='  exp
#
$result = reset($tokens);
$v =& $tokens[0];
$e =& $tokens[2];

		echo "$v = $e\n";
		set_variable($v, $e);
  		
}

function reduce_2_exp_1($tokens, &$result) {
#
# (2) exp :=  num
#
$result = reset($tokens);

}

function reduce_3_exp_2($tokens, &$result) {
#
# (3) exp :=  var
#
$result = reset($tokens);
 $result = get_variable($tokens[0]); 
}

function reduce_4_exp_3($tokens, &$result) {
#
# (4) exp :=  exp  '!'  exp
#
$result = reset($tokens);
 $result = $tokens[0] + $tokens[2]; 
}

function reduce_5_exp_4($tokens, &$result) {
#
# (5) exp :=  exp  '-'  exp
#
$result = reset($tokens);
 $result = $tokens[0] - $tokens[2]; 
}

function reduce_6_exp_5($tokens, &$result) {
#
# (6) exp :=  exp  '*'  exp
#
$result = reset($tokens);
 $result = $tokens[0] * $tokens[2]; 
}

function reduce_7_exp_6($tokens, &$result) {
#
# (7) exp :=  exp  '/'  exp
#
$result = reset($tokens);
 $result = $tokens[0] / $tokens[2]; 
}

function reduce_8_exp_7($tokens, &$result) {
#
# (8) exp :=  '('  exp  ')'
#
$result = $tokens[1];

}

function reduce_9_start_1($tokens, &$result) {
#
# (9) 'start' :=  stmt
#
$result = reset($tokens);

}

var $method = array (
  0 => 'reduce_0_stmt_1',
  1 => 'reduce_1_stmt_2',
  2 => 'reduce_2_exp_1',
  3 => 'reduce_3_exp_2',
  4 => 'reduce_4_exp_3',
  5 => 'reduce_5_exp_4',
  6 => 'reduce_6_exp_5',
  7 => 'reduce_7_exp_6',
  8 => 'reduce_8_exp_7',
  9 => 'reduce_9_start_1',
);
var $a = array (
  0 => 
  array (
    'symbol' => 'stmt',
    'len' => 1,
    'replace' => true,
  ),
  1 => 
  array (
    'symbol' => 'stmt',
    'len' => 3,
    'replace' => true,
  ),
  2 => 
  array (
    'symbol' => 'exp',
    'len' => 1,
    'replace' => true,
  ),
  3 => 
  array (
    'symbol' => 'exp',
    'len' => 1,
    'replace' => true,
  ),
  4 => 
  array (
    'symbol' => 'exp',
    'len' => 3,
    'replace' => true,
  ),
  5 => 
  array (
    'symbol' => 'exp',
    'len' => 3,
    'replace' => true,
  ),
  6 => 
  array (
    'symbol' => 'exp',
    'len' => 3,
    'replace' => true,
  ),
  7 => 
  array (
    'symbol' => 'exp',
    'len' => 3,
    'replace' => true,
  ),
  8 => 
  array (
    'symbol' => 'exp',
    'len' => 3,
    'replace' => true,
  ),
  9 => 
  array (
    'symbol' => '\'start\'',
    'len' => 1,
    'replace' => true,
  ),
);
}

?>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.