Manually reformat Flex and Bison files to be closer to clang-format style

master
Sébastien Villemot 2023-11-30 16:11:28 +01:00
parent d463607e90
commit b6adff7de7
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
4 changed files with 322 additions and 305 deletions

File diff suppressed because it is too large Load Diff

View File

@ -28,9 +28,9 @@ using namespace std;
// Announce to Flex the prototype we want for lexing function
#define YY_DECL \
Dynare::parser::token_type \
DynareFlex::lex(Dynare::parser::semantic_type *yylval, \
Dynare::parser::location_type *yylloc, \
ParsingDriver &driver)
DynareFlex::lex(Dynare::parser::semantic_type* yylval, \
Dynare::parser::location_type* yylloc, \
ParsingDriver& driver)
// Shortcut to access tokens defined by Bison
using token = Dynare::parser::token;
@ -38,7 +38,7 @@ using token = Dynare::parser::token;
/* By default yylex returns int, we use token_type.
Unfortunately yyterminate by default returns 0, which is
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;
string eofbuff;
@ -254,8 +254,8 @@ DATE -?[0-9]+([ya]|m([1-9]|1[0-2])|q[1-4])
/* Inside of a Dynare statement */
<DYNARE_STATEMENT>{DATE} {
char *yycopy = strdup(yytext);
char *uput = yycopy + yyleng;
char* yycopy = strdup(yytext);
char* uput = yycopy + yyleng;
unput(')');
unput('\'');
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>\$[^$]*\$ {
strtok(yytext+1, "$");
strtok(yytext + 1, "$");
yylval->build<string>(yytext + 1);
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;
while(getline(ss, token, ','))
while (getline(ss, token, ','))
if (driver.symbol_exists_and_is_not_modfile_local_or_external_function(token))
val.push_back(token);
else
@ -1227,7 +1227,7 @@ DynareFlex::DynareFlex(istream* in, ostream* out)
}
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)
if (*yytext++ == '\n')

View File

@ -1,6 +1,6 @@
// -*- C++ -*-
/*
* Copyright © 2019-2022 Dynare Team
* Copyright © 2019-2023 Dynare Team
*
* This file is part of Dynare.
*
@ -32,7 +32,7 @@
namespace macro { class Driver; }
}
%param { macro::Driver &driver }
%param { macro::Driver& driver }
%locations
%initial-action
@ -190,7 +190,7 @@ for : FOR { driver.pushContext(); } expr IN expr for_when EOL statements ENDFOR
if (tmpv)
vvnp.emplace_back(tmpv);
else if (tmpt)
for (const auto & it : tmpt->getValue())
for (const auto& it : tmpt->getValue())
{
auto vnp = dynamic_pointer_cast<Variable>(it);
if (!vnp)
@ -307,7 +307,10 @@ function : NAME LPAREN RPAREN
function_args : symbol
{ $$ = {$1}; }
| function_args COMMA symbol
{ $1.emplace_back($3); $$ = $1; }
{
$1.emplace_back($3);
$$ = $1;
}
;
comma_expr : %empty
@ -315,7 +318,10 @@ comma_expr : %empty
| expr
{ $$ = {$1}; }
| comma_expr COMMA expr
{ $1.emplace_back($3); $$ = $1; }
{
$1.emplace_back($3);
$$ = $1;
}
;
tuple_comma_expr : %empty
@ -325,7 +331,10 @@ tuple_comma_expr : %empty
| expr COMMA expr
{ $$ = {$1, $3}; }
| tuple_comma_expr COMMA expr
{ $1.emplace_back($3); $$ = $1; }
{
$1.emplace_back($3);
$$ = $1;
}
;
primary_expr : LPAREN expr RPAREN
@ -333,9 +342,7 @@ primary_expr : LPAREN expr RPAREN
| symbol
{ $$ = $1; } // Explicit rule needed for type conversion
| 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
{ $$ = make_shared<Function>($1, $3, @$); }
| TRUE
@ -496,7 +503,7 @@ expr : oper_expr
%%
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);
}

View File

@ -24,9 +24,9 @@
// Announce to Flex the prototype we want for lexing function
#define YY_DECL \
Tokenizer::parser::token_type \
TokenizerFlex::lex(Tokenizer::parser::semantic_type *yylval, \
Tokenizer::parser::location_type *yylloc, \
macro::Driver &driver)
TokenizerFlex::lex(Tokenizer::parser::semantic_type* yylval, \
Tokenizer::parser::location_type* yylloc, \
macro::Driver& driver)
// Shortcut to access tokens defined by Bison
using token = Tokenizer::parser::token;
@ -34,7 +34,7 @@ using token = Tokenizer::parser::token;
/* By default yylex returns int, we use token_type.
Unfortunately yyterminate by default returns 0, which is
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 ignored "-Wold-style-cast"
@ -199,7 +199,7 @@ CONT \\\\{SPC}*
#pragma GCC diagnostic pop
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)
if (*yytext++ == '\n')