File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / bird2 / conf / gen_parser.m4
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Oct 21 16:03:56 2019 UTC (4 years, 11 months ago) by misho
Branches: bird2, MAIN
CVS tags: v2_0_7p0, HEAD
bird2 ver 2.0.7

    1: m4_divert(-1)m4_dnl
    2: #
    3: #	BIRD -- Generator of Configuration Grammar
    4: #
    5: #	(c) 1998--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
    6: #
    7: #	Can be freely distributed and used under the terms of the GNU GPL.
    8: #
    9: 
   10: # Diversions used:
   11: #	1	includes
   12: #	2	types etc.
   13: #	3	rules
   14: #	4	C code
   15: 
   16: # Common aliases
   17: m4_define(DNL, `m4_dnl')
   18: 
   19: # Define macros for defining sections
   20: m4_define(CF_ZONE, `m4_divert($1)/* $2 from m4___file__ */')
   21: m4_define(CF_HDR, `CF_ZONE(1, Headers)')
   22: m4_define(CF_DEFINES, `CF_ZONE(1, Defines)')
   23: m4_define(CF_DECLS, `CF_ZONE(2, Declarations)')
   24: m4_define(CF_GRAMMAR, `CF_ZONE(3, Grammar)')
   25: m4_define(CF_CODE, `CF_ZONE(4, C Code)')
   26: m4_define(CF_END, `m4_divert(-1)')
   27: 
   28: # Simple iterator
   29: m4_define(CF_itera, `m4_ifelse($#, 1, [[CF_iter($1)]], [[CF_iter($1)[[]]CF_itera(m4_shift($@))]])')
   30: m4_define(CF_iterate, `m4_define([[CF_iter]], m4_defn([[$1]]))CF_itera($2)')
   31: 
   32: # Keywords act as untyped %token
   33: m4_define(CF_keywd, `m4_ifdef([[CF_tok_$1]],,[[m4_define([[CF_tok_$1]],1)m4_define([[CF_toks]],CF_toks $1)]])')
   34: m4_define(CF_KEYWORDS, `m4_define([[CF_toks]],[[]])CF_iterate([[CF_keywd]], [[$@]])m4_ifelse(CF_toks,,,%token[[]]CF_toks
   35: )DNL')
   36: 
   37: # CLI commands
   38: m4_define(CF_CLI, `m4_define([[CF_cmd]], cmd_[[]]m4_translit($1, [[ ]], _))DNL
   39: m4_divert(2)CF_KEYWORDS(m4_translit($1, [[ ]], [[,]]))
   40: m4_divert(3)cli_cmd: CF_cmd
   41: CF_cmd: $1 $2 END')
   42: m4_define(CF_CLI_CMD, `')
   43: m4_define(CF_CLI_HELP, `')
   44: 
   45: # ENUM declarations are ignored
   46: m4_define(CF_ENUM, `')
   47: 
   48: # After all configuration templates end, we finally generate the grammar file.
   49: m4_m4wrap(`
   50: m4_divert(0)DNL
   51: %{
   52: m4_undivert(1)DNL
   53: %}
   54: 
   55: m4_undivert(2)DNL
   56: 
   57: %%
   58: m4_undivert(3)DNL
   59: 
   60: %%
   61: m4_undivert(4)DNL
   62: ')
   63: 
   64: # As we are processing C source, we must access all M4 primitives via
   65: # m4_* and also set different quoting convention: `[[' and ']]'
   66: m4_changequote([[,]])

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>