1. [Phix] Compilation error

This simple script runs without problem when interpreted:

include builtins/regex.e 
 
function by_ilosc(object a, object b) 
    return compare(b[2], a[2]) 
end function 
 
 
integer y, l = 0 
sequence unique_words = {} 
sequence pairs = {} 
puts(1, "Reading the file...\n") 
object fn = open("Hamlet.txt","r") 
sequence whole_text = lower(get_text(fn)) 
close(fn) 
 
puts(1, "Counting...\n") 
 
whole_text = gsub("[^a-z]", whole_text, " ") 
 
sequence all_words = split(whole_text, no_empty:=true) 
 
for x = 1 to length(all_words) do 
    if length(all_words[x]) > 1 or equal(all_words[x], "a") or equal(all_words[x], "i") then 
        y = find(all_words[x], unique_words) 
        if y > 0 then 
            unique_words[y + 1] = unique_words[y + 1] + 1 
        else 
            unique_words = append(unique_words, all_words[x]) 
            unique_words = append(unique_words, 1) 
        end if 
        l = l + 1 
    end if 
end for 
 
puts(1, "Sorting and writing the result to the file...\n") 
for x = 1 to length(unique_words) by 2 do 
    pairs = append(pairs, {unique_words[x], unique_words[x + 1]}) 
end for 
 
fn = open("words.txt","w") 
puts(fn, "All words: " & sprint(l) & "\n") 
puts(fn, "Unique words: " & sprint(length(pairs)) & "\n\n") 
 
sequence sorted_pairs = custom_sort( routine_id("by_ilosc"), pairs) 
 
for x = 1 to length(sorted_pairs) do 
    puts(fn, to_string(sorted_pairs[x][1]) & " - " & sprint(sorted_pairs[x][2]) & "\n") 
end for 
close(fn) 
puts(1, "Done!\n") 

However, when I try to compile it I get an error:

C:\Program Files (x86)\Phix\pilx86.e:4372 in function jskip() 
attempt to subscript an atom 
    skip = 2 
    noofitems = <novalue> 
    skiptgt = 593 
    mergeSet = 3 
    waspc = 520 
    xpc = <novalue> 
... called from C:\Program Files (x86)\Phix\pilx86.e:4486 in function jend() 
    ilen = 8 
    k = <novalue> 
    jcode = <novalue> 
 
Global & Local Variables 
 
--> see /home/tom/Documents/Rozne/Coding/Euphoria/ex.err 

The ex.err file is... 21135 lines long. BTW I'm using Linux, so the C:\Program Files (x86)\Phix\pilx86.e part is another mystery for me...

new topic     » topic index » view message » categorize

2. Re: [Phix] Compilation error

Pirx said...

BTW I'm using Linux, so the C:\Program Files (x86)\Phix\pilx86.e part is another mystery for me...

If you can run ./p -cp (see below) you should then get corrected paths. I will take a closer look at that for the next release.

Pirx said...

C:\Program Files (x86)\Phix\pilx86.e:4372 in function jskip() 
attempt to subscript an atom 

I managed to reproduce something similar:

/home/pete/phix/pilx86.e:4372 in function jskip() 
index 87 out of bounds, reading sequence length 56 

There is something nasty going on with "exit" and "end for" which has troubled me on and off for a while now.
The opEndFor instruction fixes up a few things in the preceding opFor, hence should an unconditional exit(/opJmp) optimise away the opEndFor it all goes horribly wrong. Some of my past attempts to fix this have been less than spectacularly effective. What I think I need to do is split the opEndFor in two, with an opEndForFixup part that cannot get optimised away, if that makes any sense.

Anyway, in /home/tom/Documents/Rozne/Coding/Euphoria/pilx86.e you should find at line 4366:

--25/10/17: 
--/!* --(nope) 

change that to "--/*" and the matching "--*!/" on line 4393 to "--*/" and (re-)run ./p -cp

That should fix the immediate problem, but it may re-introduce something else. Meanwhile I will keep working on this.

Thanks,
Pete

PS: There is a deeper problem in that it works fine on Windows but not on Linux, and I need to fully investigate that as well.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu