Differences between revisions 1 and 2
Revision 1 as of 2007-05-23 22:44:07
Size: 2989
Editor: KenSchalk
Comment:
Revision 2 as of 2016-05-17 02:41:06
Size: 2989
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

Check out the new VestaSDL parser! (It's just a quick edit of the C++ parser.)

   1 // Copyright (C) 2001, Compaq Computer Corporation
   2 // 
   3 // This file is part of Vesta.
   4 // 
   5 // Vesta is free software; you can redistribute it and/or
   6 // modify it under the terms of the GNU Lesser General Public
   7 // License as published by the Free Software Foundation; either
   8 // version 2.1 of the License, or (at your option) any later version.
   9 // 
  10 // Vesta is distributed in the hope that it will be useful,
  11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13 // Lesser General Public License for more details.
  14 // 
  15 // You should have received a copy of the GNU Lesser General Public
  16 // License along with Vesta; if not, write to the Free Software
  17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18 
  19 // Created on Wed Apr 23 09:56:40 PDT 1997 by heydon
  20 // Last modified on Wed May 23 18:41:04 EDT 2007 by ken@xorian.net
  21 //      modified on Thu Feb  5 00:53:13 PST 1998 by yuanyu
  22 //      modified on Wed Jun 11 22:42:32 PDT 1997 by heydon
  23 
  24 // bridges/lex/build.ves -- the lex(1) bridge model
  25 
  26 {
  27 // Parameters specializing this bridge to the target platform -----------------
  28 
  29   // The command to invoke.
  30   command = ./command;
  31 
  32   // The root filesystem to use for this platform (which must include
  33   // the executable named by "command").
  34   root = ./root;
  35 
  36 // Functions exported by the bridge -------------------------------------------
  37 
  38     lex(/**pk**/ in_file: NamedFile, output_name: text = "lex.yy"): NamedFile
  39     /* Invoke lex(1) on the file "in_file", returning a binding
  40        that maps the name "output_name" to the output generated by
  41        lex. The argument "output_name" should not have an extension; a
  42        ".c" extension is automatically added. */
  43     {
  44         // form lex(1) command-line
  45         cmd =
  46           <command>                                  // name of executable
  47           + <"-t">                                   // "-t" writes to stdout
  48           + ./generic/binding_values(./lex/switches) // client switches
  49           + <_n(in_file)>;                           // input file
  50 
  51         // augment "." to include the lex executable and files required by lex
  52         . ++= [ root = (if _is_closure(root) then root() else root) ];
  53 
  54         // add "in_file" to working directory
  55         . ++= [ root/.WD = in_file ];
  56 
  57         // invoke lex
  58         r = _run_tool(./target_platform, cmd,
  59           /*stdin=*/ "", /*stdout_treatment=*/ "value");
  60 
  61         // construct return result
  62         return if _assert(r != ERR && r/code == 0 && r/signal == 0,
  63                           "lex failed")
  64                then [ $(output_name + ".c") = r/stdout ]
  65                else ERR;
  66     };
  67 
  68 // The bridge result itself --------------------------------------------------
  69 
  70     bridge_name = "lex";
  71     switches = [];
  72     return [ $bridge_name = [ lex, switches ] ];
  73 }