/* A Bison parser, made by GNU Bison 3.7.6. */
/* Bison implementation for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 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 . */
/* 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. */
/* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
variables, as they might otherwise be expanded by user macros.
There are some unavoidable exceptions within include files to
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
/* Identify Bison output, and Bison version. */
#define YYBISON 30706
/* Bison version string. */
#define YYBISON_VERSION "3.7.6"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
/* Pure parsers. */
#define YYPURE 2
/* Push parsers. */
#define YYPUSH 0
/* Pull parsers. */
#define YYPULL 1
/* Substitute the type names. */
#define YYSTYPE DAS_YYSTYPE
#define YYLTYPE DAS_YYLTYPE
/* Substitute the variable and function names. */
#define yyparse das_yyparse
#define yylex das_yylex
#define yyerror das_yyerror
#define yydebug das_yydebug
#define yynerrs das_yynerrs
/* First part of user prologue. */
#include "daScript/misc/platform.h"
#include "daScript/simulate/debug_info.h"
#include "daScript/ast/compilation_errors.h"
#ifdef _MSC_VER
#pragma warning(disable:4262)
#pragma warning(disable:4127)
#pragma warning(disable:4702)
#endif
using namespace das;
union DAS_YYSTYPE;
struct DAS_YYLTYPE;
#define YY_NO_UNISTD_H
#include "lex.yy.h"
void das_yyerror ( DAS_YYLTYPE * lloc, yyscan_t scanner, const string & error );
void das_yyfatalerror ( DAS_YYLTYPE * lloc, yyscan_t scanner, const string & error, CompilationError cerr );
int yylex ( DAS_YYSTYPE *lvalp, DAS_YYLTYPE *llocp, yyscan_t scanner );
void yybegin ( const char * str );
void das_yybegin_reader ( yyscan_t yyscanner );
void das_yyend_reader ( yyscan_t yyscanner );
#undef yyextra
#define yyextra (*((das::DasParserState **)(scanner)))
# ifndef YY_CAST
# ifdef __cplusplus
# define YY_CAST(Type, Val) static_cast (Val)
# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val)
# else
# define YY_CAST(Type, Val) ((Type) (Val))
# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
# endif
# endif
# ifndef YY_NULLPTR
# if defined __cplusplus
# if 201103L last_column ? yylocp->last_column - 1 : 0;
if (0 first_line)
{
res += YYFPRINTF (yyo, "%d", yylocp->first_line);
if (0 first_column)
res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
}
if (0 last_line)
{
if (yylocp->first_line < yylocp->last_line)
{
res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
if (0 yyssp];
if (!yypact_value_is_default (yyn))
{
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for
this state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yyx;
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYSYMBOL_YYerror
&& !yytable_value_is_error (yytable[yyx + yyn]))
{
if (!yyarg)
++yycount;
else if (yycount == yyargn)
return 0;
else
yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx);
}
}
if (yyarg && yycount == 0 && 0 < yyargn)
yyarg[0] = YYSYMBOL_YYEMPTY;
return yycount;
}
#ifndef yystrlen
# if defined __GLIBC__ && defined _STRING_H
# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
# else
/* Return the length of YYSTR. */
static YYPTRDIFF_T
yystrlen (const char *yystr)
{
YYPTRDIFF_T yylen;
for (yylen = 0; yystr[yylen]; yylen++)
continue;
return yylen;
}
# endif
#endif
#ifndef yystpcpy
# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
# define yystpcpy stpcpy
# else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
YYDEST. */
static char *
yystpcpy (char *yydest, const char *yysrc)
{
char *yyd = yydest;
const char *yys = yysrc;
while ((*yyd++ = *yys++) != '\0')
continue;
return yyd - 1;
}
# endif
#endif
#ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
quotes and backslashes, so that it's suitable for yyerror. The
heuristic is that double-quoting is unnecessary unless the string
contains an apostrophe, a comma, or backslash (other than
backslash-backslash). YYSTR is taken from yytname. If YYRES is
null, do not copy; instead, return the length of what the result
would have been. */
static YYPTRDIFF_T
yytnamerr (char *yyres, const char *yystr)
{
if (*yystr == '"')
{
YYPTRDIFF_T yyn = 0;
char const *yyp = yystr;
for (;;)
switch (*++yyp)
{
case '\'':
case ',':
goto do_not_strip_quotes;
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
else
goto append;
append:
default:
if (yyres)
yyres[yyn] = *yyp;
yyn++;
break;
case '"':
if (yyres)
yyres[yyn] = '\0';
return yyn;
}
do_not_strip_quotes: ;
}
if (yyres)
return yystpcpy (yyres, yystr) - yyres;
else
return yystrlen (yystr);
}
#endif
static int
yy_syntax_error_arguments (const yypcontext_t *yyctx,
yysymbol_kind_t yyarg[], int yyargn)
{
/* Actual size of YYARG. */
int yycount = 0;
/* There are many possibilities here to consider:
- If this state is a consistent state with a default action, then
the only way this function was invoked is if the default action
is an error action. In that case, don't check for expected
tokens because there are none.
- The only way there can be no lookahead present (in yychar) is if
this state is a consistent state with a default action. Thus,
detecting the absence of a lookahead is sufficient to determine
that there is no unexpected or expected token to report. In that
case, just report a simple "syntax error".
- Don't assume there isn't a lookahead just because this state is a
consistent state with a default action. There might have been a
previous inconsistent state, consistent state with a non-default
action, or user semantic action that manipulated yychar.
- Of course, the expected token list depends on states to have
correct lookahead information, and it depends on the parser not
to perform extra reductions after fetching a lookahead from the
scanner and before detecting a syntax error. Thus, state merging
(from LALR or IELR) and default reductions corrupt the expected
token list. However, the list is correct for canonical LR with
one exception: it will still contain any token that will not be
accepted due to an error action in a later state.
*/
if (yyctx->yytoken != YYSYMBOL_YYEMPTY)
{
int yyn;
if (yyarg)
yyarg[yycount] = yyctx->yytoken;
++yycount;
yyn = yypcontext_expected_tokens (yyctx,
yyarg ? yyarg + 1 : yyarg, yyargn - 1);
if (yyn == YYENOMEM)
return YYENOMEM;
else
yycount += yyn;
}
return yycount;
}
/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
about the unexpected token YYTOKEN for the state stack whose top is
YYSSP.
Return 0 if *YYMSG was successfully written. Return -1 if *YYMSG is
not large enough to hold the message. In that case, also set
*YYMSG_ALLOC to the required number of bytes. Return YYENOMEM if the
required number of bytes is too large to store. */
static int
yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
const yypcontext_t *yyctx)
{
enum { YYARGS_MAX = 5 };
/* Internationalized format string. */
const char *yyformat = YY_NULLPTR;
/* Arguments of yyformat: reported tokens (one for the "unexpected",
one per "expected"). */
yysymbol_kind_t yyarg[YYARGS_MAX];
/* Cumulated lengths of YYARG. */
YYPTRDIFF_T yysize = 0;
/* Actual size of YYARG. */
int yycount = yy_syntax_error_arguments (yyctx, yyarg, YYARGS_MAX);
if (yycount == YYENOMEM)
return YYENOMEM;
switch (yycount)
{
#define YYCASE_(N, S) \
case N: \
yyformat = S; \
break
default: /* Avoid compiler warnings. */
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
#undef YYCASE_
}
/* Compute error message size. Don't count the "%s"s, but reserve
room for the terminator. */
yysize = yystrlen (yyformat) - 2 * yycount + 1;
{
int yyi;
for (yyi = 0; yyi < yycount; ++yyi)
{
YYPTRDIFF_T yysize1
= yysize + yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]]);
if (yysize g_Program->thisModule->name.empty() ) {
yyextra->g_Program->thisModule->name = *(yyvsp[-2].s);
} else if ( yyextra->g_Program->thisModule->name != *(yyvsp[-2].s) ){
das_yyerror(scanner,"this module already has a name " + yyextra->g_Program->thisModule->name,tokAt(scanner,(yylsp[-2])),
CompilationError::module_already_has_a_name);
}
if ( !yyextra->g_Program->policies.ignore_shared_modules ) {
yyextra->g_Program->promoteToBuiltin = (yyvsp[-1].b);
}
delete (yyvsp[-2].s);
}
break;
case 21: /* character_sequence: STRING_CHARACTER */
{ (yyval.s) = new string(); *(yyval.s) += (yyvsp[0].ch); }
break;
case 22: /* character_sequence: STRING_CHARACTER_ESC */
{ (yyval.s) = new string(); *(yyval.s) += "\\\\"; }
break;
case 23: /* character_sequence: character_sequence STRING_CHARACTER */
{ (yyval.s) = (yyvsp[-1].s); *(yyvsp[-1].s) += (yyvsp[0].ch); }
break;
case 24: /* character_sequence: character_sequence STRING_CHARACTER_ESC */
{ (yyval.s) = (yyvsp[-1].s); *(yyvsp[-1].s) += "\\\\"; }
break;
case 25: /* string_constant: "start of the string" character_sequence "end of the string" */
{ (yyval.s) = (yyvsp[-1].s); }
break;
case 26: /* string_builder_body: %empty */
{
(yyval.pExpression) = new ExprStringBuilder();
(yyval.pExpression)->at = LineInfo(yyextra->g_FileAccessStack.back(),
yylloc.first_column,yylloc.first_line,yylloc.last_column,yylloc.last_line);
}
break;
case 27: /* string_builder_body: string_builder_body character_sequence */
{
bool err;
auto esconst = unescapeString(*(yyvsp[0].s),&err);
if ( err ) das_yyerror(scanner,"invalid escape sequence",tokAt(scanner,(yylsp[-1])), CompilationError::invalid_escape_sequence);
auto sc = make_smart(tokAt(scanner,(yylsp[0])),esconst);
delete (yyvsp[0].s);
static_cast((yyvsp[-1].pExpression))->elements.push_back(sc);
(yyval.pExpression) = (yyvsp[-1].pExpression);
}
break;
case 28: /* string_builder_body: string_builder_body "{" expr "}" */
{
auto se = ExpressionPtr((yyvsp[-1].pExpression));
static_cast((yyvsp[-3].pExpression))->elements.push_back(se);
(yyval.pExpression) = (yyvsp[-3].pExpression);
}
break;
case 29: /* string_builder: "start of the string" string_builder_body "end of the string" */
{
auto strb = static_cast((yyvsp[-1].pExpression));
if ( strb->elements.size()==0 ) {
(yyval.pExpression) = new ExprConstString(tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])),"");
delete (yyvsp[-1].pExpression);
} else if ( strb->elements.size()==1 && strb->elements[0]->rtti_isStringConstant() ) {
auto sconst = static_pointer_cast(strb->elements[0]);
(yyval.pExpression) = new ExprConstString(tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])),sconst->text);
delete (yyvsp[-1].pExpression);
} else {
(yyval.pExpression) = (yyvsp[-1].pExpression);
}
}
break;
case 30: /* reader_character_sequence: STRING_CHARACTER */
{
if ( !yyextra->g_ReaderMacro->accept(yyextra->g_Program.get(), yyextra->g_Program->thisModule.get(), yyextra->g_ReaderExpr, (yyvsp[0].ch), tokAt(scanner,(yylsp[0]))) ) {
das_yyend_reader(scanner);
}
}
break;
case 31: /* reader_character_sequence: reader_character_sequence STRING_CHARACTER */
{
if ( !yyextra->g_ReaderMacro->accept(yyextra->g_Program.get(), yyextra->g_Program->thisModule.get(), yyextra->g_ReaderExpr, (yyvsp[0].ch), tokAt(scanner,(yylsp[0]))) ) {
das_yyend_reader(scanner);
}
}
break;
case 32: /* $@1: %empty */
{
auto macros = yyextra->g_Program->getReaderMacro(*(yyvsp[0].s));
if ( macros.size()==0 ) {
das_yyerror(scanner,"reader macro " + *(yyvsp[0].s) + " not found",tokAt(scanner,(yylsp[0])),
CompilationError::unsupported_read_macro);
} else if ( macros.size()>1 ) {
string options;
for ( auto & x : macros ) {
options += "\t" + x->module->name + "::" + x->name + "\n";
}
das_yyerror(scanner,"too many options for the reader macro " + *(yyvsp[0].s) + "\n" + options, tokAt(scanner,(yylsp[0])),
CompilationError::unsupported_read_macro);
} else if ( yychar != '~' ) {
das_yyerror(scanner,"expecting ~ after the reader macro", tokAt(scanner,(yylsp[0])),
CompilationError::syntax_error);
} else {
yyextra->g_ReaderMacro = macros.back().get();
yyextra->g_ReaderExpr = new ExprReader(tokAt(scanner,(yylsp[-1])),yyextra->g_ReaderMacro);
yyclearin ;
das_yybegin_reader(scanner);
}
}
break;
case 33: /* expr_reader: '%' name_in_namespace $@1 reader_character_sequence */
{
yyextra->g_ReaderExpr->at = tokRangeAt(scanner,(yylsp[-3]),(yylsp[0]));
(yyval.pExpression) = yyextra->g_ReaderExpr;
delete (yyvsp[-2].s);
yyextra->g_ReaderMacro = nullptr;
yyextra->g_ReaderExpr = nullptr;
}
break;
case 34: /* options_declaration: "options" annotation_argument_list */
{
if ( yyextra->g_Program->options.size() ) {
yyextra->g_Program->options.insert ( yyextra->g_Program->options.begin(),
(yyvsp[0].aaList)->begin(), (yyvsp[0].aaList)->end() );
} else {
swap ( yyextra->g_Program->options, *(yyvsp[0].aaList) );
}
auto opt = yyextra->g_Program->options.find("indenting", tInt);
if (opt)
{
if (opt->iValue != 0 && opt->iValue != 2 && opt->iValue != 4 && opt->iValue != 8)//this is error
yyextra->das_tab_size = yyextra->das_def_tab_size;
else
yyextra->das_tab_size = opt->iValue ? opt->iValue : yyextra->das_def_tab_size;//0 is default
yyextra->g_FileAccessStack.back()->tabSize = yyextra->das_tab_size;
}
delete (yyvsp[0].aaList);
}
break;
case 36: /* require_module_name: "name" */
{
(yyval.s) = (yyvsp[0].s);
}
break;
case 37: /* require_module_name: '%' require_module_name */
{
*(yyvsp[0].s) = "%" + *(yyvsp[0].s);
(yyval.s) = (yyvsp[0].s);
}
break;
case 38: /* require_module_name: require_module_name '.' "name" */
{
*(yyvsp[-2].s) += ".";
*(yyvsp[-2].s) += *(yyvsp[0].s);
delete (yyvsp[0].s);
(yyval.s) = (yyvsp[-2].s);
}
break;
case 39: /* require_module_name: require_module_name '/' "name" */
{
*(yyvsp[-2].s) += "/";
*(yyvsp[-2].s) += *(yyvsp[0].s);
delete (yyvsp[0].s);
(yyval.s) = (yyvsp[-2].s);
}
break;
case 40: /* require_module: require_module_name is_public_module */
{
ast_requireModule(scanner,(yyvsp[-1].s),nullptr,(yyvsp[0].b),tokAt(scanner,(yylsp[-1])));
}
break;
case 41: /* require_module: require_module_name "as" "name" is_public_module */
{
ast_requireModule(scanner,(yyvsp[-3].s),(yyvsp[-1].s),(yyvsp[0].b),tokAt(scanner,(yylsp[-3])));
}
break;
case 42: /* is_public_module: %empty */
{ (yyval.b) = false; }
break;
case 43: /* is_public_module: "public" */
{ (yyval.b) = true; }
break;
case 47: /* expect_error: "integer constant" */
{
yyextra->g_Program->expectErrors[CompilationError((yyvsp[0].i))] ++;
}
break;
case 48: /* expect_error: "integer constant" ':' "integer constant" */
{
yyextra->g_Program->expectErrors[CompilationError((yyvsp[-2].i))] += (yyvsp[0].i);
}
break;
case 49: /* expression_label: "label" "integer constant" ':' */
{
(yyval.pExpression) = new ExprLabel(tokAt(scanner,(yylsp[-2])),(yyvsp[-1].i));
}
break;
case 50: /* expression_goto: "goto" "label" "integer constant" */
{
(yyval.pExpression) = new ExprGoto(tokAt(scanner,(yylsp[-2])),(yyvsp[0].i));
}
break;
case 51: /* expression_goto: "goto" expr */
{
(yyval.pExpression) = new ExprGoto(tokAt(scanner,(yylsp[-1])),ExpressionPtr((yyvsp[0].pExpression)));
}
break;
case 52: /* elif_or_static_elif: "elif" */
{ (yyval.b) = false; }
break;
case 53: /* elif_or_static_elif: "static_elif" */
{ (yyval.b) = true; }
break;
case 54: /* expression_else: %empty */
{ (yyval.pExpression) = nullptr; }
break;
case 55: /* expression_else: "else" expression_block */
{ (yyval.pExpression) = (yyvsp[0].pExpression); }
break;
case 56: /* expression_else: elif_or_static_elif expr expression_block expression_else */
{
auto eite = new ExprIfThenElse(tokAt(scanner,(yylsp[-3])),ExpressionPtr((yyvsp[-2].pExpression)),
ExpressionPtr((yyvsp[-1].pExpression)),ExpressionPtr((yyvsp[0].pExpression)));
eite->isStatic = (yyvsp[-3].b);
(yyval.pExpression) = eite;
}
break;
case 57: /* if_or_static_if: "if" */
{ (yyval.b) = false; }
break;
case 58: /* if_or_static_if: "static_if" */
{ (yyval.b) = true; }
break;
case 59: /* expression_if_then_else: if_or_static_if expr expression_block expression_else */
{
auto eite = new ExprIfThenElse(tokAt(scanner,(yylsp[-3])),ExpressionPtr((yyvsp[-2].pExpression)),
ExpressionPtr((yyvsp[-1].pExpression)),ExpressionPtr((yyvsp[0].pExpression)));
eite->isStatic = (yyvsp[-3].b);
(yyval.pExpression) = eite;
}
break;
case 60: /* expression_for_loop: "for" variable_name_with_pos_list "in" expr_list ';' expression_block */
{
(yyval.pExpression) = ast_forLoop(scanner,(yyvsp[-4].pNameWithPosList),(yyvsp[-2].pExpression),(yyvsp[0].pExpression),tokAt(scanner,(yylsp[-5])),tokAt(scanner,(yylsp[0])));
}
break;
case 61: /* expression_unsafe: "unsafe" expression_block */
{
auto pUnsafe = new ExprUnsafe(tokAt(scanner,(yylsp[-1])));
pUnsafe->body = ExpressionPtr((yyvsp[0].pExpression));
(yyval.pExpression) = pUnsafe;
}
break;
case 62: /* expression_while_loop: "while" expr expression_block */
{
auto pWhile = new ExprWhile(tokAt(scanner,(yylsp[-2])));
pWhile->cond = ExpressionPtr((yyvsp[-1].pExpression));
pWhile->body = ExpressionPtr((yyvsp[0].pExpression));
((ExprBlock *)(yyvsp[0].pExpression))->inTheLoop = true;
(yyval.pExpression) = pWhile;
}
break;
case 63: /* expression_with: "with" expr expression_block */
{
auto pWith = new ExprWith(tokAt(scanner,(yylsp[-2])));
pWith->with = ExpressionPtr((yyvsp[-1].pExpression));
pWith->body = ExpressionPtr((yyvsp[0].pExpression));
(yyval.pExpression) = pWith;
}
break;
case 64: /* $@2: %empty */
{ yyextra->das_need_oxford_comma=true; }
break;
case 65: /* expression_with_alias: "assume" "name" '=' $@2 expr */
{
(yyval.pExpression) = new ExprAssume(tokAt(scanner,(yylsp[-4])), *(yyvsp[-3].s), (yyvsp[0].pExpression) );
delete (yyvsp[-3].s);
}
break;
case 66: /* annotation_argument_value: string_constant */
{ (yyval.aa) = new AnnotationArgument("",*(yyvsp[0].s)); delete (yyvsp[0].s); }
break;
case 67: /* annotation_argument_value: "name" */
{ (yyval.aa) = new AnnotationArgument("",*(yyvsp[0].s)); delete (yyvsp[0].s); }
break;
case 68: /* annotation_argument_value: "integer constant" */
{ (yyval.aa) = new AnnotationArgument("",(yyvsp[0].i)); }
break;
case 69: /* annotation_argument_value: "floating point constant" */
{ (yyval.aa) = new AnnotationArgument("",float((yyvsp[0].fd))); }
break;
case 70: /* annotation_argument_value: "true" */
{ (yyval.aa) = new AnnotationArgument("",true); }
break;
case 71: /* annotation_argument_value: "false" */
{ (yyval.aa) = new AnnotationArgument("",false); }
break;
case 72: /* annotation_argument_value_list: annotation_argument_value */
{
(yyval.aaList) = new AnnotationArgumentList();
(yyval.aaList)->push_back(*(yyvsp[0].aa));
delete (yyvsp[0].aa);
}
break;
case 73: /* annotation_argument_value_list: annotation_argument_value_list ',' annotation_argument_value */
{
(yyval.aaList) = (yyvsp[-2].aaList);
(yyval.aaList)->push_back(*(yyvsp[0].aa));
delete (yyvsp[0].aa);
}
break;
case 74: /* annotation_argument_name: "name" */
{ (yyval.s) = (yyvsp[0].s); }
break;
case 75: /* annotation_argument_name: "type" */
{ (yyval.s) = new string("type"); }
break;
case 76: /* annotation_argument_name: "in" */
{ (yyval.s) = new string("in"); }
break;
case 77: /* annotation_argument: annotation_argument_name '=' string_constant */
{ (yyval.aa) = new AnnotationArgument(*(yyvsp[-2].s),*(yyvsp[0].s),tokAt(scanner,(yylsp[-2]))); delete (yyvsp[0].s); delete (yyvsp[-2].s); }
break;
case 78: /* annotation_argument: annotation_argument_name '=' "name" */
{ (yyval.aa) = new AnnotationArgument(*(yyvsp[-2].s),*(yyvsp[0].s),tokAt(scanner,(yylsp[-2]))); delete (yyvsp[0].s); delete (yyvsp[-2].s); }
break;
case 79: /* annotation_argument: annotation_argument_name '=' "integer constant" */
{ (yyval.aa) = new AnnotationArgument(*(yyvsp[-2].s),(yyvsp[0].i),tokAt(scanner,(yylsp[-2]))); delete (yyvsp[-2].s); }
break;
case 80: /* annotation_argument: annotation_argument_name '=' "floating point constant" */
{ (yyval.aa) = new AnnotationArgument(*(yyvsp[-2].s),float((yyvsp[0].fd)),tokAt(scanner,(yylsp[-2]))); delete (yyvsp[-2].s); }
break;
case 81: /* annotation_argument: annotation_argument_name '=' "true" */
{ (yyval.aa) = new AnnotationArgument(*(yyvsp[-2].s),true,tokAt(scanner,(yylsp[-2]))); delete (yyvsp[-2].s); }
break;
case 82: /* annotation_argument: annotation_argument_name '=' "false" */
{ (yyval.aa) = new AnnotationArgument(*(yyvsp[-2].s),false,tokAt(scanner,(yylsp[-2]))); delete (yyvsp[-2].s); }
break;
case 83: /* annotation_argument: annotation_argument_name */
{ (yyval.aa) = new AnnotationArgument(*(yyvsp[0].s),true,tokAt(scanner,(yylsp[0]))); delete (yyvsp[0].s); }
break;
case 84: /* annotation_argument: annotation_argument_name '=' '(' annotation_argument_value_list ')' */
{
{ (yyval.aa) = new AnnotationArgument(*(yyvsp[-4].s),(yyvsp[-1].aaList),tokAt(scanner,(yylsp[-4]))); delete (yyvsp[-4].s); }
}
break;
case 85: /* annotation_argument_list: annotation_argument */
{
(yyval.aaList) = ast_annotationArgumentListEntry(scanner,new AnnotationArgumentList(),(yyvsp[0].aa));
}
break;
case 86: /* annotation_argument_list: annotation_argument_list ',' annotation_argument */
{
(yyval.aaList) = ast_annotationArgumentListEntry(scanner,(yyvsp[-2].aaList),(yyvsp[0].aa));
}
break;
case 87: /* annotation_declaration_name: name_in_namespace */
{ (yyval.s) = (yyvsp[0].s); }
break;
case 88: /* annotation_declaration_name: "require" */
{ (yyval.s) = new string("require"); }
break;
case 89: /* annotation_declaration_name: "private" */
{ (yyval.s) = new string("private"); }
break;
case 90: /* annotation_declaration: annotation_declaration_name */
{
(yyval.fa) = new AnnotationDeclaration();
(yyval.fa)->at = tokAt(scanner,(yylsp[0]));
if ( auto ann = findAnnotation(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0]))) ) {
(yyval.fa)->annotation = ann;
}
delete (yyvsp[0].s);
}
break;
case 91: /* annotation_declaration: annotation_declaration_name '(' annotation_argument_list ')' */
{
(yyval.fa) = new AnnotationDeclaration();
(yyval.fa)->at = tokAt(scanner,(yylsp[-3]));
if ( auto ann = findAnnotation(scanner,*(yyvsp[-3].s),tokAt(scanner,(yylsp[-3]))) ) {
(yyval.fa)->annotation = ann;
}
swap ( (yyval.fa)->arguments, *(yyvsp[-1].aaList) );
delete (yyvsp[-1].aaList);
delete (yyvsp[-3].s);
}
break;
case 92: /* annotation_list: annotation_declaration */
{
(yyval.faList) = new AnnotationList();
(yyval.faList)->push_back(AnnotationDeclarationPtr((yyvsp[0].fa)));
}
break;
case 93: /* annotation_list: annotation_list ',' annotation_declaration */
{
(yyval.faList) = (yyvsp[-2].faList);
(yyval.faList)->push_back(AnnotationDeclarationPtr((yyvsp[0].fa)));
}
break;
case 94: /* optional_annotation_list: %empty */
{ (yyval.faList) = nullptr; }
break;
case 95: /* optional_annotation_list: '[' annotation_list ']' */
{ (yyval.faList) = (yyvsp[-1].faList); }
break;
case 96: /* optional_function_argument_list: %empty */
{ (yyval.pVarDeclList) = nullptr; }
break;
case 97: /* optional_function_argument_list: '(' ')' */
{ (yyval.pVarDeclList) = nullptr; }
break;
case 98: /* optional_function_argument_list: '(' function_argument_list ')' */
{ (yyval.pVarDeclList) = (yyvsp[-1].pVarDeclList); }
break;
case 99: /* optional_function_type: %empty */
{
(yyval.pTypeDecl) = new TypeDecl(Type::autoinfer);
}
break;
case 100: /* optional_function_type: ':' type_declaration */
{
(yyval.pTypeDecl) = (yyvsp[0].pTypeDecl);
(yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[0]));
}
break;
case 101: /* function_name: "name" */
{
das_checkName(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0])));
(yyval.s) = (yyvsp[0].s);
}
break;
case 102: /* function_name: "operator" '!' */
{ (yyval.s) = new string("!"); }
break;
case 103: /* function_name: "operator" '~' */
{ (yyval.s) = new string("~"); }
break;
case 104: /* function_name: "operator" "+=" */
{ (yyval.s) = new string("+="); }
break;
case 105: /* function_name: "operator" "-=" */
{ (yyval.s) = new string("-="); }
break;
case 106: /* function_name: "operator" "*=" */
{ (yyval.s) = new string("*="); }
break;
case 107: /* function_name: "operator" "/=" */
{ (yyval.s) = new string("/="); }
break;
case 108: /* function_name: "operator" "%=" */
{ (yyval.s) = new string("%="); }
break;
case 109: /* function_name: "operator" "&=" */
{ (yyval.s) = new string("&="); }
break;
case 110: /* function_name: "operator" "|=" */
{ (yyval.s) = new string("|="); }
break;
case 111: /* function_name: "operator" "^=" */
{ (yyval.s) = new string("^="); }
break;
case 112: /* function_name: "operator" "&&=" */
{ (yyval.s) = new string("&&="); }
break;
case 113: /* function_name: "operator" "||=" */
{ (yyval.s) = new string("||="); }
break;
case 114: /* function_name: "operator" "^^=" */
{ (yyval.s) = new string("^^="); }
break;
case 115: /* function_name: "operator" "&&" */
{ (yyval.s) = new string("&&"); }
break;
case 116: /* function_name: "operator" "||" */
{ (yyval.s) = new string("||"); }
break;
case 117: /* function_name: "operator" "^^" */
{ (yyval.s) = new string("^^"); }
break;
case 118: /* function_name: "operator" '+' */
{ (yyval.s) = new string("+"); }
break;
case 119: /* function_name: "operator" '-' */
{ (yyval.s) = new string("-"); }
break;
case 120: /* function_name: "operator" '*' */
{ (yyval.s) = new string("*"); }
break;
case 121: /* function_name: "operator" '/' */
{ (yyval.s) = new string("/"); }
break;
case 122: /* function_name: "operator" '%' */
{ (yyval.s) = new string("%"); }
break;
case 123: /* function_name: "operator" '' */
{ (yyval.s) = new string(">"); }
break;
case 125: /* function_name: "operator" ".." */
{ (yyval.s) = new string("interval"); }
break;
case 126: /* function_name: "operator" "==" */
{ (yyval.s) = new string("=="); }
break;
case 127: /* function_name: "operator" "!=" */
{ (yyval.s) = new string("!="); }
break;
case 128: /* function_name: "operator" "="); }
break;
case 130: /* function_name: "operator" '&' */
{ (yyval.s) = new string("&"); }
break;
case 131: /* function_name: "operator" '|' */
{ (yyval.s) = new string("|"); }
break;
case 132: /* function_name: "operator" '^' */
{ (yyval.s) = new string("^"); }
break;
case 133: /* function_name: "++" "operator" */
{ (yyval.s) = new string("++"); }
break;
case 134: /* function_name: "--" "operator" */
{ (yyval.s) = new string("--"); }
break;
case 135: /* function_name: "operator" "++" */
{ (yyval.s) = new string("+++"); }
break;
case 136: /* function_name: "operator" "--" */
{ (yyval.s) = new string("---"); }
break;
case 137: /* function_name: "operator" ""); }
break;
case 139: /* function_name: "operator" "="); }
break;
case 141: /* function_name: "operator" ""); }
break;
case 143: /* function_name: "operator" "="); }
break;
case 145: /* function_name: "operator" '[' ']' */
{ (yyval.s) = new string("[]"); }
break;
case 146: /* function_name: "operator" "?[" ']' */
{ (yyval.s) = new string("?[]"); }
break;
case 147: /* function_name: "operator" '.' */
{ (yyval.s) = new string("."); }
break;
case 148: /* function_name: "operator" "?." */
{ (yyval.s) = new string("?."); }
break;
case 149: /* function_name: "operator" ":=" */
{ (yyval.s) = new string("clone"); }
break;
case 150: /* function_name: "operator" "delete" */
{ (yyval.s) = new string("finalize"); }
break;
case 151: /* global_function_declaration: optional_annotation_list "def" function_declaration */
{
(yyvsp[0].pFuncDecl)->atDecl = tokRangeAt(scanner,(yylsp[-1]),(yylsp[0]));
assignDefaultArguments((yyvsp[0].pFuncDecl));
runFunctionAnnotations(scanner, (yyvsp[0].pFuncDecl), (yyvsp[-2].faList), tokAt(scanner,(yylsp[-2])));
if ( (yyvsp[0].pFuncDecl)->isGeneric() ) {
if ( !yyextra->g_Program->addGeneric((yyvsp[0].pFuncDecl)) ) {
das_yyerror(scanner,"generic function is already defined " +
(yyvsp[0].pFuncDecl)->getMangledName(),(yyvsp[0].pFuncDecl)->at,
CompilationError::function_already_declared);
}
} else {
if ( !yyextra->g_Program->addFunction((yyvsp[0].pFuncDecl)) ) {
das_yyerror(scanner,"function is already defined " +
(yyvsp[0].pFuncDecl)->getMangledName(),(yyvsp[0].pFuncDecl)->at,
CompilationError::function_already_declared);
}
}
(yyvsp[0].pFuncDecl)->delRef();
}
break;
case 152: /* optional_public_or_private_function: %empty */
{ (yyval.b) = yyextra->g_thisStructure ? !yyextra->g_thisStructure->privateStructure : yyextra->g_Program->thisModule->isPublic; }
break;
case 153: /* optional_public_or_private_function: "private" */
{ (yyval.b) = false; }
break;
case 154: /* optional_public_or_private_function: "public" */
{ (yyval.b) = true; }
break;
case 155: /* function_declaration_header: function_name optional_function_argument_list optional_function_type */
{
(yyval.pFuncDecl) = ast_functionDeclarationHeader(scanner,(yyvsp[-2].s),(yyvsp[-1].pVarDeclList),(yyvsp[0].pTypeDecl),tokAt(scanner,(yylsp[-2])));
}
break;
case 156: /* function_declaration: optional_public_or_private_function function_declaration_header expression_block */
{
(yyvsp[-1].pFuncDecl)->body = ExpressionPtr((yyvsp[0].pExpression));
(yyvsp[-1].pFuncDecl)->privateFunction = !(yyvsp[-2].b);
(yyval.pFuncDecl) = (yyvsp[-1].pFuncDecl);
}
break;
case 157: /* expression_block: '{' expressions '}' */
{
(yyval.pExpression) = (yyvsp[-1].pExpression);
(yyval.pExpression)->at = tokRangeAt(scanner,(yylsp[-2]),(yylsp[0]));
}
break;
case 158: /* expression_block: '{' expressions '}' "finally" '{' expressions '}' */
{
auto pB = (ExprBlock *) (yyvsp[-5].pExpression);
auto pF = (ExprBlock *) (yyvsp[-1].pExpression);
swap ( pB->finalList, pF->list );
(yyval.pExpression) = (yyvsp[-5].pExpression);
(yyval.pExpression)->at = tokRangeAt(scanner,(yylsp[-6]),(yylsp[0]));
delete (yyvsp[-1].pExpression);
}
break;
case 159: /* expression_any: ';' */
{ (yyval.pExpression) = nullptr; }
break;
case 160: /* expression_any: expr_pipe */
{ (yyval.pExpression) = (yyvsp[0].pExpression); }
break;
case 161: /* expression_any: expr_assign_pipe */
{ (yyval.pExpression) = (yyvsp[0].pExpression); }
break;
case 162: /* expression_any: expr_assign ';' */
{ (yyval.pExpression) = (yyvsp[-1].pExpression); }
break;
case 163: /* expression_any: expression_delete ';' */
{ (yyval.pExpression) = (yyvsp[-1].pExpression); }
break;
case 164: /* expression_any: expression_let */
{ (yyval.pExpression) = (yyvsp[0].pExpression); }
break;
case 165: /* expression_any: expression_while_loop */
{ (yyval.pExpression) = (yyvsp[0].pExpression); }
break;
case 166: /* expression_any: expression_unsafe */
{ (yyval.pExpression) = (yyvsp[0].pExpression); }
break;
case 167: /* expression_any: expression_with */
{ (yyval.pExpression) = (yyvsp[0].pExpression); }
break;
case 168: /* expression_any: expression_with_alias */
{ (yyval.pExpression) = (yyvsp[0].pExpression); }
break;
case 169: /* expression_any: expression_for_loop */
{ (yyval.pExpression) = (yyvsp[0].pExpression); }
break;
case 170: /* expression_any: expression_break ';' */
{ (yyval.pExpression) = (yyvsp[-1].pExpression); }
break;
case 171: /* expression_any: expression_continue ';' */
{ (yyval.pExpression) = (yyvsp[-1].pExpression); }
break;
case 172: /* expression_any: expression_return */
{ (yyval.pExpression) = (yyvsp[0].pExpression); }
break;
case 173: /* expression_any: expression_yield */
{ (yyval.pExpression) = (yyvsp[0].pExpression); }
break;
case 174: /* expression_any: expression_if_then_else */
{ (yyval.pExpression) = (yyvsp[0].pExpression); }
break;
case 175: /* expression_any: expression_try_catch */
{ (yyval.pExpression) = (yyvsp[0].pExpression); }
break;
case 176: /* expression_any: expression_label ';' */
{ (yyval.pExpression) = (yyvsp[-1].pExpression); }
break;
case 177: /* expression_any: expression_goto ';' */
{ (yyval.pExpression) = (yyvsp[-1].pExpression); }
break;
case 178: /* expression_any: "pass" ';' */
{ (yyval.pExpression) = nullptr; }
break;
case 179: /* expressions: %empty */
{
(yyval.pExpression) = new ExprBlock();
(yyval.pExpression)->at = LineInfo(yyextra->g_FileAccessStack.back(),
yylloc.first_column,yylloc.first_line,yylloc.last_column,yylloc.last_line);
}
break;
case 180: /* expressions: expressions expression_any */
{
(yyval.pExpression) = (yyvsp[-1].pExpression);
if ( (yyvsp[0].pExpression) ) {
static_cast((yyvsp[-1].pExpression))->list.push_back(ExpressionPtr((yyvsp[0].pExpression)));
}
}
break;
case 181: /* expressions: expressions error */
{
delete (yyvsp[-1].pExpression); (yyval.pExpression) = nullptr; YYABORT;
}
break;
case 182: /* expr_pipe: expr_assign "