| 1 |
link readLL1 |
| 2 |
record LL1(sel,deflt, |
| 3 |
terminals,actions, |
| 4 |
fiducials,firstFiducials, |
| 5 |
minLengRHS, |
| 6 |
start,eoi) |
| 7 |
|
| 8 |
|
| 9 |
procedure main(L) |
| 10 |
local filename,baseFilename,flags,outfile |
| 11 |
local ll1 |
| 12 |
flags := "" |
| 13 |
if L[1][1]=="-" then { |
| 14 |
flags := L[1] |
| 15 |
filename := L[2] |
| 16 |
} else { |
| 17 |
filename:=L[1] |
| 18 |
} |
| 19 |
if /filename then |
| 20 |
stop("usage: [iconx] tcll1 [flags] filename.ll1") |
| 21 |
|
| 22 |
baseFilename:=fileSuffix(filename)[1] |
| 23 |
if filename==(baseFilename||".inv") then |
| 24 |
stop("will not write output over input") |
| 25 |
|
| 26 |
ll1:=readLL1(baseFilename||".ll1") |
| 27 |
|
| 28 |
if *ll1.actions > 0 then { |
| 29 |
outfile:=open(baseFilename||".inv","r") |
| 30 |
every write("invocable \"",!ll1.actions,"\"") |
| 31 |
} |
| 32 |
|
| 33 |
end |
| 34 |
|
| 35 |
# From: filename.icn in Icon Program Library |
| 36 |
# Author: Robert J. Alexander, 5 Dec. 89 |
| 37 |
# Modified: Thomas Christopher, 12 Oct. 94 |
| 38 |
|
| 39 |
procedure fileSuffix(s,separator) |
| 40 |
local i |
| 41 |
/separator := "." |
| 42 |
i := *s + 1 |
| 43 |
every i := find(separator,s) |
| 44 |
return [s[1:i],s[(*s >= i) + 1:0] | &null] |
| 45 |
end |
| 46 |
|
| 47 |
|
| 48 |
|