Alien-LibJIT
view release on metacpan or search on metacpan
libjit/dpas/dpas-scanner.l view on Meta::CPAN
%{
/*
* dpas-scanner.l - Input file for lex for the Dynamic Pascal token syntax.
*
* Copyright (C) 2004 Southern Storm Software, Pty Ltd.
*
* This file is part of the libjit library.
*
* The libjit library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 2.1 of
* the License, or (at your option) any later version.
*
* The libjit library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the libjit library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "dpas-internal.h"
#include "dpas-parser.h"
#include <config.h>
#ifndef HAVE_UNISTD_H
# define YY_NO_UNISTD_H
#endif
extern YYSTYPE yylval;
/*
* Current file and line number.
*/
char *dpas_filename = "";
long dpas_linenum = 1;
/*
* Return a token code from the lexical analyser.
*/
#define RETURNTOK(x) return (x)
/*
* Parse a string value.
*/
static char *dpas_parse_string(const char *text)
{
int quote = *text++;
char *str = (char *)jit_malloc(jit_strlen(text));
char *temp;
if(!str)
{
dpas_out_of_memory();
}
temp = str;
while(*text != '\0')
{
if(text[0] == quote && text[1] == quote)
{
*temp++ = (char)quote;
text += 2;
}
else if(text[0] == quote)
{
break;
}
else
{
*temp++ = *text++;
}
}
*temp = '\0';
return str;
}
/*
* Parse a floating-point value.
*/
static jit_nfloat dpas_parse_float(const char *text)
( run in 0.754 second using v1.01-cache-2.11-cpan-df04353d9ac )