2005-01-26 23:33:38 +03:00
|
|
|
%{
|
2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
2015-11-02 23:29:52 +03:00
|
|
|
Copyright 2000-2015 Kitware, Inc., Insight Software Consortium
|
2005-01-26 23:33:38 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2005-01-26 23:33:38 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2005-01-26 23:33:38 +03:00
|
|
|
/*-------------------------------------------------------------------------
|
2008-04-21 19:28:53 +04:00
|
|
|
Portions of this source have been derived from makedepf90 version 2.8.8,
|
2005-01-26 23:33:38 +03:00
|
|
|
|
2008-04-21 19:28:53 +04:00
|
|
|
Copyright (C) 2000--2006 Erik Edelmann <erik.edelmann@iki.fi>
|
2005-01-26 23:33:38 +03:00
|
|
|
|
|
|
|
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:
|
|
|
|
|
2015-07-22 20:21:45 +03:00
|
|
|
bison --yacc --name-prefix=cmFortran_yy
|
|
|
|
--defines=cmFortranParserTokens.h
|
|
|
|
-ocmFortranParser.cxx
|
|
|
|
cmFortranParser.y
|
2005-01-26 23:33:38 +03:00
|
|
|
|
2015-07-22 20:21:45 +03:00
|
|
|
Modify cmFortranParser.cxx:
|
2015-07-22 22:08:43 +03:00
|
|
|
- "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"]
|
2005-01-26 23:33:38 +03:00
|
|
|
*/
|
|
|
|
|
2005-02-01 18:42:52 +03:00
|
|
|
/*-------------------------------------------------------------------------*/
|
2015-07-22 20:21:45 +03:00
|
|
|
#define cmFortranParser_cxx
|
|
|
|
#include "cmFortranParser.h" /* Interface to parser object. */
|
|
|
|
#include "cmFortranParserTokens.h" /* Need YYSTYPE for YY_DECL. */
|
2005-02-01 18:42:52 +03:00
|
|
|
|
2009-06-12 18:46:25 +04:00
|
|
|
#include <cmsys/String.h>
|
|
|
|
|
2005-01-26 23:58:51 +03:00
|
|
|
/* Forward declare the lexer entry point. */
|
|
|
|
YY_DECL;
|
2005-01-26 23:33:38 +03:00
|
|
|
|
2015-07-22 22:08:43 +03:00
|
|
|
/* Helper function to forward error callback from parser. */
|
|
|
|
static void cmFortran_yyerror(yyscan_t yyscanner, const char* message)
|
2005-02-01 18:42:52 +03:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_Error(parser, message);
|
2005-02-01 18:42:52 +03:00
|
|
|
}
|
2005-01-26 23:33:38 +03:00
|
|
|
|
2015-07-22 20:21:45 +03:00
|
|
|
static bool cmFortranParserIsKeyword(const char* word,
|
2007-10-04 01:01:49 +04:00
|
|
|
const char* keyword)
|
|
|
|
{
|
2009-06-12 18:46:25 +04:00
|
|
|
return cmsysString_strcasecmp(word, keyword) == 0;
|
2007-10-04 01:01:49 +04:00
|
|
|
}
|
|
|
|
|
2005-01-29 01:09:43 +03:00
|
|
|
/* Disable some warnings in the generated code. */
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
# pragma warning (disable: 4102) /* Unused goto label. */
|
2005-02-01 19:28:38 +03:00
|
|
|
# pragma warning (disable: 4065) /* Switch contains default but no case. */
|
2007-10-05 18:02:34 +04:00
|
|
|
# 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. */
|
2005-01-29 01:09:43 +03:00
|
|
|
#endif
|
2005-01-26 23:33:38 +03:00
|
|
|
%}
|
|
|
|
|
|
|
|
/* Generate a reentrant parser object. */
|
2015-07-22 22:08:43 +03:00
|
|
|
%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
|
2005-01-26 23:33:38 +03:00
|
|
|
|
|
|
|
%union {
|
|
|
|
char* string;
|
|
|
|
}
|
|
|
|
|
2005-01-29 01:13:03 +03:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
/* Tokens */
|
2007-10-03 23:41:39 +04:00
|
|
|
%token EOSTMT ASSIGNMENT_OP GARBAGE
|
2015-11-02 23:29:52 +03:00
|
|
|
%token CPP_LINE_DIRECTIVE
|
2005-01-26 23:33:38 +03:00
|
|
|
%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
|
2007-10-05 18:02:34 +04:00
|
|
|
%token F90PPR_IFDEF F90PPR_IFNDEF F90PPR_IF
|
|
|
|
%token F90PPR_ELSE F90PPR_ELIF F90PPR_ENDIF
|
2008-04-24 07:53:20 +04:00
|
|
|
%token COMMA DCOLON
|
2007-10-03 23:41:39 +04:00
|
|
|
%token <string> CPP_TOENDL
|
|
|
|
%token <number> UNTERMINATED_STRING
|
|
|
|
%token <string> STRING WORD
|
2012-05-22 22:07:24 +04:00
|
|
|
%token <string> CPP_INCLUDE_ANGLE
|
2005-01-26 23:33:38 +03:00
|
|
|
|
2005-01-29 01:13:03 +03:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
/* grammar */
|
2005-01-26 23:33:38 +03:00
|
|
|
%%
|
|
|
|
|
2007-10-03 23:41:39 +04:00
|
|
|
code: /* empty */ | code stmt;
|
2005-01-26 23:33:38 +03:00
|
|
|
|
2007-10-03 23:41:39 +04:00
|
|
|
stmt: keyword_stmt | assignment_stmt;
|
|
|
|
|
|
|
|
assignment_stmt: WORD ASSIGNMENT_OP other EOSTMT /* Ignore */
|
2007-12-18 01:55:21 +03:00
|
|
|
{
|
|
|
|
free($1);
|
|
|
|
}
|
2007-10-03 23:41:39 +04:00
|
|
|
|
|
|
|
keyword_stmt:
|
|
|
|
WORD EOSTMT
|
2005-01-26 23:33:38 +03:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
if (cmFortranParserIsKeyword($1, "interface"))
|
2007-10-03 23:41:39 +04:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser =
|
|
|
|
cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_SetInInterface(parser, true);
|
2007-10-03 23:41:39 +04:00
|
|
|
}
|
|
|
|
free($1);
|
2005-01-26 23:33:38 +03:00
|
|
|
}
|
2007-10-03 23:41:39 +04:00
|
|
|
| WORD WORD other EOSTMT
|
2005-01-26 23:33:38 +03:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
if (cmFortranParserIsKeyword($1, "use"))
|
2007-10-03 23:41:39 +04:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser =
|
|
|
|
cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleUse(parser, $2);
|
2007-10-03 23:41:39 +04:00
|
|
|
}
|
2015-07-22 20:21:45 +03:00
|
|
|
else if (cmFortranParserIsKeyword($1, "module"))
|
2007-10-03 23:41:39 +04:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser =
|
|
|
|
cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleModule(parser, $2);
|
2007-10-03 23:41:39 +04:00
|
|
|
}
|
2015-07-22 20:21:45 +03:00
|
|
|
else if (cmFortranParserIsKeyword($1, "interface"))
|
2007-10-03 23:41:39 +04:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser =
|
|
|
|
cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_SetInInterface(parser, true);
|
2007-10-03 23:41:39 +04:00
|
|
|
}
|
2015-07-22 20:21:45 +03:00
|
|
|
else if (cmFortranParserIsKeyword($2, "interface") &&
|
|
|
|
cmFortranParserIsKeyword($1, "end"))
|
2007-10-03 23:41:39 +04:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser =
|
|
|
|
cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_SetInInterface(parser, false);
|
2007-10-03 23:41:39 +04:00
|
|
|
}
|
|
|
|
free($1);
|
2007-12-18 01:55:21 +03:00
|
|
|
free($2);
|
2005-01-26 23:33:38 +03:00
|
|
|
}
|
2008-04-24 07:53:20 +04:00
|
|
|
| WORD DCOLON WORD other EOSTMT
|
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
if (cmFortranParserIsKeyword($1, "use"))
|
2008-04-24 07:53:20 +04:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser =
|
|
|
|
cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleUse(parser, $3);
|
2008-04-24 07:53:20 +04:00
|
|
|
}
|
|
|
|
free($1);
|
|
|
|
free($3);
|
|
|
|
}
|
|
|
|
| WORD COMMA WORD DCOLON WORD other EOSTMT
|
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
if (cmFortranParserIsKeyword($1, "use") &&
|
|
|
|
cmFortranParserIsKeyword($3, "non_intrinsic") )
|
2008-04-24 07:53:20 +04:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser =
|
|
|
|
cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleUse(parser, $5);
|
2008-04-24 07:53:20 +04:00
|
|
|
}
|
|
|
|
free($1);
|
|
|
|
free($3);
|
|
|
|
free($5);
|
|
|
|
}
|
2007-12-18 01:55:03 +03:00
|
|
|
| WORD STRING other EOSTMT /* Ignore */
|
2007-12-18 01:55:21 +03:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
if (cmFortranParserIsKeyword($1, "include"))
|
2008-01-08 07:08:42 +03:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser =
|
|
|
|
cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleInclude(parser, $2);
|
2008-01-08 07:08:42 +03:00
|
|
|
}
|
2007-12-18 01:55:21 +03:00
|
|
|
free($1);
|
|
|
|
free($2);
|
|
|
|
}
|
2015-11-02 23:29:52 +03:00
|
|
|
| CPP_LINE_DIRECTIVE STRING other EOSTMT
|
|
|
|
{
|
|
|
|
cmFortranParser* parser =
|
|
|
|
cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleLineDirective(parser, $2);
|
|
|
|
free($2);
|
|
|
|
}
|
2012-05-22 22:07:24 +04:00
|
|
|
| CPP_INCLUDE_ANGLE other EOSTMT
|
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser =
|
|
|
|
cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleInclude(parser, $1);
|
2012-05-22 22:07:24 +04:00
|
|
|
free($1);
|
|
|
|
}
|
2007-12-18 01:55:03 +03:00
|
|
|
| include STRING other EOSTMT
|
2005-01-26 23:33:38 +03:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser =
|
|
|
|
cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleInclude(parser, $2);
|
2005-01-26 23:33:38 +03:00
|
|
|
free($2);
|
|
|
|
}
|
2007-10-03 23:41:39 +04:00
|
|
|
| define WORD other EOSTMT
|
2005-01-26 23:33:38 +03:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleDefine(parser, $2);
|
2005-01-26 23:33:38 +03:00
|
|
|
free($2);
|
|
|
|
}
|
2007-10-03 23:41:39 +04:00
|
|
|
| undef WORD other EOSTMT
|
2005-01-26 23:33:38 +03:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleUndef(parser, $2);
|
2005-01-26 23:33:38 +03:00
|
|
|
free($2);
|
|
|
|
}
|
2007-10-03 23:41:39 +04:00
|
|
|
| ifdef WORD other EOSTMT
|
2005-01-26 23:33:38 +03:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleIfdef(parser, $2);
|
2005-01-26 23:33:38 +03:00
|
|
|
free($2);
|
|
|
|
}
|
2007-10-03 23:41:39 +04:00
|
|
|
| ifndef WORD other EOSTMT
|
2005-01-26 23:33:38 +03:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleIfndef(parser, $2);
|
2005-01-26 23:33:38 +03:00
|
|
|
free($2);
|
|
|
|
}
|
2007-10-03 23:41:39 +04:00
|
|
|
| if other EOSTMT
|
2005-01-26 23:33:38 +03:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleIf(parser);
|
2005-01-26 23:33:38 +03:00
|
|
|
}
|
2007-10-03 23:41:39 +04:00
|
|
|
| elif other EOSTMT
|
2005-01-26 23:33:38 +03:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleElif(parser);
|
2005-01-26 23:33:38 +03:00
|
|
|
}
|
2007-10-03 23:41:39 +04:00
|
|
|
| else other EOSTMT
|
2005-01-26 23:33:38 +03:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleElse(parser);
|
2005-01-26 23:33:38 +03:00
|
|
|
}
|
2007-10-03 23:41:39 +04:00
|
|
|
| endif other EOSTMT
|
2005-01-26 23:33:38 +03:00
|
|
|
{
|
2015-07-22 20:21:45 +03:00
|
|
|
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
|
|
|
|
cmFortranParser_RuleEndif(parser);
|
2005-01-26 23:33:38 +03:00
|
|
|
}
|
2007-10-03 23:41:39 +04:00
|
|
|
| WORD GARBAGE other EOSTMT /* Ignore */
|
2007-12-18 01:55:21 +03:00
|
|
|
{
|
|
|
|
free($1);
|
|
|
|
}
|
2007-10-03 23:41:39 +04:00
|
|
|
| GARBAGE other EOSTMT
|
|
|
|
| EOSTMT
|
|
|
|
| error
|
2005-01-26 23:33:38 +03:00
|
|
|
;
|
|
|
|
|
2007-10-03 23:41:39 +04:00
|
|
|
|
|
|
|
|
|
|
|
include: CPP_INCLUDE | F90PPR_INCLUDE | COCO_INCLUDE ;
|
|
|
|
define: CPP_DEFINE | F90PPR_DEFINE;
|
2005-01-26 23:33:38 +03:00
|
|
|
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); }
|
|
|
|
| STRING { free ($1); }
|
2007-10-03 23:41:39 +04:00
|
|
|
| GARBAGE
|
|
|
|
| ASSIGNMENT_OP
|
2008-04-24 07:53:20 +04:00
|
|
|
| DCOLON
|
|
|
|
| COMMA
|
2005-01-26 23:33:38 +03:00
|
|
|
| UNTERMINATED_STRING
|
|
|
|
;
|
|
|
|
|
|
|
|
%%
|
2005-01-29 01:13:03 +03:00
|
|
|
/* End of grammar */
|