Annotation of src/usr.bin/mk_cmds/cmd_tbl.l, Revision 1.1
1.1 ! downsj 1: %{
! 2: /* $OpenBSD: cmd_tbl.l,v 1.1.1.1 1995/12/14 06:52:48 tholo Exp $ */
! 3:
! 4: /*-
! 5: * Copyright 1987, 1988 by the Student Information Processing Board
! 6: * of the Massachusetts Institute of Technology
! 7: *
! 8: * Permission to use, copy, modify, and distribute this software
! 9: * and its documentation for any purpose and without fee is
! 10: * hereby granted, provided that the above copyright notice
! 11: * appear in all copies and that both that copyright notice and
! 12: * this permission notice appear in supporting documentation,
! 13: * and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
! 14: * used in advertising or publicity pertaining to distribution
! 15: * of the software without specific, written prior permission.
! 16: * M.I.T. and the M.I.T. S.I.P.B. make no representations about
! 17: * the suitability of this software for any purpose. It is
! 18: * provided "as is" without express or implied warranty.
! 19: */
! 20: %}
! 21:
! 22: N [0-9]
! 23: PC [^\"]
! 24: AN [A-Z_a-z0-9]
! 25:
! 26: %{
! 27: unsigned lineno = 1;
! 28:
! 29: static l_command_table(), l_request(), l_unimplemented(), l_end(),
! 30: l_quoted_string(), l_string();
! 31: %}
! 32:
! 33: %%
! 34:
! 35: %{
! 36: /* emptied */
! 37: %}
! 38:
! 39: command_table return l_command_table();
! 40: request return l_request();
! 41: unimplemented return l_unimplemented();
! 42: end return l_end();
! 43:
! 44: [\t ] ;
! 45:
! 46: \n ++lineno;
! 47:
! 48: \"{PC}*\" return l_quoted_string();
! 49:
! 50: {AN}* return l_string();
! 51:
! 52: #.*\n ++lineno;
! 53:
! 54: . return (*yytext);
! 55:
! 56: %%
! 57:
! 58: /*
! 59: * User-subroutines section.
! 60: *
! 61: * Have to put all this stuff here so that the include file
! 62: * from YACC output can be included, since LEX doesn't allow
! 63: * an include file before the code it generates for the above
! 64: * rules.
! 65: */
! 66:
! 67: #include <string.h>
! 68: #include "y.tab.h"
! 69: /* #include "copyright.h" */
! 70:
! 71: extern char *last_token, *ds();
! 72:
! 73: static l_command_table()
! 74: {
! 75: last_token = "command_table";
! 76: return COMMAND_TABLE;
! 77: }
! 78:
! 79: static l_request()
! 80: {
! 81: last_token = "request";
! 82: return REQUEST;
! 83: }
! 84:
! 85: static l_unimplemented()
! 86: {
! 87: last_token = "unimplemented";
! 88: return UNIMPLEMENTED;
! 89: }
! 90:
! 91: static l_end()
! 92: {
! 93: last_token = "end";
! 94: return END;
! 95: }
! 96:
! 97: static l_quoted_string()
! 98: {
! 99: register char *p;
! 100: yylval.dynstr = ds(yytext+1);
! 101: if (p=strrchr(yylval.dynstr, '"'))
! 102: *p='\0';
! 103: last_token = ds(yylval.dynstr);
! 104: return STRING;
! 105: }
! 106:
! 107: static l_string()
! 108: {
! 109: yylval.dynstr = ds(yytext);
! 110: last_token = ds(yylval.dynstr);
! 111: return STRING;
! 112: }