Manually reformat Flex and Bison files to be closer to clang-format style
parent
d463607e90
commit
b6adff7de7
File diff suppressed because it is too large
Load Diff
|
@ -28,9 +28,9 @@ using namespace std;
|
||||||
// Announce to Flex the prototype we want for lexing function
|
// Announce to Flex the prototype we want for lexing function
|
||||||
#define YY_DECL \
|
#define YY_DECL \
|
||||||
Dynare::parser::token_type \
|
Dynare::parser::token_type \
|
||||||
DynareFlex::lex(Dynare::parser::semantic_type *yylval, \
|
DynareFlex::lex(Dynare::parser::semantic_type* yylval, \
|
||||||
Dynare::parser::location_type *yylloc, \
|
Dynare::parser::location_type* yylloc, \
|
||||||
ParsingDriver &driver)
|
ParsingDriver& driver)
|
||||||
|
|
||||||
// Shortcut to access tokens defined by Bison
|
// Shortcut to access tokens defined by Bison
|
||||||
using token = Dynare::parser::token;
|
using token = Dynare::parser::token;
|
||||||
|
@ -38,7 +38,7 @@ using token = Dynare::parser::token;
|
||||||
/* By default yylex returns int, we use token_type.
|
/* By default yylex returns int, we use token_type.
|
||||||
Unfortunately yyterminate by default returns 0, which is
|
Unfortunately yyterminate by default returns 0, which is
|
||||||
not of token_type. */
|
not of token_type. */
|
||||||
#define yyterminate() return Dynare::parser::token_type (0);
|
#define yyterminate() return Dynare::parser::token_type(0);
|
||||||
|
|
||||||
int comment_caller, line_caller;
|
int comment_caller, line_caller;
|
||||||
string eofbuff;
|
string eofbuff;
|
||||||
|
@ -254,8 +254,8 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4])
|
||||||
|
|
||||||
/* Inside of a Dynare statement */
|
/* Inside of a Dynare statement */
|
||||||
<DYNARE_STATEMENT>{DATE} {
|
<DYNARE_STATEMENT>{DATE} {
|
||||||
char *yycopy = strdup(yytext);
|
char* yycopy = strdup(yytext);
|
||||||
char *uput = yycopy + yyleng;
|
char* uput = yycopy + yyleng;
|
||||||
unput(')');
|
unput(')');
|
||||||
unput('\'');
|
unput('\'');
|
||||||
while (uput > yycopy)
|
while (uput > yycopy)
|
||||||
|
@ -779,7 +779,7 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4])
|
||||||
<DYNARE_STATEMENT>non_zero {return token::NON_ZERO;}
|
<DYNARE_STATEMENT>non_zero {return token::NON_ZERO;}
|
||||||
|
|
||||||
<DYNARE_STATEMENT>\$[^$]*\$ {
|
<DYNARE_STATEMENT>\$[^$]*\$ {
|
||||||
strtok(yytext+1, "$");
|
strtok(yytext + 1, "$");
|
||||||
yylval->build<string>(yytext + 1);
|
yylval->build<string>(yytext + 1);
|
||||||
return token::TEX_NAME;
|
return token::TEX_NAME;
|
||||||
}
|
}
|
||||||
|
@ -1156,7 +1156,7 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4])
|
||||||
|
|
||||||
bool dynare_statement = true;
|
bool dynare_statement = true;
|
||||||
|
|
||||||
while(getline(ss, token, ','))
|
while (getline(ss, token, ','))
|
||||||
if (driver.symbol_exists_and_is_not_modfile_local_or_external_function(token))
|
if (driver.symbol_exists_and_is_not_modfile_local_or_external_function(token))
|
||||||
val.push_back(token);
|
val.push_back(token);
|
||||||
else
|
else
|
||||||
|
@ -1227,7 +1227,7 @@ DynareFlex::DynareFlex(istream* in, ostream* out)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynareFlex::location_increment(Dynare::parser::location_type *yylloc, const char *yytext)
|
DynareFlex::location_increment(Dynare::parser::location_type* yylloc, const char* yytext)
|
||||||
{
|
{
|
||||||
while (*yytext != 0)
|
while (*yytext != 0)
|
||||||
if (*yytext++ == '\n')
|
if (*yytext++ == '\n')
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
/*
|
/*
|
||||||
* Copyright © 2019-2022 Dynare Team
|
* Copyright © 2019-2023 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
namespace macro { class Driver; }
|
namespace macro { class Driver; }
|
||||||
}
|
}
|
||||||
|
|
||||||
%param { macro::Driver &driver }
|
%param { macro::Driver& driver }
|
||||||
|
|
||||||
%locations
|
%locations
|
||||||
%initial-action
|
%initial-action
|
||||||
|
@ -190,7 +190,7 @@ for : FOR { driver.pushContext(); } expr IN expr for_when EOL statements ENDFOR
|
||||||
if (tmpv)
|
if (tmpv)
|
||||||
vvnp.emplace_back(tmpv);
|
vvnp.emplace_back(tmpv);
|
||||||
else if (tmpt)
|
else if (tmpt)
|
||||||
for (const auto & it : tmpt->getValue())
|
for (const auto& it : tmpt->getValue())
|
||||||
{
|
{
|
||||||
auto vnp = dynamic_pointer_cast<Variable>(it);
|
auto vnp = dynamic_pointer_cast<Variable>(it);
|
||||||
if (!vnp)
|
if (!vnp)
|
||||||
|
@ -307,7 +307,10 @@ function : NAME LPAREN RPAREN
|
||||||
function_args : symbol
|
function_args : symbol
|
||||||
{ $$ = {$1}; }
|
{ $$ = {$1}; }
|
||||||
| function_args COMMA symbol
|
| function_args COMMA symbol
|
||||||
{ $1.emplace_back($3); $$ = $1; }
|
{
|
||||||
|
$1.emplace_back($3);
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
comma_expr : %empty
|
comma_expr : %empty
|
||||||
|
@ -315,7 +318,10 @@ comma_expr : %empty
|
||||||
| expr
|
| expr
|
||||||
{ $$ = {$1}; }
|
{ $$ = {$1}; }
|
||||||
| comma_expr COMMA expr
|
| comma_expr COMMA expr
|
||||||
{ $1.emplace_back($3); $$ = $1; }
|
{
|
||||||
|
$1.emplace_back($3);
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
tuple_comma_expr : %empty
|
tuple_comma_expr : %empty
|
||||||
|
@ -325,7 +331,10 @@ tuple_comma_expr : %empty
|
||||||
| expr COMMA expr
|
| expr COMMA expr
|
||||||
{ $$ = {$1, $3}; }
|
{ $$ = {$1, $3}; }
|
||||||
| tuple_comma_expr COMMA expr
|
| tuple_comma_expr COMMA expr
|
||||||
{ $1.emplace_back($3); $$ = $1; }
|
{
|
||||||
|
$1.emplace_back($3);
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
primary_expr : LPAREN expr RPAREN
|
primary_expr : LPAREN expr RPAREN
|
||||||
|
@ -333,9 +342,7 @@ primary_expr : LPAREN expr RPAREN
|
||||||
| symbol
|
| symbol
|
||||||
{ $$ = $1; } // Explicit rule needed for type conversion
|
{ $$ = $1; } // Explicit rule needed for type conversion
|
||||||
| NAME LBRACKET comma_expr RBRACKET
|
| NAME LBRACKET comma_expr RBRACKET
|
||||||
{
|
{ $$ = make_shared<Variable>($1, make_shared<Array>($3, @3), @$); }
|
||||||
$$ = make_shared<Variable>($1, make_shared<Array>($3, @3), @$);
|
|
||||||
}
|
|
||||||
| NAME LPAREN comma_expr RPAREN
|
| NAME LPAREN comma_expr RPAREN
|
||||||
{ $$ = make_shared<Function>($1, $3, @$); }
|
{ $$ = make_shared<Function>($1, $3, @$); }
|
||||||
| TRUE
|
| TRUE
|
||||||
|
@ -496,7 +503,7 @@ expr : oper_expr
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void
|
void
|
||||||
Tokenizer::parser::error(const Tokenizer::parser::location_type &l, const string &m)
|
Tokenizer::parser::error(const Tokenizer::parser::location_type& l, const string& m)
|
||||||
{
|
{
|
||||||
driver.error(l, m);
|
driver.error(l, m);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,9 @@
|
||||||
// Announce to Flex the prototype we want for lexing function
|
// Announce to Flex the prototype we want for lexing function
|
||||||
#define YY_DECL \
|
#define YY_DECL \
|
||||||
Tokenizer::parser::token_type \
|
Tokenizer::parser::token_type \
|
||||||
TokenizerFlex::lex(Tokenizer::parser::semantic_type *yylval, \
|
TokenizerFlex::lex(Tokenizer::parser::semantic_type* yylval, \
|
||||||
Tokenizer::parser::location_type *yylloc, \
|
Tokenizer::parser::location_type* yylloc, \
|
||||||
macro::Driver &driver)
|
macro::Driver& driver)
|
||||||
|
|
||||||
// Shortcut to access tokens defined by Bison
|
// Shortcut to access tokens defined by Bison
|
||||||
using token = Tokenizer::parser::token;
|
using token = Tokenizer::parser::token;
|
||||||
|
@ -34,7 +34,7 @@ using token = Tokenizer::parser::token;
|
||||||
/* By default yylex returns int, we use token_type.
|
/* By default yylex returns int, we use token_type.
|
||||||
Unfortunately yyterminate by default returns 0, which is
|
Unfortunately yyterminate by default returns 0, which is
|
||||||
not of token_type. */
|
not of token_type. */
|
||||||
#define yyterminate() return Tokenizer::parser::token_type (0);
|
#define yyterminate() return Tokenizer::parser::token_type(0);
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||||
|
@ -199,7 +199,7 @@ CONT \\\\{SPC}*
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
void
|
void
|
||||||
TokenizerFlex::location_increment(Tokenizer::parser::location_type *yylloc, const char *yytext)
|
TokenizerFlex::location_increment(Tokenizer::parser::location_type* yylloc, const char* yytext)
|
||||||
{
|
{
|
||||||
while (*yytext != 0)
|
while (*yytext != 0)
|
||||||
if (*yytext++ == '\n')
|
if (*yytext++ == '\n')
|
||||||
|
|
Loading…
Reference in New Issue