"Fossies" - the Fresh Open Source Software Archive

Member "erltools/com/asnext/chop.cc" (15 May 2006, 3621 Bytes) of package /linux/misc/old/erltools-4.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "chop.cc" see the Fossies "Dox" file reference documentation.

    1 /*************************************************************************/
    2 /*                                                                       */
    3 /*        Chopper.c - Built by Eric Lavillonniere on Tandon 386 - 89    */
    4 /*                                                                       */
    5 /*************************************************************************/
    6 /* This file is part of metagen                                             
    7    
    8    Metagen is a syntaxic analyser generator with backtrack.
    9    
   10    It runs on dos and unix. It generates c code. */
   11 /* Copyright(C) 1989 Eric Lavillonniere */
   12 /*
   13    This program is free software; you can redistribute it and/or modify
   14    it under the terms of the GNU General Public License as published by
   15    the Free Software Foundation; either version 1, or (at your option)
   16    any later version.
   17    
   18    This program is distributed in the hope that it will be useful,
   19    but WITHOUT ANY WARRANTY; without even the implied warranty of
   20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   21    GNU General Public License for more details.
   22    
   23    You should have received a copy of the GNU General Public License
   24    along with this program; see the file COPYING. If not, write to 
   25    the Free Software
   26    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   27    
   28    */
   29 #include "token.h"
   30 
   31 #if defined(ON_W)
   32 #include "..\metachop\metachop.h"
   33 #else 
   34 #include "../metachop/metachop.h"
   35 #endif
   36 
   37 #include <fcntl.h>
   38 #include "asnext.h"
   39 
   40 metachop        *parser_metachop ;
   41 asnext          *parser_asnext ;
   42 char            *theFileName ;
   43 int             compiledLine = 0 ;
   44 DecompMetachop  *DecompMetachop::ptDecomp = 0 ;
   45 DecompChopb     *DecompChopb::ptDecomp = 0 ;
   46 
   47 
   48 extern "C" {
   49     
   50     /**************************************************************
   51                main
   52        ***************************************************************/
   53     extern int      cplusGen ;  /* c++ generation */ 
   54     int             metaQuick ; /* quick version */ 
   55     static char     name [80], *ptName ;
   56     char            *parseLanguage = (char *)0 ;
   57     
   58     PTREE TakeUseGrammar ( PTREE tree )
   59     {
   60         return (PTREE)0 ;
   61     }
   62 }
   63 
   64 void ChopTree ( PTREE tree )
   65 {
   66     cplusGen = 1 ;
   67     decomp_metachop(tree);
   68     WriteString("/*Well done my boy */ ");
   69     NewLine();
   70 }
   71 
   72 int main ( int argc, char **argv )
   73 {
   74     PTREE           tree ;
   75     char            name [50];
   76     char            *ptName ;
   77     DecompMetachop  decomp ;
   78     
   79     MetaInit();
   80     asnext () . AsLanguage();
   81     metachop () . AsLanguage ();
   82     DecompMetachop::ptDecomp = &decomp ;
   83     DecompChopb::ptDecomp = (DecompChopb *)(&decomp);
   84     DecompCplus::ptDecomp = (DecompCplus *)(&decomp);
   85     metachop () . AsLanguage ();
   86     ReadIncludeS("c.set", 1);
   87     cplusGen = metaQuick = 0 ;
   88 follow : 
   89     if ( !strcmp(*(argv + 1), "-c++") ) {
   90         cplusGen = 1 ;
   91         argc-- ;
   92         argv++ ;
   93         goto follow ;
   94     } else if ( !strcmp(*(argv + 1), "-f") ) {
   95         metaQuick = 1 ;
   96         argc-- ;
   97         argv++ ;
   98         goto follow ;
   99     }
  100     if ( argc < 2 ) {
  101         sprintf(name, "Bad name for your source file \n");
  102         write(2, name, strlen(name));
  103         exit(0);
  104     } else {
  105         theFileName = ptName = *(argv + 1);
  106     }
  107     tree = metachop () . ReadFile (ptName);
  108     AddRef(tree);
  109     ChopTree(tree);
  110     MetaEnd();
  111     if ( !firstError ) 
  112         return 1 ;
  113     else 
  114         return 0 ;
  115 }
  116 
  117 int AllReadyLoaded ( PPTREE tree )
  118 {
  119     return 1 ;
  120 }