/* lexer.c - The scripting lexer. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <grub/script_sh.h>
#define yytext_ptr char *
#include "grub_script.tab.h"
#include "grub_script.yy.h"
void
{
}
void
{
}
/* Start recording all characters passing through the lexer. */
unsigned
{
{
grub_script_yyerror (parser, 0);
}
}
char *
{
int count;
char *result;
return 0;
return 0;
if (result) {
}
{
}
return result;
}
/* Record STR if input recording is enabled. */
void
{
int len;
char *old;
return;
{
{
grub_script_yyerror (parser, 0);
return;
}
}
}
/* Read next line of input if necessary, and set yyscanner buffers. */
int
const char *input)
{
int len = 0;
char *p = 0;
char *line = 0;
return 1;
{
return 1;
}
line = 0;
if (! input)
else
/* Ensure '\n' at the end. */
{
}
{
if (p)
{
p[len++] = '\n';
p[len] = '\0';
}
line = p;
}
if (! line)
{
return 1;
}
/* Prepend any left over unput-text. */
if (lexerstate->prefix)
{
if (! p)
{
return 1;
}
lexerstate->prefix = 0;
line = p;
}
if (! buffer)
{
return 1;
}
return 0;
}
struct grub_lexer_param *
{
if (!lexerstate)
return 0;
if (!lexerstate->text)
{
return 0;
}
{
return 0;
}
{
parser->lexerstate = 0;
return 0;
}
return lexerstate;
}
void
{
if (!lexerstate)
return;
}
int
struct grub_parser_param *parserstate)
{
char *str;
int token;
if (parserstate->err)
return GRUB_PARSER_TOKEN_BAD;
if (lexerstate->eof)
return GRUB_PARSER_TOKEN_EOF;
/*
* Words with environment variables, like foo${bar}baz needs
* multiple tokens to be merged into a single grub_script_arg. We
* use two variables to achieve this: lexerstate->merge_start and
* lexerstate->merge_end
*/
lexerstate->merge_start = 0;
lexerstate->merge_end = 0;
do
{
/* Empty lexerstate->text. */
if (token == GRUB_PARSER_TOKEN_BAD)
break;
/* Merging feature uses lexerstate->text instead of yytext. */
if (lexerstate->merge_start)
{
}
else
{
}
}
return GRUB_PARSER_TOKEN_BAD;
return token;
}
void
{
if (err)
grub_print_error ();
}