home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume12 / cake / part06 / Lib / Grammar < prev    next >
Encoding:
Text File  |  1987-10-15  |  1.4 KB  |  52 lines

  1. $    Cakefile to handle coupled lex and yacc files.
  2.  
  3. $    This file assumes that yacc sources are in files whose names
  4. $    are of the form %_g.y (the g is for grammar) and that lex
  5. $    sources are in files whose names are of the form %_s.l (the
  6. $    s is for scanner). It assumes that yacc and lex sources occur
  7. $    in pairs, i.e. %_g.y and %_s.l for the same value of %.
  8. $    It renames the output files of yacc and lex so that they
  9. $    have the same basename as their source files, and it massages
  10. $    the generated sources using yyrepl(1). This enables one to put
  11. $    more than one parser/scanner pair in the same directory without
  12. $    conflict over yy* variables. You should define the macro TABLES
  13. $    if you wish to keep the tables generated by the -v options
  14. $    of yacc and lex.
  15.  
  16. $    This cakefile was written to work with the cakefile C and one
  17. $    of the cakefiles Main and System.
  18.  
  19. #ifdef    TABLES
  20. #define    YFLAGS    -dv
  21. #define    LFLAGS    -v
  22.  
  23. %_g.c^ %_g.h@ %_g.t:    %_g.y
  24.             yacc YFLAGS %_g.y
  25.             @mv y.tab.h %_g.h
  26.             @mv y.tab.c %_g.c
  27.             @mv y.output %_g.t
  28.             @yyrepl %_g.y %_g.c %_g.h
  29.  
  30. %_s.c^ %_s.t:        %_s.l %_g.h
  31.             lex LFLAGS %_s.l > %_s.t
  32.             @mv lex.yy.c %_s.c
  33.             @yyrepl %_g.y %_s.c
  34. #else
  35. #define    YFLAGS    -d
  36. #define    LFLAGS
  37.  
  38. %_g.c^ %_g.h@:        %_g.y
  39.             yacc YFLAGS %_g.y
  40.             @mv y.tab.h %_g.h
  41.             @mv y.tab.c %_g.c
  42.             @yyrepl %_g.y %_g.c %_g.h
  43.  
  44. %_s.c^:            %_s.l %_g.h
  45.             lex LFLAGS %_s.l
  46.             @mv lex.yy.c %_s.c
  47.             @yyrepl %_g.y %_s.c
  48. #endif
  49.  
  50. #define    USE_YACC
  51. #define    USE_LEX
  52.