[Phix] Compilation error
- Posted by Pirx Aug 26, 2018
- 1353 views
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...