lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


 > How about making a "competition" or a quest for the perfect switch  
 > (if there is one) right here on the mailing list?

Have at it!  Here's a sample from Lua-2.5+nw.  Since Lua's syntax was
inspired by Pascal, I took my inspiration from Modula-3.

  globmatch a of
  | "-e" => dostring(List.get(argv))
  | "-internal" => markup = Stages.markup; nt = Stages.nt
  | "-external" => markup = libFile("markup"); nt = libFile("nt")
  | "-v" => verbose = 1
  | "-ml", "-m3", "-awk", "-icn", "-icon", "-pascal", 
    "-c", "-c++", "-f77", "-f90", "-tex" =>
             -- deliberately ignore nountangle args
  | "-t" => -- this is the default
  | "-t*" =>   -- copy tabs at markup, use width given in notangle
	      List.put(markopt, "-t")
      	      List.put(opt, a)
  | "-filter" => List.put(filters, MD.stringFilter(List.get(argv)))
  | "-ifilter" =>
      local stagearg = List.get(argv)
      dostring("if 1 then local f, arg = " .. stagearg .. 
               "; if not f then error('no tangle: Stage ' .. " ..
                    format('%q', stagearg) .. 
                    " .. ' does not exist for -ifilter') end" ..
               "; List.put(filters, MPipe.filter(f, arg)) end")
  | "-markup" => markup = List.get(argv)
  | "-w[0-9]", "-w[0-9][0-9]*" =>  -- ignore arg meant for nountangle
  | "-L*" => List.put(markopt, "-t"); List.put(opt, "-t"); List.put(opt, a)
  | "-"   => List.put(arg, a)
  | "-cpif", "-cp" => List.put(opt, a); List.put(opt, List.get(argv))
  | "-*"  => List.put(opt, a)
  | "*"   => List.put(arg, a)
  else => error("This can't happen! Arg did not match *: " .. a)
  end

The implementation should be downloadable from
   http://www.eecs.harvard.edu/~nr/noweb/alphacur.zip
I believe there's a manual and everything :-)

 > btw, about " failed experiments with extensible syntax in the 1960s",  
 > what exactly did you mean?   How did they fail and would the IT  
 > environment still be similar, or changed enough?

I'm not old enough to have the info at my fingertips, but Ned Irons,
Tom Cheatham, and others did lots of experiments with extensible
syntax.  The short version of the problem is that nobody could read
any of the programs.  For the longer version, a good person to ask
would be John Levine, who moderates comp.compilers.


Norman