LexerParser: move to custom directory

This commit is contained in:
Daniel Pfeifer
2017-04-28 20:26:55 +02:00
parent 8927e913f7
commit 9bad0dfcce
30 changed files with 65 additions and 41 deletions
+17
View File
@@ -0,0 +1,17 @@
/cmCommandArgumentLexer.cxx generated
/cmCommandArgumentLexer.h generated
/cmCommandArgumentParser.cxx generated
/cmCommandArgumentParserTokens.h generated
/cmDependsJavaLexer.cxx generated
/cmDependsJavaLexer.h generated
/cmDependsJavaParser.cxx generated
/cmDependsJavaParserTokens.h generated
/cmExprLexer.cxx generated
/cmExprLexer.h generated
/cmExprParser.cxx generated
/cmExprParserTokens.h generated
/cmFortranLexer.cxx generated
/cmFortranLexer.h generated
/cmFortranParser.cxx generated
/cmFortranParserTokens.h generated
/cmListFileLexer.c generated
File diff suppressed because it is too large Load Diff
+336
View File
@@ -0,0 +1,336 @@
#ifndef cmCommandArgument_yyHEADER_H
#define cmCommandArgument_yyHEADER_H 1
#define cmCommandArgument_yyIN_HEADER 1
#line 6 "cmCommandArgumentLexer.h"
#line 8 "cmCommandArgumentLexer.h"
#define FLEXINT_H 1
#define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
#define YY_FLEX_SUBMINOR_VERSION 1
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
/* end standard C headers. */
/* flex integer type definitions */
#ifndef FLEXINT_H
#define FLEXINT_H
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
#endif
#include <inttypes.h>
typedef int8_t flex_int8_t;
typedef uint8_t flex_uint8_t;
typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
/* Limits of integral types. */
#ifndef INT8_MIN
#define INT8_MIN (-128)
#endif
#ifndef INT16_MIN
#define INT16_MIN (-32767-1)
#endif
#ifndef INT32_MIN
#define INT32_MIN (-2147483647-1)
#endif
#ifndef INT8_MAX
#define INT8_MAX (127)
#endif
#ifndef INT16_MAX
#define INT16_MAX (32767)
#endif
#ifndef INT32_MAX
#define INT32_MAX (2147483647)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX (255U)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX (65535U)
#endif
#ifndef UINT32_MAX
#define UINT32_MAX (4294967295U)
#endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
/* TODO: this is always defined, so inline it */
#define yyconst const
#if defined(__GNUC__) && __GNUC__ >= 3
#define yynoreturn __attribute__((__noreturn__))
#else
#define yynoreturn
#endif
/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
typedef void* yyscan_t;
#endif
/* For convenience, these vars (plus the bison vars far below)
are macros in the reentrant scanner. */
#define yyin yyg->yyin_r
#define yyout yyg->yyout_r
#define yyextra yyg->yyextra_r
#define yyleng yyg->yyleng_r
#define yytext yyg->yytext_r
#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
{
FILE *yy_input_file;
char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
int yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
* delete it.
*/
int yy_is_our_buffer;
/* Whether this is an "interactive" input source; if so, and
* if we're using stdio for input, then we want to use getc()
* instead of fread(), to make sure we stop fetching input after
* each newline.
*/
int yy_is_interactive;
/* Whether we're considered to be at the beginning of a line.
* If so, '^' rules will be active on the next match, otherwise
* not.
*/
int yy_at_bol;
int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
int yy_fill_buffer;
int yy_buffer_status;
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
void cmCommandArgument_yyrestart (FILE *input_file ,yyscan_t yyscanner );
void cmCommandArgument_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
YY_BUFFER_STATE cmCommandArgument_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
void cmCommandArgument_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void cmCommandArgument_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void cmCommandArgument_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
void cmCommandArgument_yypop_buffer_state (yyscan_t yyscanner );
YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE cmCommandArgument_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
YY_BUFFER_STATE cmCommandArgument_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
void *cmCommandArgument_yyalloc (yy_size_t ,yyscan_t yyscanner );
void *cmCommandArgument_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
void cmCommandArgument_yyfree (void * ,yyscan_t yyscanner );
/* Begin user sect3 */
#define cmCommandArgument_yywrap(yyscanner) (/*CONSTCOND*/1)
#define YY_SKIP_YYWRAP
#define yytext_ptr yytext_r
#ifdef YY_HEADER_EXPORT_START_CONDITIONS
#define INITIAL 0
#define ESCAPES 1
#define NOESCAPES 2
#endif
#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif
int cmCommandArgument_yylex_init (yyscan_t* scanner);
int cmCommandArgument_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
int cmCommandArgument_yylex_destroy (yyscan_t yyscanner );
int cmCommandArgument_yyget_debug (yyscan_t yyscanner );
void cmCommandArgument_yyset_debug (int debug_flag ,yyscan_t yyscanner );
YY_EXTRA_TYPE cmCommandArgument_yyget_extra (yyscan_t yyscanner );
void cmCommandArgument_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
FILE *cmCommandArgument_yyget_in (yyscan_t yyscanner );
void cmCommandArgument_yyset_in (FILE * _in_str ,yyscan_t yyscanner );
FILE *cmCommandArgument_yyget_out (yyscan_t yyscanner );
void cmCommandArgument_yyset_out (FILE * _out_str ,yyscan_t yyscanner );
int cmCommandArgument_yyget_leng (yyscan_t yyscanner );
char *cmCommandArgument_yyget_text (yyscan_t yyscanner );
int cmCommandArgument_yyget_lineno (yyscan_t yyscanner );
void cmCommandArgument_yyset_lineno (int _line_number ,yyscan_t yyscanner );
int cmCommandArgument_yyget_column (yyscan_t yyscanner );
void cmCommandArgument_yyset_column (int _column_no ,yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int cmCommandArgument_yywrap (yyscan_t yyscanner );
#else
extern int cmCommandArgument_yywrap (yyscan_t yyscanner );
#endif
#endif
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
#endif
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif
/* Number of entries by which start-condition stack grows. */
#ifndef YY_START_STACK_INCR
#define YY_START_STACK_INCR 25
#endif
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
*/
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
extern int cmCommandArgument_yylex (yyscan_t yyscanner);
#define YY_DECL int cmCommandArgument_yylex (yyscan_t yyscanner)
#endif /* !YY_DECL */
/* yy_get_previous_state - get the state just before the EOB char was reached */
#undef YY_NEW_FILE
#undef YY_FLUSH_BUFFER
#undef yy_set_bol
#undef yy_new_buffer
#undef yy_set_interactive
#undef YY_DO_BEFORE_ACTION
#ifdef YY_DECL_IS_OURS
#undef YY_DECL_IS_OURS
#undef YY_DECL
#endif
#line 127 "cmCommandArgumentLexer.in.l"
#line 335 "cmCommandArgumentLexer.h"
#undef cmCommandArgument_yyIN_HEADER
#endif /* cmCommandArgument_yyHEADER_H */
@@ -0,0 +1,139 @@
%{
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
/*
This file must be translated to C++ and modified to build everywhere.
Run flex >= 2.6 like this:
flex --nounistd -DFLEXINT_H --prefix=cmCommandArgument_yy --header-file=cmCommandArgumentLexer.h -ocmCommandArgumentLexer.cxx cmCommandArgumentLexer.in.l
Modify cmCommandArgumentLexer.cxx:
- remove trailing whitespace: sed -i 's/\s*$//' cmCommandArgumentLexer.h cmCommandArgumentLexer.cxx
- remove blank lines at end of file
- #include "cmStandardLexer.h" at the top
- add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t
*/
/* IWYU pragma: no_forward_declare yyguts_t */
#include "cmCommandArgumentParserHelper.h"
/* Replace the lexer input function. */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
{ result = yyextra->LexInput(buf, max_size); }
/* Include the set of tokens from the parser. */
#include "cmCommandArgumentParserTokens.h"
/*--------------------------------------------------------------------------*/
%}
%option reentrant
%option noyywrap
%option nounput
%pointer
%s ESCAPES
%s NOESCAPES
%%
\$ENV\{ {
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2);
return cal_ENVCURLY;
}
\$[A-Za-z0-9/_.+-]+\{ {
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2);
return cal_NCURLY;
}
@[A-Za-z0-9/_.+-]+@ {
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2);
return cal_ATNAME;
}
"${" {
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
yylvalp->str = yyextra->DCURLYVariable;
return cal_DCURLY;
}
"}" {
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
yylvalp->str = yyextra->RCURLYVariable;
return cal_RCURLY;
}
"@" {
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
yylvalp->str = yyextra->ATVariable;
return cal_AT;
}
[A-Za-z0-9/_.+-]+ {
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
return cal_NAME;
}
<ESCAPES>\\. {
if ( !yyextra->HandleEscapeSymbol(yylvalp, *(yytext+1)) )
{
return cal_ERROR;
}
return cal_SYMBOL;
}
[^\${}\\@]+ {
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
return cal_SYMBOL;
}
"$" {
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
yylvalp->str = yyextra->DOLLARVariable;
return cal_DOLLAR;
}
"{" {
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
yylvalp->str = yyextra->LCURLYVariable;
return cal_LCURLY;
}
<ESCAPES>"\\" {
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
yylvalp->str = yyextra->BSLASHVariable;
return cal_BSLASH;
}
<NOESCAPES>"\\" {
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
yylvalp->str = yyextra->BSLASHVariable;
return cal_SYMBOL;
}
%%
/*--------------------------------------------------------------------------*/
void cmCommandArgument_SetupEscapes(yyscan_t yyscanner, bool noEscapes)
{
/* Hack into the internal flex-generated scanner to set the state. */
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if(noEscapes) {
BEGIN(NOESCAPES);
} else {
BEGIN(ESCAPES);
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,191 @@
%{
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
/*
This file must be translated to C and modified to build everywhere.
Run bison like this:
bison --yacc --name-prefix=cmCommandArgument_yy --defines=cmCommandArgumentParserTokens.h -ocmCommandArgumentParser.cxx cmCommandArgumentParser.y
Modify cmCommandArgumentParser.cxx:
- "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"]
*/
#include "cmConfigure.h" // IWYU pragma: keep
#include <string.h>
#define yyGetParser (cmCommandArgument_yyget_extra(yyscanner))
/* Make sure malloc and free are available on QNX. */
#ifdef __QNX__
# include <malloc.h>
#endif
/* Make sure the parser uses standard memory allocation. The default
generated parser malloc/free declarations do not work on all
platforms. */
#include <stdlib.h>
#define YYMALLOC malloc
#define YYFREE free
/*-------------------------------------------------------------------------*/
#include "cmCommandArgumentParserHelper.h" /* Interface to parser object. */
#include "cmCommandArgumentLexer.h" /* Interface to lexer object. */
#include "cmCommandArgumentParserTokens.h" /* Need YYSTYPE for YY_DECL. */
/* Forward declare the lexer entry point. */
YY_DECL;
/* Helper function to forward error callback from parser. */
static void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message);
/* Configure the parser to support large input. */
#define YYMAXDEPTH 100000
#define YYINITDEPTH 10000
/* Disable some warnings in the generated code. */
#ifdef _MSC_VER
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch statement contains default but no
case. */
# pragma warning (disable: 4244) /* loss of precision */
# pragma warning (disable: 4702) /* unreachable code */
#endif
%}
/* Generate a reentrant parser object. */
%define api.pure
/* Configure the parser to use a lexer object. */
%lex-param {yyscan_t yyscanner}
%parse-param {yyscan_t yyscanner}
%define parse.error verbose
/*
%union {
char* string;
}
*/
/*-------------------------------------------------------------------------*/
/* Tokens */
%token cal_ENVCURLY
%token cal_NCURLY
%token cal_DCURLY
%token cal_DOLLAR "$"
%token cal_LCURLY "{"
%token cal_RCURLY "}"
%token cal_NAME
%token cal_BSLASH "\\"
%token cal_SYMBOL
%token cal_AT "@"
%token cal_ERROR
%token cal_ATNAME
/*-------------------------------------------------------------------------*/
/* grammar */
%%
Start:
GoalWithOptionalBackSlash {
$<str>$ = 0;
yyGetParser->SetResult($<str>1);
}
GoalWithOptionalBackSlash:
Goal {
$<str>$ = $<str>1;
}
| Goal cal_BSLASH {
$<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
}
Goal:
{
$<str>$ = 0;
}
| String Goal {
$<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
}
String:
OuterText {
$<str>$ = $<str>1;
}
| Variable {
$<str>$ = $<str>1;
}
OuterText:
cal_NAME {
$<str>$ = $<str>1;
}
| cal_AT {
$<str>$ = $<str>1;
}
| cal_DOLLAR {
$<str>$ = $<str>1;
}
| cal_LCURLY {
$<str>$ = $<str>1;
}
| cal_RCURLY {
$<str>$ = $<str>1;
}
| cal_SYMBOL {
$<str>$ = $<str>1;
}
Variable:
cal_ENVCURLY EnvVarName cal_RCURLY {
$<str>$ = yyGetParser->ExpandSpecialVariable($<str>1, $<str>2);
}
| cal_NCURLY MultipleIds cal_RCURLY {
$<str>$ = yyGetParser->ExpandSpecialVariable($<str>1, $<str>2);
}
| cal_DCURLY MultipleIds cal_RCURLY {
$<str>$ = yyGetParser->ExpandVariable($<str>2);
}
| cal_ATNAME {
$<str>$ = yyGetParser->ExpandVariableForAt($<str>1);
}
EnvVarName:
MultipleIds {
$<str>$ = $<str>1;
}
| cal_SYMBOL EnvVarName {
$<str>$ = $<str>1;
}
MultipleIds:
{
$<str>$ = 0;
}
| ID MultipleIds {
$<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
}
ID:
cal_NAME {
$<str>$ = $<str>1;
}
| Variable {
$<str>$ = $<str>1;
}
;
%%
/* End of grammar */
/*--------------------------------------------------------------------------*/
void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message)
{
yyGetParser->Error(message);
}
@@ -0,0 +1,82 @@
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED
# define YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int cmCommandArgument_yydebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
cal_ENVCURLY = 258,
cal_NCURLY = 259,
cal_DCURLY = 260,
cal_DOLLAR = 261,
cal_LCURLY = 262,
cal_RCURLY = 263,
cal_NAME = 264,
cal_BSLASH = 265,
cal_SYMBOL = 266,
cal_AT = 267,
cal_ERROR = 268,
cal_ATNAME = 269
};
#endif
/* Tokens. */
#define cal_ENVCURLY 258
#define cal_NCURLY 259
#define cal_DCURLY 260
#define cal_DOLLAR 261
#define cal_LCURLY 262
#define cal_RCURLY 263
#define cal_NAME 264
#define cal_BSLASH 265
#define cal_SYMBOL 266
#define cal_AT 267
#define cal_ERROR 268
#define cal_ATNAME 269
/* Value type. */
int cmCommandArgument_yyparse (yyscan_t yyscanner);
#endif /* !YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED */
File diff suppressed because it is too large Load Diff
+336
View File
@@ -0,0 +1,336 @@
#ifndef cmDependsJava_yyHEADER_H
#define cmDependsJava_yyHEADER_H 1
#define cmDependsJava_yyIN_HEADER 1
#line 6 "cmDependsJavaLexer.h"
#line 8 "cmDependsJavaLexer.h"
#define FLEXINT_H 1
#define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
#define YY_FLEX_SUBMINOR_VERSION 1
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
/* end standard C headers. */
/* flex integer type definitions */
#ifndef FLEXINT_H
#define FLEXINT_H
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
#endif
#include <inttypes.h>
typedef int8_t flex_int8_t;
typedef uint8_t flex_uint8_t;
typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
/* Limits of integral types. */
#ifndef INT8_MIN
#define INT8_MIN (-128)
#endif
#ifndef INT16_MIN
#define INT16_MIN (-32767-1)
#endif
#ifndef INT32_MIN
#define INT32_MIN (-2147483647-1)
#endif
#ifndef INT8_MAX
#define INT8_MAX (127)
#endif
#ifndef INT16_MAX
#define INT16_MAX (32767)
#endif
#ifndef INT32_MAX
#define INT32_MAX (2147483647)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX (255U)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX (65535U)
#endif
#ifndef UINT32_MAX
#define UINT32_MAX (4294967295U)
#endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
/* TODO: this is always defined, so inline it */
#define yyconst const
#if defined(__GNUC__) && __GNUC__ >= 3
#define yynoreturn __attribute__((__noreturn__))
#else
#define yynoreturn
#endif
/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
typedef void* yyscan_t;
#endif
/* For convenience, these vars (plus the bison vars far below)
are macros in the reentrant scanner. */
#define yyin yyg->yyin_r
#define yyout yyg->yyout_r
#define yyextra yyg->yyextra_r
#define yyleng yyg->yyleng_r
#define yytext yyg->yytext_r
#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
{
FILE *yy_input_file;
char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
int yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
* delete it.
*/
int yy_is_our_buffer;
/* Whether this is an "interactive" input source; if so, and
* if we're using stdio for input, then we want to use getc()
* instead of fread(), to make sure we stop fetching input after
* each newline.
*/
int yy_is_interactive;
/* Whether we're considered to be at the beginning of a line.
* If so, '^' rules will be active on the next match, otherwise
* not.
*/
int yy_at_bol;
int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
int yy_fill_buffer;
int yy_buffer_status;
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
void cmDependsJava_yyrestart (FILE *input_file ,yyscan_t yyscanner );
void cmDependsJava_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
YY_BUFFER_STATE cmDependsJava_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
void cmDependsJava_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void cmDependsJava_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void cmDependsJava_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
void cmDependsJava_yypop_buffer_state (yyscan_t yyscanner );
YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE cmDependsJava_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
YY_BUFFER_STATE cmDependsJava_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
void *cmDependsJava_yyalloc (yy_size_t ,yyscan_t yyscanner );
void *cmDependsJava_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
void cmDependsJava_yyfree (void * ,yyscan_t yyscanner );
/* Begin user sect3 */
#define cmDependsJava_yywrap(yyscanner) (/*CONSTCOND*/1)
#define YY_SKIP_YYWRAP
#define yytext_ptr yytext_r
#ifdef YY_HEADER_EXPORT_START_CONDITIONS
#define INITIAL 0
#define comment 1
#define string 2
#endif
#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif
int cmDependsJava_yylex_init (yyscan_t* scanner);
int cmDependsJava_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
int cmDependsJava_yylex_destroy (yyscan_t yyscanner );
int cmDependsJava_yyget_debug (yyscan_t yyscanner );
void cmDependsJava_yyset_debug (int debug_flag ,yyscan_t yyscanner );
YY_EXTRA_TYPE cmDependsJava_yyget_extra (yyscan_t yyscanner );
void cmDependsJava_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
FILE *cmDependsJava_yyget_in (yyscan_t yyscanner );
void cmDependsJava_yyset_in (FILE * _in_str ,yyscan_t yyscanner );
FILE *cmDependsJava_yyget_out (yyscan_t yyscanner );
void cmDependsJava_yyset_out (FILE * _out_str ,yyscan_t yyscanner );
int cmDependsJava_yyget_leng (yyscan_t yyscanner );
char *cmDependsJava_yyget_text (yyscan_t yyscanner );
int cmDependsJava_yyget_lineno (yyscan_t yyscanner );
void cmDependsJava_yyset_lineno (int _line_number ,yyscan_t yyscanner );
int cmDependsJava_yyget_column (yyscan_t yyscanner );
void cmDependsJava_yyset_column (int _column_no ,yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int cmDependsJava_yywrap (yyscan_t yyscanner );
#else
extern int cmDependsJava_yywrap (yyscan_t yyscanner );
#endif
#endif
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
#endif
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif
/* Number of entries by which start-condition stack grows. */
#ifndef YY_START_STACK_INCR
#define YY_START_STACK_INCR 25
#endif
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
*/
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
extern int cmDependsJava_yylex (yyscan_t yyscanner);
#define YY_DECL int cmDependsJava_yylex (yyscan_t yyscanner)
#endif /* !YY_DECL */
/* yy_get_previous_state - get the state just before the EOB char was reached */
#undef YY_NEW_FILE
#undef YY_FLUSH_BUFFER
#undef yy_set_bol
#undef yy_new_buffer
#undef yy_set_interactive
#undef YY_DO_BEFORE_ACTION
#ifdef YY_DECL_IS_OURS
#undef YY_DECL_IS_OURS
#undef YY_DECL
#endif
#line 174 "cmDependsJavaLexer.in.l"
#line 335 "cmDependsJavaLexer.h"
#undef cmDependsJava_yyIN_HEADER
#endif /* cmDependsJava_yyHEADER_H */
+174
View File
@@ -0,0 +1,174 @@
%{
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
/*
This file must be translated to C++ and modified to build everywhere.
Run flex >= 2.6 like this:
flex --nounistd -DFLEXINT_H --prefix=cmDependsJava_yy --header-file=cmDependsJavaLexer.h -ocmDependsJavaLexer.cxx cmDependsJavaLexer.in.l
Modify cmDependsJavaLexer.cxx:
- remove trailing whitespace: sed -i 's/\s*$//' cmDependsJavaLexer.h cmDependsJavaLexer.cxx
- remove blank lines at end of file
- #include "cmStandardLexer.h" at the top
- add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t
*/
/* IWYU pragma: no_forward_declare yyguts_t */
#include <iostream>
#include "cmDependsJavaParserHelper.h"
/* Replace the lexer input function. */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
{ result = yyextra->LexInput(buf, max_size); }
/* Include the set of tokens from the parser. */
#include "cmDependsJavaParserTokens.h"
#define KEYWORD yylvalp->str = 0
#define SYMBOL yylvalp->str = 0
#define PRIMITIVE yylvalp->str = 0
/*--------------------------------------------------------------------------*/
%}
%option reentrant
%option noyywrap
%pointer
%x comment
%x string
%%
"/*" { BEGIN(comment); }
<comment>"*/" { BEGIN(INITIAL); }
<comment>.|\n {}
\" { BEGIN(string); }
<string>\" { BEGIN(INITIAL); return jp_STRINGLITERAL; }
<string>. {}
abstract { KEYWORD; return jp_ABSTRACT; }
assert { KEYWORD; return jp_ASSERT; }
boolean { KEYWORD; return jp_BOOLEAN_TYPE; }
break { KEYWORD; return jp_BREAK; }
byte { KEYWORD; return jp_BYTE_TYPE; }
case { KEYWORD; return jp_CASE; }
catch { KEYWORD; return jp_CATCH; }
char { KEYWORD; return jp_CHAR_TYPE; }
class { KEYWORD; return jp_CLASS; }
continue { KEYWORD; return jp_CONTINUE; }
default { KEYWORD; return jp_DEFAULT; }
do { KEYWORD; return jp_DO; }
double { KEYWORD; return jp_DOUBLE_TYPE; }
else { KEYWORD; return jp_ELSE; }
extends { KEYWORD; return jp_EXTENDS; }
final { KEYWORD; return jp_FINAL; }
finally { KEYWORD; return jp_FINALLY; }
float { KEYWORD; return jp_FLOAT_TYPE; }
for { KEYWORD; return jp_FOR; }
if { KEYWORD; return jp_IF; }
implements { KEYWORD; return jp_IMPLEMENTS; }
import { KEYWORD; return jp_IMPORT; }
instanceof { KEYWORD; return jp_INSTANCEOF; }
int { KEYWORD; return jp_INT_TYPE; }
interface { KEYWORD; return jp_INTERFACE; }
long { KEYWORD; return jp_LONG_TYPE; }
native { KEYWORD; return jp_NATIVE; }
new { KEYWORD; return jp_NEW; }
package { KEYWORD; return jp_PACKAGE; }
private { KEYWORD; return jp_PRIVATE; }
protected { KEYWORD; return jp_PROTECTED; }
public { KEYWORD; return jp_PUBLIC; }
return { KEYWORD; return jp_RETURN; }
short { KEYWORD; return jp_SHORT_TYPE; }
static { KEYWORD; return jp_STATIC; }
strictfp { KEYWORD; return jp_STRICTFP; }
super { KEYWORD; return jp_SUPER; }
switch { KEYWORD; return jp_SWITCH; }
synchronized { KEYWORD; return jp_SYNCHRONIZED; }
this { KEYWORD; return jp_THIS; }
throw { KEYWORD; return jp_THROW; }
throws { KEYWORD; return jp_THROWS; }
transient { KEYWORD; return jp_TRANSIENT; }
try { KEYWORD; return jp_TRY; }
void { KEYWORD; return jp_VOID; }
volatile { KEYWORD; return jp_VOLATILE; }
while { KEYWORD; return jp_WHILE; }
(true|false) { PRIMITIVE; return jp_BOOLEANLITERAL; }
\'([^\\]|\\.|\\u[0-9a-fA-F]*|\\[0-7]*)\' { PRIMITIVE; return jp_CHARACTERLITERAL; }
(0|[0-9]+)[lL]? { PRIMITIVE; return jp_DECIMALINTEGERLITERAL; }
([0-9]+\.[0-9]*|\.[0-9]+|[0-9]+)([eE][+\-]?[0-9]+)?[fFdD]? { PRIMITIVE; return jp_FLOATINGPOINTLITERAL; }
0[xX][0-9a-fA-F]+[lL]? { PRIMITIVE; return jp_HEXINTEGERLITERAL; }
null { PRIMITIVE; return jp_NULLLITERAL; }
"&" { SYMBOL; return jp_AND; }
"&&" { SYMBOL; return jp_ANDAND; }
"&=" { SYMBOL; return jp_ANDEQUALS; }
"\]" { SYMBOL; return jp_BRACKETEND; }
"\[" { SYMBOL; return jp_BRACKETSTART; }
"\^" { SYMBOL; return jp_CARROT; }
"\^=" { SYMBOL; return jp_CARROTEQUALS; }
":" { SYMBOL; return jp_COLON; }
"," { SYMBOL; return jp_COMMA; }
"}" { SYMBOL; return jp_CURLYEND; }
"{" { SYMBOL; return jp_CURLYSTART; }
"/" { SYMBOL; return jp_DIVIDE; }
"/=" { SYMBOL; return jp_DIVIDEEQUALS; }
"\$" { SYMBOL; return jp_DOLLAR; }
"\." { SYMBOL; return jp_DOT; }
"=" { SYMBOL; return jp_EQUALS; }
"==" { SYMBOL; return jp_EQUALSEQUALS; }
"\!" { SYMBOL; return jp_EXCLAMATION; }
"\!=" { SYMBOL; return jp_EXCLAMATIONEQUALS; }
">" { SYMBOL; return jp_GREATER; }
">=" { SYMBOL; return jp_GTEQUALS; }
">>" { SYMBOL; return jp_GTGT; }
">>=" { SYMBOL; return jp_GTGTEQUALS; }
">>>" { SYMBOL; return jp_GTGTGT; }
">>>=" { SYMBOL; return jp_GTGTGTEQUALS; }
"<<=" { SYMBOL; return jp_LESLESEQUALS; }
"<" { SYMBOL; return jp_LESSTHAN; }
"<=" { SYMBOL; return jp_LTEQUALS; }
"<<" { SYMBOL; return jp_LTLT; }
"-" { SYMBOL; return jp_MINUS; }
"-=" { SYMBOL; return jp_MINUSEQUALS; }
"--" { SYMBOL; return jp_MINUSMINUS; }
"\)" { SYMBOL; return jp_PAREEND; }
"\(" { SYMBOL; return jp_PARESTART; }
"%" { SYMBOL; return jp_PERCENT; }
"%=" { SYMBOL; return jp_PERCENTEQUALS; }
"\|" { SYMBOL; return jp_PIPE; }
"\|=" { SYMBOL; return jp_PIPEEQUALS; }
"\|\|" { SYMBOL; return jp_PIPEPIPE; }
"\+" { SYMBOL; return jp_PLUS; }
"\+=" { SYMBOL; return jp_PLUSEQUALS; }
"\+\+" { SYMBOL; return jp_PLUSPLUS; }
"\?" { SYMBOL; return jp_QUESTION; }
";" { SYMBOL; return jp_SEMICOL; }
"\~" { SYMBOL; return jp_TILDE; }
"\*" { SYMBOL; return jp_TIMES; }
"\*=" { SYMBOL; return jp_TIMESEQUALS; }
[a-z_A-Z][a-z_0-9A-Z]* {
yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
return jp_NAME;
}
\/\/.*\n { }
[ \f\t\n\r] { }
. {
std::cerr << "Unknown character: " << yytext[0]
<< " (" << (int)yytext[0] << ")" << std::endl;
yyextra->Error("Unknown character");
return jp_ERROR;
}
%%
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,264 @@
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_CMDEPENDSJAVA_YY_CMDEPENDSJAVAPARSERTOKENS_H_INCLUDED
# define YY_CMDEPENDSJAVA_YY_CMDEPENDSJAVAPARSERTOKENS_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int cmDependsJava_yydebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
jp_ABSTRACT = 258,
jp_ASSERT = 259,
jp_BOOLEAN_TYPE = 260,
jp_BREAK = 261,
jp_BYTE_TYPE = 262,
jp_CASE = 263,
jp_CATCH = 264,
jp_CHAR_TYPE = 265,
jp_CLASS = 266,
jp_CONTINUE = 267,
jp_DEFAULT = 268,
jp_DO = 269,
jp_DOUBLE_TYPE = 270,
jp_ELSE = 271,
jp_EXTENDS = 272,
jp_FINAL = 273,
jp_FINALLY = 274,
jp_FLOAT_TYPE = 275,
jp_FOR = 276,
jp_IF = 277,
jp_IMPLEMENTS = 278,
jp_IMPORT = 279,
jp_INSTANCEOF = 280,
jp_INT_TYPE = 281,
jp_INTERFACE = 282,
jp_LONG_TYPE = 283,
jp_NATIVE = 284,
jp_NEW = 285,
jp_PACKAGE = 286,
jp_PRIVATE = 287,
jp_PROTECTED = 288,
jp_PUBLIC = 289,
jp_RETURN = 290,
jp_SHORT_TYPE = 291,
jp_STATIC = 292,
jp_STRICTFP = 293,
jp_SUPER = 294,
jp_SWITCH = 295,
jp_SYNCHRONIZED = 296,
jp_THIS = 297,
jp_THROW = 298,
jp_THROWS = 299,
jp_TRANSIENT = 300,
jp_TRY = 301,
jp_VOID = 302,
jp_VOLATILE = 303,
jp_WHILE = 304,
jp_BOOLEANLITERAL = 305,
jp_CHARACTERLITERAL = 306,
jp_DECIMALINTEGERLITERAL = 307,
jp_FLOATINGPOINTLITERAL = 308,
jp_HEXINTEGERLITERAL = 309,
jp_NULLLITERAL = 310,
jp_STRINGLITERAL = 311,
jp_NAME = 312,
jp_AND = 313,
jp_ANDAND = 314,
jp_ANDEQUALS = 315,
jp_BRACKETEND = 316,
jp_BRACKETSTART = 317,
jp_CARROT = 318,
jp_CARROTEQUALS = 319,
jp_COLON = 320,
jp_COMMA = 321,
jp_CURLYEND = 322,
jp_CURLYSTART = 323,
jp_DIVIDE = 324,
jp_DIVIDEEQUALS = 325,
jp_DOLLAR = 326,
jp_DOT = 327,
jp_EQUALS = 328,
jp_EQUALSEQUALS = 329,
jp_EXCLAMATION = 330,
jp_EXCLAMATIONEQUALS = 331,
jp_GREATER = 332,
jp_GTEQUALS = 333,
jp_GTGT = 334,
jp_GTGTEQUALS = 335,
jp_GTGTGT = 336,
jp_GTGTGTEQUALS = 337,
jp_LESLESEQUALS = 338,
jp_LESSTHAN = 339,
jp_LTEQUALS = 340,
jp_LTLT = 341,
jp_MINUS = 342,
jp_MINUSEQUALS = 343,
jp_MINUSMINUS = 344,
jp_PAREEND = 345,
jp_PARESTART = 346,
jp_PERCENT = 347,
jp_PERCENTEQUALS = 348,
jp_PIPE = 349,
jp_PIPEEQUALS = 350,
jp_PIPEPIPE = 351,
jp_PLUS = 352,
jp_PLUSEQUALS = 353,
jp_PLUSPLUS = 354,
jp_QUESTION = 355,
jp_SEMICOL = 356,
jp_TILDE = 357,
jp_TIMES = 358,
jp_TIMESEQUALS = 359,
jp_ERROR = 360
};
#endif
/* Tokens. */
#define jp_ABSTRACT 258
#define jp_ASSERT 259
#define jp_BOOLEAN_TYPE 260
#define jp_BREAK 261
#define jp_BYTE_TYPE 262
#define jp_CASE 263
#define jp_CATCH 264
#define jp_CHAR_TYPE 265
#define jp_CLASS 266
#define jp_CONTINUE 267
#define jp_DEFAULT 268
#define jp_DO 269
#define jp_DOUBLE_TYPE 270
#define jp_ELSE 271
#define jp_EXTENDS 272
#define jp_FINAL 273
#define jp_FINALLY 274
#define jp_FLOAT_TYPE 275
#define jp_FOR 276
#define jp_IF 277
#define jp_IMPLEMENTS 278
#define jp_IMPORT 279
#define jp_INSTANCEOF 280
#define jp_INT_TYPE 281
#define jp_INTERFACE 282
#define jp_LONG_TYPE 283
#define jp_NATIVE 284
#define jp_NEW 285
#define jp_PACKAGE 286
#define jp_PRIVATE 287
#define jp_PROTECTED 288
#define jp_PUBLIC 289
#define jp_RETURN 290
#define jp_SHORT_TYPE 291
#define jp_STATIC 292
#define jp_STRICTFP 293
#define jp_SUPER 294
#define jp_SWITCH 295
#define jp_SYNCHRONIZED 296
#define jp_THIS 297
#define jp_THROW 298
#define jp_THROWS 299
#define jp_TRANSIENT 300
#define jp_TRY 301
#define jp_VOID 302
#define jp_VOLATILE 303
#define jp_WHILE 304
#define jp_BOOLEANLITERAL 305
#define jp_CHARACTERLITERAL 306
#define jp_DECIMALINTEGERLITERAL 307
#define jp_FLOATINGPOINTLITERAL 308
#define jp_HEXINTEGERLITERAL 309
#define jp_NULLLITERAL 310
#define jp_STRINGLITERAL 311
#define jp_NAME 312
#define jp_AND 313
#define jp_ANDAND 314
#define jp_ANDEQUALS 315
#define jp_BRACKETEND 316
#define jp_BRACKETSTART 317
#define jp_CARROT 318
#define jp_CARROTEQUALS 319
#define jp_COLON 320
#define jp_COMMA 321
#define jp_CURLYEND 322
#define jp_CURLYSTART 323
#define jp_DIVIDE 324
#define jp_DIVIDEEQUALS 325
#define jp_DOLLAR 326
#define jp_DOT 327
#define jp_EQUALS 328
#define jp_EQUALSEQUALS 329
#define jp_EXCLAMATION 330
#define jp_EXCLAMATIONEQUALS 331
#define jp_GREATER 332
#define jp_GTEQUALS 333
#define jp_GTGT 334
#define jp_GTGTEQUALS 335
#define jp_GTGTGT 336
#define jp_GTGTGTEQUALS 337
#define jp_LESLESEQUALS 338
#define jp_LESSTHAN 339
#define jp_LTEQUALS 340
#define jp_LTLT 341
#define jp_MINUS 342
#define jp_MINUSEQUALS 343
#define jp_MINUSMINUS 344
#define jp_PAREEND 345
#define jp_PARESTART 346
#define jp_PERCENT 347
#define jp_PERCENTEQUALS 348
#define jp_PIPE 349
#define jp_PIPEEQUALS 350
#define jp_PIPEPIPE 351
#define jp_PLUS 352
#define jp_PLUSEQUALS 353
#define jp_PLUSPLUS 354
#define jp_QUESTION 355
#define jp_SEMICOL 356
#define jp_TILDE 357
#define jp_TIMES 358
#define jp_TIMESEQUALS 359
#define jp_ERROR 360
/* Value type. */
int cmDependsJava_yyparse (yyscan_t yyscanner);
#endif /* !YY_CMDEPENDSJAVA_YY_CMDEPENDSJAVAPARSERTOKENS_H_INCLUDED */
File diff suppressed because it is too large Load Diff
+334
View File
@@ -0,0 +1,334 @@
#ifndef cmExpr_yyHEADER_H
#define cmExpr_yyHEADER_H 1
#define cmExpr_yyIN_HEADER 1
#line 6 "cmExprLexer.h"
#line 8 "cmExprLexer.h"
#define FLEXINT_H 1
#define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
#define YY_FLEX_SUBMINOR_VERSION 1
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
/* end standard C headers. */
/* flex integer type definitions */
#ifndef FLEXINT_H
#define FLEXINT_H
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
#endif
#include <inttypes.h>
typedef int8_t flex_int8_t;
typedef uint8_t flex_uint8_t;
typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
/* Limits of integral types. */
#ifndef INT8_MIN
#define INT8_MIN (-128)
#endif
#ifndef INT16_MIN
#define INT16_MIN (-32767-1)
#endif
#ifndef INT32_MIN
#define INT32_MIN (-2147483647-1)
#endif
#ifndef INT8_MAX
#define INT8_MAX (127)
#endif
#ifndef INT16_MAX
#define INT16_MAX (32767)
#endif
#ifndef INT32_MAX
#define INT32_MAX (2147483647)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX (255U)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX (65535U)
#endif
#ifndef UINT32_MAX
#define UINT32_MAX (4294967295U)
#endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
/* TODO: this is always defined, so inline it */
#define yyconst const
#if defined(__GNUC__) && __GNUC__ >= 3
#define yynoreturn __attribute__((__noreturn__))
#else
#define yynoreturn
#endif
/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
typedef void* yyscan_t;
#endif
/* For convenience, these vars (plus the bison vars far below)
are macros in the reentrant scanner. */
#define yyin yyg->yyin_r
#define yyout yyg->yyout_r
#define yyextra yyg->yyextra_r
#define yyleng yyg->yyleng_r
#define yytext yyg->yytext_r
#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
{
FILE *yy_input_file;
char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
int yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
* delete it.
*/
int yy_is_our_buffer;
/* Whether this is an "interactive" input source; if so, and
* if we're using stdio for input, then we want to use getc()
* instead of fread(), to make sure we stop fetching input after
* each newline.
*/
int yy_is_interactive;
/* Whether we're considered to be at the beginning of a line.
* If so, '^' rules will be active on the next match, otherwise
* not.
*/
int yy_at_bol;
int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
int yy_fill_buffer;
int yy_buffer_status;
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
void cmExpr_yyrestart (FILE *input_file ,yyscan_t yyscanner );
void cmExpr_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
YY_BUFFER_STATE cmExpr_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
void cmExpr_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void cmExpr_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void cmExpr_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
void cmExpr_yypop_buffer_state (yyscan_t yyscanner );
YY_BUFFER_STATE cmExpr_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE cmExpr_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
YY_BUFFER_STATE cmExpr_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
void *cmExpr_yyalloc (yy_size_t ,yyscan_t yyscanner );
void *cmExpr_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
void cmExpr_yyfree (void * ,yyscan_t yyscanner );
/* Begin user sect3 */
#define cmExpr_yywrap(yyscanner) (/*CONSTCOND*/1)
#define YY_SKIP_YYWRAP
#define yytext_ptr yytext_r
#ifdef YY_HEADER_EXPORT_START_CONDITIONS
#define INITIAL 0
#endif
#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif
int cmExpr_yylex_init (yyscan_t* scanner);
int cmExpr_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
int cmExpr_yylex_destroy (yyscan_t yyscanner );
int cmExpr_yyget_debug (yyscan_t yyscanner );
void cmExpr_yyset_debug (int debug_flag ,yyscan_t yyscanner );
YY_EXTRA_TYPE cmExpr_yyget_extra (yyscan_t yyscanner );
void cmExpr_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
FILE *cmExpr_yyget_in (yyscan_t yyscanner );
void cmExpr_yyset_in (FILE * _in_str ,yyscan_t yyscanner );
FILE *cmExpr_yyget_out (yyscan_t yyscanner );
void cmExpr_yyset_out (FILE * _out_str ,yyscan_t yyscanner );
int cmExpr_yyget_leng (yyscan_t yyscanner );
char *cmExpr_yyget_text (yyscan_t yyscanner );
int cmExpr_yyget_lineno (yyscan_t yyscanner );
void cmExpr_yyset_lineno (int _line_number ,yyscan_t yyscanner );
int cmExpr_yyget_column (yyscan_t yyscanner );
void cmExpr_yyset_column (int _column_no ,yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int cmExpr_yywrap (yyscan_t yyscanner );
#else
extern int cmExpr_yywrap (yyscan_t yyscanner );
#endif
#endif
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
#endif
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif
/* Number of entries by which start-condition stack grows. */
#ifndef YY_START_STACK_INCR
#define YY_START_STACK_INCR 25
#endif
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
*/
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
extern int cmExpr_yylex (yyscan_t yyscanner);
#define YY_DECL int cmExpr_yylex (yyscan_t yyscanner)
#endif /* !YY_DECL */
/* yy_get_previous_state - get the state just before the EOB char was reached */
#undef YY_NEW_FILE
#undef YY_FLUSH_BUFFER
#undef yy_set_bol
#undef yy_new_buffer
#undef yy_set_interactive
#undef YY_DO_BEFORE_ACTION
#ifdef YY_DECL_IS_OURS
#undef YY_DECL_IS_OURS
#undef YY_DECL
#endif
#line 57 "cmExprLexer.in.l"
#line 333 "cmExprLexer.h"
#undef cmExpr_yyIN_HEADER
#endif /* cmExpr_yyHEADER_H */
+57
View File
@@ -0,0 +1,57 @@
%{
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
/*
This file must be translated to C++ and modified to build everywhere.
Run flex >= 2.6 like this:
flex --nounistd -DFLEXINT_H --prefix=cmExpr_yy --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l
Modify cmExprLexer.cxx:
- remove trailing whitespace: sed -i 's/\s*$//' cmExprLexer.h cmExprLexer.cxx
- remove blank lines at end of file
- #include "cmStandardLexer.h" at the top
- add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t
*/
/* IWYU pragma: no_forward_declare yyguts_t */
#include "cmExprParserHelper.h"
/* Replace the lexer input function. */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
{ result = yyextra->LexInput(buf, max_size); }
/* Include the set of tokens from the parser. */
#include "cmExprParserTokens.h"
/*--------------------------------------------------------------------------*/
%}
%option reentrant
%option noyywrap
%pointer
%%
[0-9][0-9]* { yylvalp->Number = atoi(yytext); return exp_NUMBER; }
"+" { return exp_PLUS; }
"-" { return exp_MINUS; }
"*" { return exp_TIMES; }
"/" { return exp_DIVIDE; }
"%" { return exp_MOD; }
"\|" { return exp_OR; }
"&" { return exp_AND; }
"^" { return exp_XOR; }
"~" { return exp_NOT; }
"<<" { return exp_SHIFTLEFT; }
">>" { return exp_SHIFTRIGHT; }
"(" { return exp_OPENPARENT; }
")" { return exp_CLOSEPARENT; }
%%
File diff suppressed because it is too large Load Diff
+164
View File
@@ -0,0 +1,164 @@
%{
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
/*
This file must be translated to C and modified to build everywhere.
Run bison like this:
bison --yacc --name-prefix=cmExpr_yy --defines=cmExprParserTokens.h -ocmExprParser.cxx cmExprParser.y
Modify cmExprParser.cxx:
- "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"]
*/
#include "cmConfigure.h" // IWYU pragma: keep
#include <stdlib.h>
#include <string.h>
/*-------------------------------------------------------------------------*/
#define YYDEBUG 1
#include "cmExprParserHelper.h" /* Interface to parser object. */
#include "cmExprLexer.h" /* Interface to lexer object. */
#include "cmExprParserTokens.h" /* Need YYSTYPE for YY_DECL. */
/* Forward declare the lexer entry point. */
YY_DECL;
/* Helper function to forward error callback from parser. */
static void cmExpr_yyerror(yyscan_t yyscanner, const char* message);
/* Disable some warnings in the generated code. */
#ifdef _MSC_VER
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch statement contains default but no case. */
#endif
%}
/* Generate a reentrant parser object. */
%define api.pure
/* Configure the parser to use a lexer object. */
%lex-param {yyscan_t yyscanner}
%parse-param {yyscan_t yyscanner}
%define parse.error verbose
/*-------------------------------------------------------------------------*/
/* Tokens */
%token exp_PLUS
%token exp_MINUS
%token exp_TIMES
%token exp_DIVIDE
%token exp_MOD
%token exp_SHIFTLEFT
%token exp_SHIFTRIGHT
%token exp_OPENPARENT
%token exp_CLOSEPARENT
%token exp_OR;
%token exp_AND;
%token exp_XOR;
%token exp_NOT;
%token exp_NUMBER;
/*-------------------------------------------------------------------------*/
/* grammar */
%%
start:
exp {
cmExpr_yyget_extra(yyscanner)->SetResult($<Number>1);
}
exp:
bitwiseor {
$<Number>$ = $<Number>1;
}
| exp exp_OR bitwiseor {
$<Number>$ = $<Number>1 | $<Number>3;
}
bitwiseor:
bitwisexor {
$<Number>$ = $<Number>1;
}
| bitwiseor exp_XOR bitwisexor {
$<Number>$ = $<Number>1 ^ $<Number>3;
}
bitwisexor:
bitwiseand {
$<Number>$ = $<Number>1;
}
| bitwisexor exp_AND bitwiseand {
$<Number>$ = $<Number>1 & $<Number>3;
}
bitwiseand:
shift {
$<Number>$ = $<Number>1;
}
| bitwiseand exp_SHIFTLEFT shift {
$<Number>$ = $<Number>1 << $<Number>3;
}
| bitwiseand exp_SHIFTRIGHT shift {
$<Number>$ = $<Number>1 >> $<Number>3;
}
shift:
term {
$<Number>$ = $<Number>1;
}
| shift exp_PLUS term {
$<Number>$ = $<Number>1 + $<Number>3;
}
| shift exp_MINUS term {
$<Number>$ = $<Number>1 - $<Number>3;
}
term:
unary {
$<Number>$ = $<Number>1;
}
| term exp_TIMES unary {
$<Number>$ = $<Number>1 * $<Number>3;
}
| term exp_DIVIDE unary {
$<Number>$ = $<Number>1 / $<Number>3;
}
| term exp_MOD unary {
$<Number>$ = $<Number>1 % $<Number>3;
}
unary:
factor {
$<Number>$ = $<Number>1;
}
| exp_PLUS unary {
$<Number>$ = + $<Number>2;
}
| exp_MINUS unary {
$<Number>$ = - $<Number>2;
}
factor:
exp_NUMBER {
$<Number>$ = $<Number>1;
}
| exp_OPENPARENT exp exp_CLOSEPARENT {
$<Number>$ = $<Number>2;
}
;
%%
/* End of grammar */
/*--------------------------------------------------------------------------*/
void cmExpr_yyerror(yyscan_t yyscanner, const char* message)
{
cmExpr_yyget_extra(yyscanner)->Error(message);
}
+86
View File
@@ -0,0 +1,86 @@
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_CMEXPR_YY_CMEXPRPARSERTOKENS_H_INCLUDED
# define YY_CMEXPR_YY_CMEXPRPARSERTOKENS_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int cmExpr_yydebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
exp_PLUS = 258,
exp_MINUS = 259,
exp_TIMES = 260,
exp_DIVIDE = 261,
exp_MOD = 262,
exp_SHIFTLEFT = 263,
exp_SHIFTRIGHT = 264,
exp_OPENPARENT = 265,
exp_CLOSEPARENT = 266,
exp_OR = 267,
exp_AND = 268,
exp_XOR = 269,
exp_NOT = 270,
exp_NUMBER = 271
};
#endif
/* Tokens. */
#define exp_PLUS 258
#define exp_MINUS 259
#define exp_TIMES 260
#define exp_DIVIDE 261
#define exp_MOD 262
#define exp_SHIFTLEFT 263
#define exp_SHIFTRIGHT 264
#define exp_OPENPARENT 265
#define exp_CLOSEPARENT 266
#define exp_OR 267
#define exp_AND 268
#define exp_XOR 269
#define exp_NOT 270
#define exp_NUMBER 271
/* Value type. */
int cmExpr_yyparse (yyscan_t yyscanner);
#endif /* !YY_CMEXPR_YY_CMEXPRPARSERTOKENS_H_INCLUDED */
File diff suppressed because it is too large Load Diff
+338
View File
@@ -0,0 +1,338 @@
#ifndef cmFortran_yyHEADER_H
#define cmFortran_yyHEADER_H 1
#define cmFortran_yyIN_HEADER 1
#line 6 "cmFortranLexer.h"
#line 8 "cmFortranLexer.h"
#define FLEXINT_H 1
#define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
#define YY_FLEX_SUBMINOR_VERSION 1
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
/* end standard C headers. */
/* flex integer type definitions */
#ifndef FLEXINT_H
#define FLEXINT_H
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
#endif
#include <inttypes.h>
typedef int8_t flex_int8_t;
typedef uint8_t flex_uint8_t;
typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
/* Limits of integral types. */
#ifndef INT8_MIN
#define INT8_MIN (-128)
#endif
#ifndef INT16_MIN
#define INT16_MIN (-32767-1)
#endif
#ifndef INT32_MIN
#define INT32_MIN (-2147483647-1)
#endif
#ifndef INT8_MAX
#define INT8_MAX (127)
#endif
#ifndef INT16_MAX
#define INT16_MAX (32767)
#endif
#ifndef INT32_MAX
#define INT32_MAX (2147483647)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX (255U)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX (65535U)
#endif
#ifndef UINT32_MAX
#define UINT32_MAX (4294967295U)
#endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
/* TODO: this is always defined, so inline it */
#define yyconst const
#if defined(__GNUC__) && __GNUC__ >= 3
#define yynoreturn __attribute__((__noreturn__))
#else
#define yynoreturn
#endif
/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
typedef void* yyscan_t;
#endif
/* For convenience, these vars (plus the bison vars far below)
are macros in the reentrant scanner. */
#define yyin yyg->yyin_r
#define yyout yyg->yyout_r
#define yyextra yyg->yyextra_r
#define yyleng yyg->yyleng_r
#define yytext yyg->yytext_r
#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
{
FILE *yy_input_file;
char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
int yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
* delete it.
*/
int yy_is_our_buffer;
/* Whether this is an "interactive" input source; if so, and
* if we're using stdio for input, then we want to use getc()
* instead of fread(), to make sure we stop fetching input after
* each newline.
*/
int yy_is_interactive;
/* Whether we're considered to be at the beginning of a line.
* If so, '^' rules will be active on the next match, otherwise
* not.
*/
int yy_at_bol;
int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
int yy_fill_buffer;
int yy_buffer_status;
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
void cmFortran_yyrestart (FILE *input_file ,yyscan_t yyscanner );
void cmFortran_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
YY_BUFFER_STATE cmFortran_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
void cmFortran_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void cmFortran_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void cmFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
void cmFortran_yypop_buffer_state (yyscan_t yyscanner );
YY_BUFFER_STATE cmFortran_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE cmFortran_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
YY_BUFFER_STATE cmFortran_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
void *cmFortran_yyalloc (yy_size_t ,yyscan_t yyscanner );
void *cmFortran_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
void cmFortran_yyfree (void * ,yyscan_t yyscanner );
/* Begin user sect3 */
#define cmFortran_yywrap(yyscanner) (/*CONSTCOND*/1)
#define YY_SKIP_YYWRAP
#define yytext_ptr yytext_r
#ifdef YY_HEADER_EXPORT_START_CONDITIONS
#define INITIAL 0
#define free_fmt 1
#define fixed_fmt 2
#define str_sq 3
#define str_dq 4
#endif
#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
#endif
int cmFortran_yylex_init (yyscan_t* scanner);
int cmFortran_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
int cmFortran_yylex_destroy (yyscan_t yyscanner );
int cmFortran_yyget_debug (yyscan_t yyscanner );
void cmFortran_yyset_debug (int debug_flag ,yyscan_t yyscanner );
YY_EXTRA_TYPE cmFortran_yyget_extra (yyscan_t yyscanner );
void cmFortran_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
FILE *cmFortran_yyget_in (yyscan_t yyscanner );
void cmFortran_yyset_in (FILE * _in_str ,yyscan_t yyscanner );
FILE *cmFortran_yyget_out (yyscan_t yyscanner );
void cmFortran_yyset_out (FILE * _out_str ,yyscan_t yyscanner );
int cmFortran_yyget_leng (yyscan_t yyscanner );
char *cmFortran_yyget_text (yyscan_t yyscanner );
int cmFortran_yyget_lineno (yyscan_t yyscanner );
void cmFortran_yyset_lineno (int _line_number ,yyscan_t yyscanner );
int cmFortran_yyget_column (yyscan_t yyscanner );
void cmFortran_yyset_column (int _column_no ,yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int cmFortran_yywrap (yyscan_t yyscanner );
#else
extern int cmFortran_yywrap (yyscan_t yyscanner );
#endif
#endif
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
#endif
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif
/* Number of entries by which start-condition stack grows. */
#ifndef YY_START_STACK_INCR
#define YY_START_STACK_INCR 25
#endif
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
*/
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
extern int cmFortran_yylex (yyscan_t yyscanner);
#define YY_DECL int cmFortran_yylex (yyscan_t yyscanner)
#endif /* !YY_DECL */
/* yy_get_previous_state - get the state just before the EOB char was reached */
#undef YY_NEW_FILE
#undef YY_FLUSH_BUFFER
#undef yy_set_bol
#undef yy_new_buffer
#undef yy_set_interactive
#undef YY_DO_BEFORE_ACTION
#ifdef YY_DECL_IS_OURS
#undef YY_DECL_IS_OURS
#undef YY_DECL
#endif
#line 178 "cmFortranLexer.in.l"
#line 337 "cmFortranLexer.h"
#undef cmFortran_yyIN_HEADER
#endif /* cmFortran_yyHEADER_H */
+186
View File
@@ -0,0 +1,186 @@
%{
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
/*-------------------------------------------------------------------------
Portions of this source have been derived from makedepf90 version 2.8.8,
Copyright (C) 2000--2006 Erik Edelmann <erik.edelmann@iki.fi>
The code was originally distributed under the GPL but permission
from the copyright holder has been obtained to distribute this
derived work under the CMake license.
-------------------------------------------------------------------------*/
/*
This file must be translated to C++ and modified to build everywhere.
Run flex >= 2.6 like this:
flex -i --nounistd -DFLEXINT_H --prefix=cmFortran_yy --header-file=cmFortranLexer.h -ocmFortranLexer.cxx cmFortranLexer.in.l
Modify cmFortranLexer.cxx:
- remove trailing whitespace: sed -i 's/\s*$//' cmFortranLexer.h cmFortranLexer.cxx
- remove blank lines at end of file
- #include "cmStandardLexer.h" at the top
- add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t
*/
/* IWYU pragma: no_forward_declare yyguts_t */
#undef YY_NO_UNPUT
#define cmFortranLexer_cxx
#include "cmFortranParser.h" /* Interface to parser object. */
/* Replace the lexer input function. */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
{ result = cmFortranParser_Input(yyextra, buf, max_size); }
/* Include the set of tokens from the parser. */
#include "cmFortranParserTokens.h"
/*--------------------------------------------------------------------------*/
%}
%option reentrant
%option noyywrap
%pointer
%s free_fmt fixed_fmt
%x str_sq str_dq
%%
\" {
cmFortranParser_StringStart(yyextra);
cmFortranParser_SetOldStartcond(yyextra, YY_START);
BEGIN(str_dq);
}
' {
cmFortranParser_StringStart(yyextra);
cmFortranParser_SetOldStartcond(yyextra, YY_START);
BEGIN(str_sq);
}
<str_dq>\" |
<str_sq>' {
BEGIN(cmFortranParser_GetOldStartcond(yyextra) );
yylvalp->string = strdup(cmFortranParser_StringEnd(yyextra));
return STRING;
}
<str_dq,str_sq>&[ \t]*\n |
<str_dq,str_sq>&[ \t]*\n[ \t]*& /* Ignore (continued strings, free fmt) */
<fixed_fmt,str_dq,str_sq>\n[ ]{5}[^ \t\n] {
if (cmFortranParser_GetOldStartcond(yyextra) == fixed_fmt)
; /* Ignore (cont. strings, fixed fmt) */
else
{
unput(yytext[strlen(yytext)-1]);
}
}
<str_dq,str_sq>\n {
unput ('\n');
BEGIN(INITIAL);
return UNTERMINATED_STRING;
}
<str_sq,str_dq>. {
cmFortranParser_StringAppend(yyextra, yytext[0]);
}
!.*\n { return EOSTMT; } /* Treat comments like */
<fixed_fmt>^[cC*dD].*\n { return EOSTMT; } /* empty lines */
^[ \t]*#([ \t]*line)?[ \t]*[0-9]+[ \t]* { return CPP_LINE_DIRECTIVE; }
^[ \t]*#[ \t]*include[ \t]*<[^>]+> {
yytext[yyleng-1] = 0;
yylvalp->string = strdup(strchr(yytext, '<')+1);
return CPP_INCLUDE_ANGLE;
}
^[ \t]*#[ \t]*include { return CPP_INCLUDE; }
\$[ \t]*include { return F90PPR_INCLUDE; }
\?\?[ \t]*include { return COCO_INCLUDE; }
^[ \t]*#[ \t]*define { return CPP_DEFINE; }
\$[ \t]*DEFINE { return F90PPR_DEFINE; }
^[ \t]*#[ \t]*undef { return CPP_UNDEF; }
\$[ \t]*UNDEF { return F90PPR_UNDEF; }
^[ \t]*#[ \t]*ifdef { return CPP_IFDEF; }
^[ \t]*#[ \t]*ifndef { return CPP_IFNDEF; }
^[ \t]*#[ \t]*if { return CPP_IF; }
^[ \t]*#[ \t]*elif { return CPP_ELIF; }
^[ \t]*#[ \t]*else { return CPP_ELSE; }
^[ \t]*#[ \t]*endif { return CPP_ENDIF; }
$[ \t]*ifdef { return F90PPR_IFDEF; }
$[ \t]*ifndef { return F90PPR_IFNDEF; }
$[ \t]*if { return F90PPR_IF; }
$[ \t]*elif { return F90PPR_ELIF; }
$[ \t]*else { return F90PPR_ELSE; }
$[ \t]*endif { return F90PPR_ENDIF; }
/* Line continuations, possible involving comments. */
&([ \t\n]*|!.*)*
&([ \t\n]*|!.*)*&
, { return COMMA; }
:: { return DCOLON; }
: { return COLON; }
<fixed_fmt>\n[ ]{5}[^ ] { return GARBAGE; }
=|=> { return ASSIGNMENT_OP; }
[Ee][Nn][Dd] { return END; }
[Ii][Nn][Cc][Ll][Uu][Dd][Ee] { return INCLUDE; }
[Ii][Nn][Tt][Ee][Rr][Ff][Aa][Cc][Ee] { return INTERFACE; }
[Mm][Oo][Dd][Uu][Ll][Ee] { return MODULE; }
[Ss][Uu][bb][Mm][Oo][Dd][Uu][Ll][Ee] { return SUBMODULE; }
[Uu][Ss][Ee] { return USE; }
[a-zA-Z_][a-zA-Z_0-9]* {
yylvalp->string = strdup(yytext);
return WORD;
}
\( { return LPAREN; }
\) { return RPAREN; }
[^ \t\n\r:;,!'"a-zA-Z=&()]+ { return GARBAGE; }
;|\n { return EOSTMT; }
[ \t\r,] /* Ignore */
\\[ \t]*\n /* Ignore line-endings preceded by \ */
. { return *yytext; }
<<EOF>> {
if(!cmFortranParser_FilePop(yyextra) )
{
return YY_NULL;
}
}
%%
/*--------------------------------------------------------------------------*/
YY_BUFFER_STATE cmFortranLexer_GetCurrentBuffer(yyscan_t yyscanner)
{
/* Hack into the internal flex-generated scanner to get the buffer. */
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return YY_CURRENT_BUFFER;
}
File diff suppressed because it is too large Load Diff
+247
View File
@@ -0,0 +1,247 @@
%{
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
/*-------------------------------------------------------------------------
Portions of this source have been derived from makedepf90 version 2.8.8,
Copyright (C) 2000--2006 Erik Edelmann <erik.edelmann@iki.fi>
The code was originally distributed under the GPL but permission
from the copyright holder has been obtained to distribute this
derived work under the CMake license.
-------------------------------------------------------------------------*/
/*
This file must be translated to C and modified to build everywhere.
Run bison like this:
bison --yacc --name-prefix=cmFortran_yy
--defines=cmFortranParserTokens.h
-ocmFortranParser.cxx
cmFortranParser.y
Modify cmFortranParser.cxx:
- "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"]
*/
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmsys/String.h"
#include <stdlib.h>
#include <string.h>
/*-------------------------------------------------------------------------*/
#define cmFortranParser_cxx
#include "cmFortranParser.h" /* Interface to parser object. */
#include "cmFortranParserTokens.h" /* Need YYSTYPE for YY_DECL. */
/* Forward declare the lexer entry point. */
YY_DECL;
/* Helper function to forward error callback from parser. */
static void cmFortran_yyerror(yyscan_t yyscanner, const char* message)
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_Error(parser, message);
}
/* Disable some warnings in the generated code. */
#ifdef _MSC_VER
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch contains default but no case. */
# pragma warning (disable: 4701) /* Local variable may not be initialized. */
# pragma warning (disable: 4702) /* Unreachable code. */
# pragma warning (disable: 4127) /* Conditional expression is constant. */
# pragma warning (disable: 4244) /* Conversion to smaller type, data loss. */
#endif
%}
/* Generate a reentrant parser object. */
%define api.pure
/* Configure the parser to use a lexer object. */
%lex-param {yyscan_t yyscanner}
%parse-param {yyscan_t yyscanner}
%define parse.error verbose
%union {
char* string;
}
/*-------------------------------------------------------------------------*/
/* Tokens */
%token EOSTMT ASSIGNMENT_OP GARBAGE
%token CPP_LINE_DIRECTIVE
%token CPP_INCLUDE F90PPR_INCLUDE COCO_INCLUDE
%token F90PPR_DEFINE CPP_DEFINE F90PPR_UNDEF CPP_UNDEF
%token CPP_IFDEF CPP_IFNDEF CPP_IF CPP_ELSE CPP_ELIF CPP_ENDIF
%token F90PPR_IFDEF F90PPR_IFNDEF F90PPR_IF
%token F90PPR_ELSE F90PPR_ELIF F90PPR_ENDIF
%token COMMA COLON DCOLON LPAREN RPAREN
%token <number> UNTERMINATED_STRING
%token <string> STRING WORD
%token <string> CPP_INCLUDE_ANGLE
%token END
%token INCLUDE
%token INTERFACE
%token MODULE
%token SUBMODULE
%token USE
/*-------------------------------------------------------------------------*/
/* grammar */
%%
code: /* empty */ | code stmt;
stmt:
INTERFACE EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_SetInInterface(parser, true);
}
| USE WORD other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleUse(parser, $2);
free($2);
}
| MODULE WORD other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
if (cmsysString_strcasecmp($2, "function") != 0 &&
cmsysString_strcasecmp($2, "procedure") != 0 &&
cmsysString_strcasecmp($2, "subroutine") != 0) {
cmFortranParser_RuleModule(parser, $2);
}
free($2);
}
| SUBMODULE LPAREN WORD RPAREN WORD other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleUse(parser, $3);
free($3);
free($5);
}
| SUBMODULE LPAREN WORD COLON WORD RPAREN WORD other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleUse(parser, $3);
free($3);
free($5);
free($7);
}
| INTERFACE WORD other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_SetInInterface(parser, true);
free($2);
}
| END INTERFACE other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_SetInInterface(parser, false);
}
| USE DCOLON WORD other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleUse(parser, $3);
free($3);
}
| USE COMMA WORD DCOLON WORD other EOSTMT {
if (cmsysString_strcasecmp($3, "non_intrinsic") == 0) {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleUse(parser, $5);
}
free($3);
free($5);
}
| INCLUDE STRING other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleInclude(parser, $2);
free($2);
}
| CPP_LINE_DIRECTIVE STRING other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleLineDirective(parser, $2);
free($2);
}
| CPP_INCLUDE_ANGLE other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleInclude(parser, $1);
free($1);
}
| include STRING other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleInclude(parser, $2);
free($2);
}
| define WORD other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleDefine(parser, $2);
free($2);
}
| undef WORD other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleUndef(parser, $2);
free($2);
}
| ifdef WORD other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleIfdef(parser, $2);
free($2);
}
| ifndef WORD other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleIfndef(parser, $2);
free($2);
}
| if other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleIf(parser);
}
| elif other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleElif(parser);
}
| else other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleElse(parser);
}
| endif other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleEndif(parser);
}
| EOSTMT
| error EOSTMT /* tolerate unknown statements until their end */
;
include: CPP_INCLUDE | F90PPR_INCLUDE | COCO_INCLUDE ;
define: CPP_DEFINE | F90PPR_DEFINE;
undef: CPP_UNDEF | F90PPR_UNDEF ;
ifdef: CPP_IFDEF | F90PPR_IFDEF ;
ifndef: CPP_IFNDEF | F90PPR_IFNDEF ;
if: CPP_IF | F90PPR_IF ;
elif: CPP_ELIF | F90PPR_ELIF ;
else: CPP_ELSE | F90PPR_ELSE ;
endif: CPP_ENDIF | F90PPR_ENDIF ;
other: /* empty */ | other misc_code ;
misc_code:
WORD { free ($1); }
| END
| INCLUDE
| INTERFACE
| MODULE
| SUBMODULE
| USE
| STRING { free ($1); }
| GARBAGE
| ASSIGNMENT_OP
| COLON
| DCOLON
| LPAREN
| RPAREN
| COMMA
| UNTERMINATED_STRING
;
%%
/* End of grammar */
+149
View File
@@ -0,0 +1,149 @@
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_CMFORTRAN_YY_CMFORTRANPARSERTOKENS_H_INCLUDED
# define YY_CMFORTRAN_YY_CMFORTRANPARSERTOKENS_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int cmFortran_yydebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
EOSTMT = 258,
ASSIGNMENT_OP = 259,
GARBAGE = 260,
CPP_LINE_DIRECTIVE = 261,
CPP_INCLUDE = 262,
F90PPR_INCLUDE = 263,
COCO_INCLUDE = 264,
F90PPR_DEFINE = 265,
CPP_DEFINE = 266,
F90PPR_UNDEF = 267,
CPP_UNDEF = 268,
CPP_IFDEF = 269,
CPP_IFNDEF = 270,
CPP_IF = 271,
CPP_ELSE = 272,
CPP_ELIF = 273,
CPP_ENDIF = 274,
F90PPR_IFDEF = 275,
F90PPR_IFNDEF = 276,
F90PPR_IF = 277,
F90PPR_ELSE = 278,
F90PPR_ELIF = 279,
F90PPR_ENDIF = 280,
COMMA = 281,
COLON = 282,
DCOLON = 283,
LPAREN = 284,
RPAREN = 285,
UNTERMINATED_STRING = 286,
STRING = 287,
WORD = 288,
CPP_INCLUDE_ANGLE = 289,
END = 290,
INCLUDE = 291,
INTERFACE = 292,
MODULE = 293,
SUBMODULE = 294,
USE = 295
};
#endif
/* Tokens. */
#define EOSTMT 258
#define ASSIGNMENT_OP 259
#define GARBAGE 260
#define CPP_LINE_DIRECTIVE 261
#define CPP_INCLUDE 262
#define F90PPR_INCLUDE 263
#define COCO_INCLUDE 264
#define F90PPR_DEFINE 265
#define CPP_DEFINE 266
#define F90PPR_UNDEF 267
#define CPP_UNDEF 268
#define CPP_IFDEF 269
#define CPP_IFNDEF 270
#define CPP_IF 271
#define CPP_ELSE 272
#define CPP_ELIF 273
#define CPP_ENDIF 274
#define F90PPR_IFDEF 275
#define F90PPR_IFNDEF 276
#define F90PPR_IF 277
#define F90PPR_ELSE 278
#define F90PPR_ELIF 279
#define F90PPR_ENDIF 280
#define COMMA 281
#define COLON 282
#define DCOLON 283
#define LPAREN 284
#define RPAREN 285
#define UNTERMINATED_STRING 286
#define STRING 287
#define WORD 288
#define CPP_INCLUDE_ANGLE 289
#define END 290
#define INCLUDE 291
#define INTERFACE 292
#define MODULE 293
#define SUBMODULE 294
#define USE 295
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 70 "cmFortranParser.y" /* yacc.c:1909 */
char* string;
#line 138 "cmFortranParserTokens.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
int cmFortran_yyparse (yyscan_t yyscanner);
#endif /* !YY_CMFORTRAN_YY_CMFORTRANPARSERTOKENS_H_INCLUDED */
File diff suppressed because it is too large Load Diff
+564
View File
@@ -0,0 +1,564 @@
%{
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
/*
This file must be translated to C and modified to build everywhere.
Run flex >= 2.6 like this:
flex --nounistd -DFLEXINT_H --prefix=cmListFileLexer_yy -ocmListFileLexer.c cmListFileLexer.in.l
Modify cmListFileLexer.c:
- remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c
- remove blank lines at end of file
- #include "cmStandardLexer.h" at the top
- add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t
- change type of variable yyl under yy_find_action from yy_size_t to int
*/
/* IWYU pragma: no_forward_declare yyguts_t */
#ifdef WIN32
#include "cmsys/Encoding.h"
#endif
/* Setup the proper cmListFileLexer_yylex declaration. */
#define YY_EXTRA_TYPE cmListFileLexer*
#define YY_DECL int cmListFileLexer_yylex (yyscan_t yyscanner, cmListFileLexer* lexer)
#include "cmListFileLexer.h"
/*--------------------------------------------------------------------------*/
struct cmListFileLexer_s
{
cmListFileLexer_Token token;
int bracket;
int comment;
int line;
int column;
int size;
FILE* file;
size_t cr;
char* string_buffer;
char* string_position;
int string_left;
yyscan_t scanner;
};
static void cmListFileLexerSetToken(cmListFileLexer* lexer, const char* text,
int length);
static void cmListFileLexerAppend(cmListFileLexer* lexer, const char* text,
int length);
static int cmListFileLexerInput(cmListFileLexer* lexer, char* buffer,
size_t bufferSize);
static void cmListFileLexerInit(cmListFileLexer* lexer);
static void cmListFileLexerDestroy(cmListFileLexer* lexer);
/* Replace the lexer input function. */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
{ result = cmListFileLexerInput(cmListFileLexer_yyget_extra(yyscanner), buf, max_size); }
/*--------------------------------------------------------------------------*/
%}
%option reentrant
%option yylineno
%option noyywrap
%pointer
%x STRING
%x BRACKET
%x BRACKETEND
%x COMMENT
MAKEVAR \$\([A-Za-z0-9_]*\)
UNQUOTED ([^ \t\r\n\(\)#\\\"[=]|\\.)
LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t[=])*\"
%%
<INITIAL,COMMENT>\n {
lexer->token.type = cmListFileLexer_Token_Newline;
cmListFileLexerSetToken(lexer, yytext, yyleng);
++lexer->line;
lexer->column = 1;
BEGIN(INITIAL);
return 1;
}
#?\[=*\[\n? {
const char* bracket = yytext;
lexer->comment = yytext[0] == '#';
if (lexer->comment) {
lexer->token.type = cmListFileLexer_Token_CommentBracket;
bracket += 1;
} else {
lexer->token.type = cmListFileLexer_Token_ArgumentBracket;
}
cmListFileLexerSetToken(lexer, "", 0);
lexer->bracket = strchr(bracket+1, '[') - bracket;
if (yytext[yyleng-1] == '\n') {
++lexer->line;
lexer->column = 1;
} else {
lexer->column += yyleng;
}
BEGIN(BRACKET);
}
# {
lexer->column += yyleng;
BEGIN(COMMENT);
}
<COMMENT>.* {
lexer->column += yyleng;
}
\( {
lexer->token.type = cmListFileLexer_Token_ParenLeft;
cmListFileLexerSetToken(lexer, yytext, yyleng);
lexer->column += yyleng;
return 1;
}
\) {
lexer->token.type = cmListFileLexer_Token_ParenRight;
cmListFileLexerSetToken(lexer, yytext, yyleng);
lexer->column += yyleng;
return 1;
}
[A-Za-z_][A-Za-z0-9_]* {
lexer->token.type = cmListFileLexer_Token_Identifier;
cmListFileLexerSetToken(lexer, yytext, yyleng);
lexer->column += yyleng;
return 1;
}
<BRACKET>\]=* {
/* Handle ]]====]=======]*/
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
if (yyleng == lexer->bracket) {
BEGIN(BRACKETEND);
}
}
<BRACKETEND>\] {
lexer->column += yyleng;
/* Erase the partial bracket from the token. */
lexer->token.length -= lexer->bracket;
lexer->token.text[lexer->token.length] = 0;
BEGIN(INITIAL);
return 1;
}
<BRACKET>([^]\n])+ {
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
}
<BRACKET,BRACKETEND>\n {
cmListFileLexerAppend(lexer, yytext, yyleng);
++lexer->line;
lexer->column = 1;
BEGIN(BRACKET);
}
<BRACKET,BRACKETEND>. {
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
BEGIN(BRACKET);
}
<BRACKET,BRACKETEND><<EOF>> {
lexer->token.type = cmListFileLexer_Token_BadBracket;
BEGIN(INITIAL);
return 1;
}
({UNQUOTED}|=|\[=*{UNQUOTED})({UNQUOTED}|[[=])* {
lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
cmListFileLexerSetToken(lexer, yytext, yyleng);
lexer->column += yyleng;
return 1;
}
({MAKEVAR}|{UNQUOTED}|=|\[=*{LEGACY})({LEGACY}|[[=])* {
lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
cmListFileLexerSetToken(lexer, yytext, yyleng);
lexer->column += yyleng;
return 1;
}
\[ {
lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
cmListFileLexerSetToken(lexer, yytext, yyleng);
lexer->column += yyleng;
return 1;
}
\" {
lexer->token.type = cmListFileLexer_Token_ArgumentQuoted;
cmListFileLexerSetToken(lexer, "", 0);
lexer->column += yyleng;
BEGIN(STRING);
}
<STRING>([^\\\n\"]|\\.)+ {
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
}
<STRING>\\\n {
/* Continuation: text is not part of string */
++lexer->line;
lexer->column = 1;
}
<STRING>\n {
cmListFileLexerAppend(lexer, yytext, yyleng);
++lexer->line;
lexer->column = 1;
}
<STRING>\" {
lexer->column += yyleng;
BEGIN(INITIAL);
return 1;
}
<STRING>. {
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
}
<STRING><<EOF>> {
lexer->token.type = cmListFileLexer_Token_BadString;
BEGIN(INITIAL);
return 1;
}
[ \t\r]+ {
lexer->token.type = cmListFileLexer_Token_Space;
cmListFileLexerSetToken(lexer, yytext, yyleng);
lexer->column += yyleng;
return 1;
}
. {
lexer->token.type = cmListFileLexer_Token_BadCharacter;
cmListFileLexerSetToken(lexer, yytext, yyleng);
lexer->column += yyleng;
return 1;
}
<<EOF>> {
lexer->token.type = cmListFileLexer_Token_None;
cmListFileLexerSetToken(lexer, 0, 0);
return 0;
}
%%
/*--------------------------------------------------------------------------*/
static void cmListFileLexerSetToken(cmListFileLexer* lexer, const char* text,
int length)
{
/* Set the token line and column number. */
lexer->token.line = lexer->line;
lexer->token.column = lexer->column;
/* Use the same buffer if possible. */
if (lexer->token.text) {
if (text && length < lexer->size) {
strcpy(lexer->token.text, text);
lexer->token.length = length;
return;
}
free(lexer->token.text);
lexer->token.text = 0;
lexer->size = 0;
}
/* Need to extend the buffer. */
if (text) {
lexer->token.text = strdup(text);
lexer->token.length = length;
lexer->size = length + 1;
} else {
lexer->token.length = 0;
}
}
/*--------------------------------------------------------------------------*/
static void cmListFileLexerAppend(cmListFileLexer* lexer, const char* text,
int length)
{
char* temp;
int newSize;
/* If the appended text will fit in the buffer, do not reallocate. */
newSize = lexer->token.length + length + 1;
if (lexer->token.text && newSize <= lexer->size) {
strcpy(lexer->token.text + lexer->token.length, text);
lexer->token.length += length;
return;
}
/* We need to extend the buffer. */
temp = malloc(newSize);
if (lexer->token.text) {
memcpy(temp, lexer->token.text, lexer->token.length);
free(lexer->token.text);
}
memcpy(temp + lexer->token.length, text, length);
temp[lexer->token.length + length] = 0;
lexer->token.text = temp;
lexer->token.length += length;
lexer->size = newSize;
}
/*--------------------------------------------------------------------------*/
static int cmListFileLexerInput(cmListFileLexer* lexer, char* buffer,
size_t bufferSize)
{
if (lexer) {
if (lexer->file) {
/* Convert CRLF -> LF explicitly. The C FILE "t"ext mode
does not convert newlines on all platforms. Move any
trailing CR to the start of the buffer for the next read. */
size_t cr = lexer->cr;
size_t n;
buffer[0] = '\r';
n = fread(buffer + cr, 1, bufferSize - cr, lexer->file);
if (n) {
char* o = buffer;
const char* i = buffer;
const char* e;
n += cr;
cr = (buffer[n - 1] == '\r') ? 1 : 0;
e = buffer + n - cr;
while (i != e) {
if (i[0] == '\r' && i[1] == '\n') {
++i;
}
*o++ = *i++;
}
n = o - buffer;
} else {
n = cr;
cr = 0;
}
lexer->cr = cr;
return n;
} else if (lexer->string_left) {
int length = lexer->string_left;
if ((int)bufferSize < length) {
length = (int)bufferSize;
}
memcpy(buffer, lexer->string_position, length);
lexer->string_position += length;
lexer->string_left -= length;
return length;
}
}
return 0;
}
/*--------------------------------------------------------------------------*/
static void cmListFileLexerInit(cmListFileLexer* lexer)
{
if (lexer->file || lexer->string_buffer) {
cmListFileLexer_yylex_init(&lexer->scanner);
cmListFileLexer_yyset_extra(lexer, lexer->scanner);
}
}
/*--------------------------------------------------------------------------*/
static void cmListFileLexerDestroy(cmListFileLexer* lexer)
{
cmListFileLexerSetToken(lexer, 0, 0);
if (lexer->file || lexer->string_buffer) {
cmListFileLexer_yylex_destroy(lexer->scanner);
if (lexer->file) {
fclose(lexer->file);
lexer->file = 0;
}
if (lexer->string_buffer) {
free(lexer->string_buffer);
lexer->string_buffer = 0;
lexer->string_left = 0;
lexer->string_position = 0;
}
}
}
/*--------------------------------------------------------------------------*/
cmListFileLexer* cmListFileLexer_New(void)
{
cmListFileLexer* lexer = (cmListFileLexer*)malloc(sizeof(cmListFileLexer));
if (!lexer) {
return 0;
}
memset(lexer, 0, sizeof(*lexer));
lexer->line = 1;
lexer->column = 1;
return lexer;
}
/*--------------------------------------------------------------------------*/
void cmListFileLexer_Delete(cmListFileLexer* lexer)
{
cmListFileLexer_SetFileName(lexer, 0, 0);
free(lexer);
}
/*--------------------------------------------------------------------------*/
static cmListFileLexer_BOM cmListFileLexer_ReadBOM(FILE* f)
{
unsigned char b[2];
if (fread(b, 1, 2, f) == 2) {
if (b[0] == 0xEF && b[1] == 0xBB) {
if (fread(b, 1, 1, f) == 1 && b[0] == 0xBF) {
return cmListFileLexer_BOM_UTF8;
}
} else if (b[0] == 0xFE && b[1] == 0xFF) {
/* UTF-16 BE */
return cmListFileLexer_BOM_UTF16BE;
} else if (b[0] == 0 && b[1] == 0) {
if (fread(b, 1, 2, f) == 2 && b[0] == 0xFE && b[1] == 0xFF) {
return cmListFileLexer_BOM_UTF32BE;
}
} else if (b[0] == 0xFF && b[1] == 0xFE) {
fpos_t p;
fgetpos(f, &p);
if (fread(b, 1, 2, f) == 2 && b[0] == 0 && b[1] == 0) {
return cmListFileLexer_BOM_UTF32LE;
}
fsetpos(f, &p);
return cmListFileLexer_BOM_UTF16LE;
}
}
rewind(f);
return cmListFileLexer_BOM_None;
}
/*--------------------------------------------------------------------------*/
int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name,
cmListFileLexer_BOM* bom)
{
int result = 1;
cmListFileLexerDestroy(lexer);
if (name) {
#ifdef _WIN32
wchar_t* wname = cmsysEncoding_DupToWide(name);
lexer->file = _wfopen(wname, L"rb");
free(wname);
#else
lexer->file = fopen(name, "rb");
#endif
if (lexer->file) {
if (bom) {
*bom = cmListFileLexer_ReadBOM(lexer->file);
}
} else {
result = 0;
}
}
cmListFileLexerInit(lexer);
return result;
}
/*--------------------------------------------------------------------------*/
int cmListFileLexer_SetString(cmListFileLexer* lexer, const char* text)
{
int result = 1;
cmListFileLexerDestroy(lexer);
if (text) {
int length = (int)strlen(text);
lexer->string_buffer = (char*)malloc(length + 1);
if (lexer->string_buffer) {
strcpy(lexer->string_buffer, text);
lexer->string_position = lexer->string_buffer;
lexer->string_left = length;
} else {
result = 0;
}
}
cmListFileLexerInit(lexer);
return result;
}
/*--------------------------------------------------------------------------*/
cmListFileLexer_Token* cmListFileLexer_Scan(cmListFileLexer* lexer)
{
if (!lexer->file) {
return 0;
}
if (cmListFileLexer_yylex(lexer->scanner, lexer)) {
return &lexer->token;
} else {
cmListFileLexer_SetFileName(lexer, 0, 0);
return 0;
}
}
/*--------------------------------------------------------------------------*/
long cmListFileLexer_GetCurrentLine(cmListFileLexer* lexer)
{
if (lexer->file) {
return lexer->line;
} else {
return 0;
}
}
/*--------------------------------------------------------------------------*/
long cmListFileLexer_GetCurrentColumn(cmListFileLexer* lexer)
{
if (lexer->file) {
return lexer->column;
} else {
return 0;
}
}
/*--------------------------------------------------------------------------*/
const char* cmListFileLexer_GetTypeAsString(cmListFileLexer* lexer,
cmListFileLexer_Type type)
{
(void)lexer;
switch (type) {
case cmListFileLexer_Token_None:
return "nothing";
case cmListFileLexer_Token_Space:
return "space";
case cmListFileLexer_Token_Newline:
return "newline";
case cmListFileLexer_Token_Identifier:
return "identifier";
case cmListFileLexer_Token_ParenLeft:
return "left paren";
case cmListFileLexer_Token_ParenRight:
return "right paren";
case cmListFileLexer_Token_ArgumentUnquoted:
return "unquoted argument";
case cmListFileLexer_Token_ArgumentQuoted:
return "quoted argument";
case cmListFileLexer_Token_ArgumentBracket:
return "bracket argument";
case cmListFileLexer_Token_CommentBracket:
return "bracket comment";
case cmListFileLexer_Token_BadCharacter:
return "bad character";
case cmListFileLexer_Token_BadBracket:
return "unterminated bracket";
case cmListFileLexer_Token_BadString:
return "unterminated string";
}
return "unknown token";
}