home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / TOOLS / SHELL_IN.EXP < prev    next >
Text File  |  1996-06-04  |  2KB  |  38 lines

  1. %    $Id: shell_interface.exp,v 1.2 1994/12/08 23:53:07 duchier Exp $    
  2. module("shell")?
  3.  
  4. open("parser")?
  5.  
  6. open("tokenizer")?
  7.  
  8. module("tokenizer")?
  9.  
  10. public(next_shell_token)?
  11.  
  12. ->(next_shell_token,|(_A,;(,(=(call_once(read_new_shell_token(_B,copy_term(rest_chars))),_C),;(,(:==(_C,false),,(!,fail)),;(,(:==(_B,none),,(!,,(<<-(rest_token,"the end of the line"),=(_A,[])))),,(<<-(rest_token,`(_B)),fail)))),=(_A,[copy_term(rest_token)|`(next_shell_token)])))).
  13.  
  14. :-(read_new_shell_token(_A,_B),,(void_chars(0 => _B,rest => _C),,(!,;(,(=(_C,[]),,(!,=(_A,none))),,(token(0 => _C,_A,rest => _D),<<-(rest_chars,_D)))))).
  15.  
  16. module("parser")?
  17.  
  18. public(first_shell_parse,next_shell_parse,sh_query)?
  19.  
  20. :-(first_shell_parse(_A,_B,_C,_D,_E,_F),,(init_shell_parse,,(<<-(rest_chars,_A),,(read_new_shell_expr(next_shell_token,_G,_C,_H,_I,vars => _B),,(cond(_G,cond(:==(_H,assertion),=(_D,declaration),=(_D,sh_query)),=(_D,error)),,(=(_E,cond(:==(features(_B,"parser"),[]),false)),=(_F,:==(_I,[])))))))).
  21.  
  22. :-(next_shell_parse(_A,_B,_C,_D),,(=(_E,next_shell_token),,(read_new_expr(_E,_F,_B,_G,_H,vars => _A),,(cond(_F,cond(:==(_G,assertion),=(_C,declaration),=(_C,sh_query)),=(_C,error)),=(_D,:==(_H,[])))))).
  23.  
  24. :-(read_new_shell_expr(_A,_B,_C,_D,_E,vars => _F),;(,(expr(0 => _A,_C,mask => 0,max => 1200,rest => _G,vars => _F),,(;(,(:<(_C,string),,(=(_D,sh_query),,(=(_H,root_sort(_C)),<-(_C,`(=(@,system(_H))))))),;(,(parser_C(["."],false,_G,_E),=(_D,assertion)),,(parser_C(["?"],false,_G,_E),=(_D,sh_query)))),,(=(_B,true),!))),=(_B,false))).
  25.  
  26. :-(init_shell_parse,<<-(rest_token,"the beginning of the line")).
  27.  
  28. module("shell")?
  29.  
  30. :-(print_vars(@(vars => _A)),cond(:\==(_B: features(_A,"shell"),[]),,(=(build_write_term(_B,_A),_C),,(pretty_write(_C),nl)))).
  31.  
  32. ->(build_write_term([_A],_B),|(`(=(_A,_C)),=(_C,project(_A,_B)))).
  33.  
  34. ->(build_write_term([_A|_B],_C),|(,(`(=(_A,_D)),build_write_term(_B,_C)),=(_D,project(_A,_C)))).
  35.  
  36. :-(write_parse_error,,(nl_err,,(write_err("**** Syntax error at line ",current_line_number," near: "),,(cond(:=<(_A: copy_term(rest_token),string),write(_A),cond(:=<(_A,variable),write_err(project(1,_A)),writeq_err(project(1,_A)))),nl_err)))).
  37.  
  38.