Changeset 3236 for src/pge

Show
Ignore:
Timestamp:
05/15/05 01:16:08 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
4802
Message:

* external parrot for Rules is now kept in a single process, instead of spawning one parrot for each rules invocation

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/pge/run_pge.pir

    r3183 r3236  
    11.sub _main 
    2     .local int spi, spc, utf8 
     2    .local int spi, spc, utf8, pos, size1, size2 
    33    .local pmc args, match, add_rule 
    4     .local string name, rule, input, result 
    5     .include "iglobals.pasm" 
     4    .local string name, rule, input, result, cmd, sizeStr, arg1, arg2 
     5    .local pmc stdin 
    66 
    77    load_bytecode "PGE/Hs.pir" 
    8     utf8        = charset "utf8" 
    9     add_rule    = find_global "PGE::Hs", "add_rule" 
     8    match = find_global "PGE::Hs", "match" 
    109 
    11     getinterp args 
    12     set args, args[.IGLOBALS_ARGV_LIST] 
    13     spi = 3 
    14     spc = elements args 
     10  loop: 
     11    getstdin stdin 
     12    readline input, stdin 
     13    length pos, input  
     14    if pos < 1 goto end 
     15    pos = index input, " " 
     16    if pos == 0 goto loop 
     17    cmd = substr input, 0, pos 
     18    inc pos 
     19    input = substr input, pos 
     20    pos = index input, " " 
     21    if pos == 0 goto loop 
     22    sizeStr = substr input, 0, pos 
     23    size1 = sizeStr 
     24    inc pos 
     25    sizeStr = substr input, pos 
     26    size2 = sizeStr 
    1527 
    16   subrules: 
    17     unless spi < spc goto do_match 
    18     name    = args[spi] 
    19     inc spi 
    20     rule    = args[spi] 
    21     inc spi 
    22     trans_charset name, utf8 
    23     trans_charset rule, utf8 
    24     add_rule(name, rule) 
    25     goto subrules 
     28    # Now read up arg1 and arg2 
     29    inc size1 
     30    arg1 = read stdin, size1 
     31    chopn arg1, 1 # skip \n 
     32    inc size2 
     33    arg2 = read stdin, size2 
     34    chopn arg2, 1 # skip \n 
     35 
     36    if cmd == "add_rule" goto do_add_rule 
     37    if cmd == "match" goto do_match 
     38    goto loop 
     39  
     40  do_add_rule: 
     41    add_rule(arg1, arg2) 
     42    goto loop 
     43 
    2644  do_match: 
    27     match   = find_global "PGE::Hs", "match" 
    28     input   = args[1] 
    29     rule    = args[2] 
    30     trans_charset input, utf8 
    31     trans_charset rule, utf8 
    32     result  = match(input, rule) 
     45    result = match(arg1, arg2) 
     46    length pos, result  
     47    print "OK " 
     48    print pos 
     49    print "\n" 
    3350    print result 
     51    print "\n" 
     52    goto loop 
     53 
     54  end: 
    3455.end