mmsp_lex.l revision cee0fb94c0d4227de0a00efc162fb2739844b641
%{
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* A scanner for SAM Media Manager Protocol
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mmsp_yacc.h>
#define YYSTYPE mms_stype_t
#include <mms_list.h>
#include <mms_sym.h>
#include <mms_parser.h>
#include <mms_par_impl.h>
/*
* Redefine yylex to accept a pointer to the work area
*/
#define SAVE_TOKEN(src) { \
int len; \
len = MMS_PAR_MAX_TOKEN; \
} \
}
%}
DIGIT ([+-]*[0-9]+)
DECNUM_STR ((\"[\+-]*[0-9]+\")|('[\+-]*[0-9]+'))
WORD ([a-zA-Z][a-zA-Z0-9_]*)
STRING ((\"[^"]*\")|(\'[^']*\'))
BADSTRING ((\"[^"]+)|(\'[^']+))
RANGE (\.\.)
MMP_COMMENT (#[^\n]*)
%%
{RANGE} {
return (RANGE);
}
{DECNUM_STR} {
"MMS_PAR_MAX_TOKEN");
return (ERR_TOKEN_TOO_BIG);
}
return (NUMERIC_STR);
}
{DECNUM} {
if (yyleng > MMS_PAR_MAX_TOKEN) {
"MMS_PAR_MAX_TOKEN");
return (ERR_TOKEN_TOO_BIG);
}
return (NUMERIC);
}
{WORD} {
if (yyleng > MMS_PAR_MAX_TOKEN) {
"MMS_PAR_MAX_TOKEN");
return (ERR_TOKEN_TOO_BIG);
}
/* Error code may be any word */
return (ERROR_CODE);
}
return (UNKNOWN_KEYWORD);
}
}
{STRING} {
/* Remove the enclosing quotes */
"MMS_PAR_MAX_TOKEN");
return (ERR_TOKEN_TOO_BIG);
}
/* Error code may be any string */
return (ERROR_CODE);
}
/* Looking for a keyword or an objectname */
mms_pwka);
}
}
return (STRING);
}
{BADSTRING} {
return (NO_ENDING_QUOTE);
}
\xfe {
"too many characters");
return (INCORRECT_INPUT_SIZE);
}
" "|\t|\r {
/* discard white spaces */
mms_pwka->par_wka_col++;
}
\n {
mms_pwka->par_wka_line++;
}
. {
mms_pwka->par_wka_col++;
return (yytext[0]);
}
%%
static YY_BUFFER_STATE mmsp_buffer;
void
mms_mmsp_scan_string(char *str)
{
}
void
{
}