<commit_before>%{

 /*
    csound_pre.l:

    Copyright (C) 2011
    <NAME>

    This file is part of Csound.

    The Csound Library is free software; you can redistribute it
    and/or modify it under the terms of the Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    Csound 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 Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with Csound; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MAc
    02111-1307 USA
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "csoundCore.h"
#include "corfile.h"
#define YY_DECL int yylex (CSOUND *csound, yyscan_t yyscanner)
static void comment(yyscan_t);
static void do_comment(yyscan_t);
static void do_include(CSOUND *, int, yyscan_t);
static void do_macro_arg(CSOUND *, char *, yyscan_t);
static void do_macro(CSOUND *, char *, yyscan_t);
static void do_umacro(CSOUND *, char *, yyscan_t);
static void do_ifdef(CSOUND *, char *, yyscan_t);
static void do_ifdef_skip_code(CSOUND *, yyscan_t);
static void do_function(char *, CORFIL*);
//static void print_csound_predata(CSOUND *,char *,yyscan_t);
static void csound_pre_line(CORFIL*, yyscan_t);
 static void delete_macros(CSOUND*, yyscan_t);
#include "parse_param.h"

#define YY_EXTRA_TYPE  PRE_PARM *
#define PARM    yyget_extra(yyscanner)

#define YY_USER_INIT {csound_pre_scan_string(csound->orchstr->body, yyscanner); \
    csound_preset_lineno(csound->orcLineOffset, yyscanner);             \
    yyg->yy_flex_debug_r=1; PARM->macro_stack_size = 0;                 \
    PARM->alt_stack = NULL; PARM->macro_stack_ptr = 0;                  \
  }
static MACRO *find_definition(MACRO *, char *);
%}
%option reentrant
%option noyywrap
%option prefix="csound_pre"
%option outfile="Engine/csound_prelex.c"
%option stdout

NEWLINE         (\n|\r\n?)
STSTR           \"
ESCAPE          \\.
XSTR            \{\{([^}]|\}[^}])*\}\}
IDENT           [a-zA-Z_][a-zA-Z0-9_]*
MACRONAME       "$"`?[a-zA-Z_][a-zA-Z0-9_`]*
MACRONAMED      "$"`?[a-zA-Z_][a-zA-Z0-9_`]*\.
MACRONAMEA      "$"`?[a-zA-Z_][a-zA-Z0-9_`]*\(
MACRONAMEDA     "$"`?[a-zA-Z_][a-zA-Z0-9_`]*\.\(
MACROB          [a-zA-Z_][a-zA-Z0-9_]*\(
MACRO           [a-zA-Z_][a-zA-Z0-9_]*

STCOM           \/\*
INCLUDE         "#include"
DEFINE          #[ \t]*define
UNDEF           "#undef"
IFDEF           #ifn?def
ELSE            #else[ \t]*(;.*)?$
END             #end(if)?[ \t]*(;.*)?(\n|\r\n?)
CONT            \\[ \t]*(;.*)?(\n|\r\n?)
RESET           "###\n"

INT             "int"[ \t]*\(
FRAC            "frac"[ \t]*\(
ROUND           "round"[ \t]*\(
FLOOR           "floor"[ \t]*\(
CEIL            "ceil"[ \t]*\(
RND             "rnd"[ \t]*\(
BIRND           "birnd"[ \t]*\(
ABS             "abs"[ \t]*\(
EXP             "exp"[ \t]*\(
LOG             "log"[ \t]*\(
SQRT            "sqrt"[ \t]*\(
SIN             "sin"[ \t]*\(
COS             "cos"[ \t]*\(
TAN             "tan"[ \t]*\(
SININV          "sininv"[ \t]*\(
COSINV          "cosinv"[ \t]*\(
TANINV          "taninv"[ \t]*\(
LOG10           "log10"[ \t]*\(
LOG2            "log2"[ \t]*\(
SINH            "sinh"[ \t]*\(
COSH            "cosh"[ \t]*\(
TANH            "tanh"[ \t]*\(
AMPDB           "ampdb"[ \t]*\(
AMPDBFS         "ampdbfs"[ \t]*\(
DBAMP           "dbamp"[ \t]*\(
DBFSAMP         "dbfsamp"[ \t]*\(
FTCPS           "ftcps"[ \t]*\(
FTLEN           "ftlen"[ \t]*\(
FTSR            "ftsr"[ \t]*\(
FTLPTIM         "ftlptim"[ \t]*\(
FTCHNLS         "ftchnls"[ \t]*\(
I               "i"[ \t]*\(
K               "k"[ \t]*\(
CPSOCT          "cpsoct"[ \t]*\(
OCTPCH          "octpch"[ \t]*\(
CPSPCH          "cpspch"[ \t]*\(
PCHOCT          "pchoct"[ \t]*\(
OCTCPS          "octcps"[ \t]*\(
NSAMP           "nsamp"[ \t]*\(
POWOFTWO        "powoftwo"[ \t]*\(
LOGBTWO         "logbtwo"[ \t]*\(
A               "a"[ \t]*\(
TB0             "tb0"[ \t]*\(
TB1             "tb1"[ \t]*\(
TB2             "tb2"[ \t]*\(
TB3             "tb3"[ \t]*\(
TB4             "tb4"[ \t]*\(
TB5             "tb5"[ \t]*\(
TB6             "tb6"[ \t]*\(
TB7             "tb7"[ \t]*\(
TB8             "tb8"[ \t]*\(
TB9             "tb9"[ \t]*\(
TB10            "tb10"[ \t]*\(
TB11            "tb11"[ \t]*\(
TB12            "tb12"[ \t]*\(
TB13            "tb13"[ \t]*\(
TB14            "tb14"[ \t]*\(
TB15            "tb15"[ \t]*\(
URD             "urd"[ \t]*\(
NOT             "not"[ \t]*\(
CENT            "cent"[ \t]*\(
OCTAVE          "octave"[ \t]*\(
SEMITONE        "semitone"[ \t]*\(
CPSMIDIN        "cpsmidinn"[ \t]*\(
OCTMIDIN        "octmidinn"[ \t]*\(
PCHMIDIN        "pchmidinn"[ \t]*\(
DB              "db"[ \t]*\(
P               "p"[ \t]*\(
QINF            "qinf"[ \t]*\(
QNAN            "qnan"[ \t]*\(

%X incl
%x macro
%x umacro
%x ifdef

%%

{RESET}         { csound_preset_lineno(csound->orcLineOffset, yyscanner);
                  csound->Free(csound, PARM->alt_stack);
                }
{CONT}          {
                  char bb[80];
                  csound_preset_lineno(1+csound_preget_lineno(yyscanner),
                                       yyscanner);
                  if (PARM->isString==0) {
                    sprintf(bb, "#sline %d ", csound_preget_lineno(yyscanner));
                    corfile_puts(bb, csound->expanded_orc);
                  }
                }
{NEWLINE}       {
                  corfile_putc('\n', csound->expanded_orc);
                  csound_preset_lineno(1+csound_preget_lineno(yyscanner),
                                       yyscanner);
                  csound_pre_line(csound->expanded_orc, yyscanner);
                }
"//"            {
                  if (PARM->isString != 1) {
                    comment(yyscanner);
                    corfile_putc('\n', csound->expanded_orc);
                    csound_pre_line(csound->expanded_orc, yyscanner);
                  }
                  else {
                    corfile_puts(yytext, csound->expanded_orc);
                  }
                }
";"             {
                  if (PARM->isString != 1) {
                    comment(yyscanner);
                    corfile_putc('\n', csound->expanded_orc);
                    csound_pre_line(csound->expanded_orc, yyscanner);
                  }
                  else {
                    corfile_puts(yytext, csound->expanded_orc);
                  }
                  //corfile_putline(csound_preget_lineno(yyscanner),
                  //                csound->expanded_orc);
                }
{STCOM}         {
                  if (PARM->isString != 1)
                    do_comment(yyscanner);
                  else
                    corfile_puts(yytext, csound->expanded_orc);
                }
{ESCAPE}        { corfile_puts(yytext, csound->expanded_orc); }
{STSTR}         {
                  corfile_putc('"', csound->expanded_orc);
                  PARM->isString = !PARM->isString;
                }
{XSTR}          {
                  char c, *str = yytext;
                  if (PARM->isString == 1)
                    yyless(2);
                  while ((c = *str++) != '\0') {
                    switch(c) {
                    case '\r': if (*str == '\n') continue;
                    case '\n':
                      csound_preset_lineno(1+csound_preget_lineno(yyscanner),
                                           yyscanner);
                      break;
                    default: break;
                    }
                  }
                  corfile_puts(yytext, csound->expanded_orc);
                }
{MACRONAME}     {
                   MACRO     *mm = PARM->macros;
                   mm = find_definition(mm, yytext+1);
                   if (UNLIKELY(mm == NULL)) {
                     csound->Message(csound,Str("Undefined macro: '%s'"), yytext);
                     csound->LongJmp(csound, 1);
                   }
                   /* Need to read from macro definition */
                   /* ??fiddle with buffers I guess */
                   if (UNLIKELY(PARM->macro_stack_ptr >= PARM->macro_stack_size )) {
                     PARM->alt_stack =
                       (MACRON*)
                       csound->ReAlloc(csound, PARM->alt_stack,
                                       sizeof(MACRON)*(PARM->macro_stack_size+=10));
                     if (UNLIKELY(PARM->alt_stack == NULL)) {
                       csound->Message(csound, Str("Memory exhausted"));
                       csound->LongJmp(csound, 1);
                     }
                     /* csound->DebugMsg(csound, "alt_stack now %d long\n", */
                     /*                  PARM->macro_stack_size); */
                   }
                   PARM->alt_stack[PARM->macro_stack_ptr].n = 0;
                   PARM->alt_stack[PARM->macro_stack_ptr].line =
                     csound_preget_lineno(yyscanner);
                   PARM->alt_stack[PARM->macro_stack_ptr++].s = NULL;
                   yypush_buffer_state(YY_CURRENT_BUFFER, yyscanner);
                   csound_preset_lineno(1, yyscanner);
                   if (PARM->depth>1022) {
                     csound->Message(csound,
                                     Str("macros/include nested too deep: "));
                     csound->LongJmp(csound, 1);
                   }
                   PARM->lstack[++PARM->depth] =
                     (strchr(mm->body,'\n') ?file_to_int(csound, yytext) : 63);
                   yy_scan_string(mm->body, yyscanner);
                   /* csound->DebugMsg(csound,"%p\n", YY_CURRENT_BUFFER); */
                }
{MACRONAMED}    {
                   MACRO     *mm = PARM->macros;
                   yytext[yyleng-1] = '\0';
                   mm = find_definition(mm, yytext+1);
                   if (UNLIKELY(mm == NULL)) {
                     csound->Message(csound,Str("Undefined macro: '%s'"), yytext);
                     csound->LongJmp(csound, 1);
                   }
                   /* Need to read from macro definition */
                   /* ??fiddle with buffers I guess */
                   if (UNLIKELY(PARM->macro_stack_ptr >= PARM->macro_stack_size )) {
                     PARM->alt_stack =
                       (MACRON*)
                       csound->ReAlloc(csound, PARM->alt_stack,
                                       sizeof(MACRON)*(PARM->macro_stack_size+=10));
                     if (UNLIKELY(PARM->alt_stack == NULL)) {
                       csound->Message(csound, Str("Memory exhausted"));
                       csound->LongJmp(csound, 1);
                     }
                     /* csound->DebugMsg(csound, "alt_stack now %d long\n", */
                     /*                  PARM->macro_stack_size); */
                   }
                   PARM->alt_stack[PARM->macro_stack_ptr].n = 0;
                   PARM->alt_stack[PARM->macro_stack_ptr].line =
                     csound_preget_lineno(yyscanner);
                   PARM->alt_stack[PARM->macro_stack_ptr++].s = NULL;
                   yypush_buffer_state(YY_CURRENT_BUFFER, yyscanner);
                   csound_preset_lineno(1, yyscanner);
                   if (PARM->depth>1022) {
                     csound->Message(csound,
                                     Str("macros/include nested too deep: "));
                     csound->LongJmp(csound, 1);
                   }
                   PARM->lstack[++PARM->depth] =
                     (strchr(mm->body,'\n') ?file_to_int(csound, yytext) : 63);
                   yy_scan_string(mm->body, yyscanner);
                   /* csound->DebugMsg(csound,"%p\n", YY_CURRENT_BUFFER); */
                 }
{MACRONAMEA}    {
                   MACRO     *mm = PARM->macros;
                   char      *mname;
                   int c, i, j, cnt=0;
                   //csound->DebugMsg(csound,"Macro with arguments call %s\n",
                   //                 yytext);
                   yytext[yyleng-1] = '\0';
                   mm = find_definition(PARM->macros, yytext+1);
                   if (UNLIKELY(mm == NULL)) {
                     csound->Message(csound,Str("Undefined macro: '%s'"), yytext);
                     csound->LongJmp(csound, 1);
                   }
                   mname = yytext;
                   /* Need to read from macro definition */
                   csound->DebugMsg(csound,"Looking for %d args\n", mm->acnt);
                   for (j = 0; j < mm->acnt; j++) {
                     char  term = (j == mm->acnt - 1 ? ')' : '\'');
 /* Compatability */
                     char  trm1 = (j == mm->acnt - 1 ? ')' : '#');
                     MACRO *nn = (MACRO*) csound->Malloc(csound, sizeof(MACRO));
                     int   size = 100;
                     if (UNLIKELY(nn == NULL)) {
                       csound->Message(csound, Str("Memory exhausted"));
                       csound->LongJmp(csound, 1);
                     }
                     nn->name = csound->Malloc(csound, strlen(mm->arg[j]) + 1);
                     if (UNLIKELY(nn->name == NULL)) {
                       csound->Message(csound, Str("Memory exhausted"));
                       csound->LongJmp(csound, 1);
                     }
                     csound->DebugMsg(csound,"Arg %d: %s\n", j+1, mm->arg[j]);
                     strcpy(nn->name, mm->arg[j]);
                     csound->Message(csound, "defining argument %s ",
                                        nn->name);
                     i = 0;
                     nn->body = (char*) csound->Malloc(csound, 100);
                     if (UNLIKELY(nn->body == NULL)) {
                       csound->Message(csound, Str("Memory exhausted"));
                       csound->LongJmp(csound, 1);
                     }
                     while (1) {
                       c = input(yyscanner);
                       if (c=='(') cnt++;
                       if (cnt==0 && ( c==term || c==trm1)) break;
                       if (cnt==0 && c == ')') {
                         csound->Die(csound, Str("Too few arguments to macro\n"));
                       }
                       if (c==')') cnt--;
                       if (c == '\\') {
                         int newc = input(yyscanner);
                         if (newc == ')')<commit_msg>small fix to macros with more than one argument<commit_after>%{

 /*
    csound_pre.l:

    Copyright (C) 2011
    <NAME>

    This file is part of Csound.

    The Csound Library is free software; you can redistribute it
    and/or modify it under the terms of the Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    Csound 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 Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with Csound; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MAc
    02111-1307 USA
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "csoundCore.h"
#include "corfile.h"
#define YY_DECL int yylex (CSOUND *csound, yyscan_t yyscanner)
static void comment(yyscan_t);
static void do_comment(yyscan_t);
static void do_include(CSOUND *, int, yyscan_t);
static void do_macro_arg(CSOUND *, char *, yyscan_t);
static void do_macro(CSOUND *, char *, yyscan_t);
static void do_umacro(CSOUND *, char *, yyscan_t);
static void do_ifdef(CSOUND *, char *, yyscan_t);
static void do_ifdef_skip_code(CSOUND *, yyscan_t);
static void do_function(char *, CORFIL*);
//static void print_csound_predata(CSOUND *,char *,yyscan_t);
static void csound_pre_line(CORFIL*, yyscan_t);
 static void delete_macros(CSOUND*, yyscan_t);
#include "parse_param.h"

#define YY_EXTRA_TYPE  PRE_PARM *
#define PARM    yyget_extra(yyscanner)

#define YY_USER_INIT {csound_pre_scan_string(csound->orchstr->body, yyscanner); \
    csound_preset_lineno(csound->orcLineOffset, yyscanner);             \
    yyg->yy_flex_debug_r=1; PARM->macro_stack_size = 0;                 \
    PARM->alt_stack = NULL; PARM->macro_stack_ptr = 0;                  \
  }
static MACRO *find_definition(MACRO *, char *);
%}
%option reentrant
%option noyywrap
%option prefix="csound_pre"
%option outfile="Engine/csound_prelex.c"
%option stdout

NEWLINE         (\n|\r\n?)
STSTR           \"
ESCAPE          \\.
XSTR            \{\{([^}]|\}[^}])*\}\}
IDENT           [a-zA-Z_][a-zA-Z0-9_]*
MACRONAME       "$"`?[a-zA-Z_][a-zA-Z0-9_`]*
MACRONAMED      "$"`?[a-zA-Z_][a-zA-Z0-9_`]*\.
MACRONAMEA      "$"`?[a-zA-Z_][a-zA-Z0-9_`]*\(
MACRONAMEDA     "$"`?[a-zA-Z_][a-zA-Z0-9_`]*\.\(
MACROB          [a-zA-Z_][a-zA-Z0-9_]*\(
MACRO           [a-zA-Z_][a-zA-Z0-9_]*

STCOM           \/\*
INCLUDE         "#include"
DEFINE          #[ \t]*define
UNDEF           "#undef"
IFDEF           #ifn?def
ELSE            #else[ \t]*(;.*)?$
END             #end(if)?[ \t]*(;.*)?(\n|\r\n?)
CONT            \\[ \t]*(;.*)?(\n|\r\n?)
RESET           "###\n"

INT             "int"[ \t]*\(
FRAC            "frac"[ \t]*\(
ROUND           "round"[ \t]*\(
FLOOR           "floor"[ \t]*\(
CEIL            "ceil"[ \t]*\(
RND             "rnd"[ \t]*\(
BIRND           "birnd"[ \t]*\(
ABS             "abs"[ \t]*\(
EXP             "exp"[ \t]*\(
LOG             "log"[ \t]*\(
SQRT            "sqrt"[ \t]*\(
SIN             "sin"[ \t]*\(
COS             "cos"[ \t]*\(
TAN             "tan"[ \t]*\(
SININV          "sininv"[ \t]*\(
COSINV          "cosinv"[ \t]*\(
TANINV          "taninv"[ \t]*\(
LOG10           "log10"[ \t]*\(
LOG2            "log2"[ \t]*\(
SINH            "sinh"[ \t]*\(
COSH            "cosh"[ \t]*\(
TANH            "tanh"[ \t]*\(
AMPDB           "ampdb"[ \t]*\(
AMPDBFS         "ampdbfs"[ \t]*\(
DBAMP           "dbamp"[ \t]*\(
DBFSAMP         "dbfsamp"[ \t]*\(
FTCPS           "ftcps"[ \t]*\(
FTLEN           "ftlen"[ \t]*\(
FTSR            "ftsr"[ \t]*\(
FTLPTIM         "ftlptim"[ \t]*\(
FTCHNLS         "ftchnls"[ \t]*\(
I               "i"[ \t]*\(
K               "k"[ \t]*\(
CPSOCT          "cpsoct"[ \t]*\(
OCTPCH          "octpch"[ \t]*\(
CPSPCH          "cpspch"[ \t]*\(
PCHOCT          "pchoct"[ \t]*\(
OCTCPS          "octcps"[ \t]*\(
NSAMP           "nsamp"[ \t]*\(
POWOFTWO        "powoftwo"[ \t]*\(
LOGBTWO         "logbtwo"[ \t]*\(
A               "a"[ \t]*\(
TB0             "tb0"[ \t]*\(
TB1             "tb1"[ \t]*\(
TB2             "tb2"[ \t]*\(
TB3             "tb3"[ \t]*\(
TB4             "tb4"[ \t]*\(
TB5             "tb5"[ \t]*\(
TB6             "tb6"[ \t]*\(
TB7             "tb7"[ \t]*\(
TB8             "tb8"[ \t]*\(
TB9             "tb9"[ \t]*\(
TB10            "tb10"[ \t]*\(
TB11            "tb11"[ \t]*\(
TB12            "tb12"[ \t]*\(
TB13            "tb13"[ \t]*\(
TB14            "tb14"[ \t]*\(
TB15            "tb15"[ \t]*\(
URD             "urd"[ \t]*\(
NOT             "not"[ \t]*\(
CENT            "cent"[ \t]*\(
OCTAVE          "octave"[ \t]*\(
SEMITONE        "semitone"[ \t]*\(
CPSMIDIN        "cpsmidinn"[ \t]*\(
OCTMIDIN        "octmidinn"[ \t]*\(
PCHMIDIN        "pchmidinn"[ \t]*\(
DB              "db"[ \t]*\(
P               "p"[ \t]*\(
QINF            "qinf"[ \t]*\(
QNAN            "qnan"[ \t]*\(

%X incl
%x macro
%x umacro
%x ifdef

%%

{RESET}         { csound_preset_lineno(csound->orcLineOffset, yyscanner);
                  csound->Free(csound, PARM->alt_stack);
                }
{CONT}          {
                  char bb[80];
                  csound_preset_lineno(1+csound_preget_lineno(yyscanner),
                                       yyscanner);
                  if (PARM->isString==0) {
                    sprintf(bb, "#sline %d ", csound_preget_lineno(yyscanner));
                    corfile_puts(bb, csound->expanded_orc);
                  }
                }
{NEWLINE}       {
                  corfile_putc('\n', csound->expanded_orc);
                  csound_preset_lineno(1+csound_preget_lineno(yyscanner),
                                       yyscanner);
                  csound_pre_line(csound->expanded_orc, yyscanner);
                }
"//"            {
                  if (PARM->isString != 1) {
                    comment(yyscanner);
                    corfile_putc('\n', csound->expanded_orc);
                    csound_pre_line(csound->expanded_orc, yyscanner);
                  }
                  else {
                    corfile_puts(yytext, csound->expanded_orc);
                  }
                }
";"             {
                  if (PARM->isString != 1) {
                    comment(yyscanner);
                    corfile_putc('\n', csound->expanded_orc);
                    csound_pre_line(csound->expanded_orc, yyscanner);
                  }
                  else {
                    corfile_puts(yytext, csound->expanded_orc);
                  }
                  //corfile_putline(csound_preget_lineno(yyscanner),
                  //                csound->expanded_orc);
                }
{STCOM}         {
                  if (PARM->isString != 1)
                    do_comment(yyscanner);
                  else
                    corfile_puts(yytext, csound->expanded_orc);
                }
{ESCAPE}        { corfile_puts(yytext, csound->expanded_orc); }
{STSTR}         {
                  corfile_putc('"', csound->expanded_orc);
                  PARM->isString = !PARM->isString;
                }
{XSTR}          {
                  char c, *str = yytext;
                  if (PARM->isString == 1)
                    yyless(2);
                  while ((c = *str++) != '\0') {
                    switch(c) {
                    case '\r': if (*str == '\n') continue;
                    case '\n':
                      csound_preset_lineno(1+csound_preget_lineno(yyscanner),
                                           yyscanner);
                      break;
                    default: break;
                    }
                  }
                  corfile_puts(yytext, csound->expanded_orc);
                }
{MACRONAME}     {
                   MACRO     *mm = PARM->macros;
                   mm = find_definition(mm, yytext+1);
                   if (UNLIKELY(mm == NULL)) {
                     csound->Message(csound,Str("Undefined macro: '%s'"), yytext);
                     csound->LongJmp(csound, 1);
                   }
                   /* Need to read from macro definition */
                   /* ??fiddle with buffers I guess */
                   if (UNLIKELY(PARM->macro_stack_ptr >= PARM->macro_stack_size )) {
                     PARM->alt_stack =
                       (MACRON*)
                       csound->ReAlloc(csound, PARM->alt_stack,
                                       sizeof(MACRON)*(PARM->macro_stack_size+=10));
                     if (UNLIKELY(PARM->alt_stack == NULL)) {
                       csound->Message(csound, Str("Memory exhausted"));
                       csound->LongJmp(csound, 1);
                     }
                     /* csound->DebugMsg(csound, "alt_stack now %d long\n", */
                     /*                  PARM->macro_stack_size); */
                   }
                   PARM->alt_stack[PARM->macro_stack_ptr].n = 0;
                   PARM->alt_stack[PARM->macro_stack_ptr].line =
                     csound_preget_lineno(yyscanner);
                   PARM->alt_stack[PARM->macro_stack_ptr++].s = NULL;
                   yypush_buffer_state(YY_CURRENT_BUFFER, yyscanner);
                   csound_preset_lineno(1, yyscanner);
                   if (PARM->depth>1022) {
                     csound->Message(csound,
                                     Str("macros/include nested too deep: "));
                     csound->LongJmp(csound, 1);
                   }
                   PARM->lstack[++PARM->depth] =
                     (strchr(mm->body,'\n') ?file_to_int(csound, yytext) : 63);
                   yy_scan_string(mm->body, yyscanner);
                   /* csound->DebugMsg(csound,"%p\n", YY_CURRENT_BUFFER); */
                }
{MACRONAMED}    {
                   MACRO     *mm = PARM->macros;
                   yytext[yyleng-1] = '\0';
                   mm = find_definition(mm, yytext+1);
                   if (UNLIKELY(mm == NULL)) {
                     csound->Message(csound,Str("Undefined macro: '%s'"), yytext);
                     csound->LongJmp(csound, 1);
                   }
                   /* Need to read from macro definition */
                   /* ??fiddle with buffers I guess */
                   if (UNLIKELY(PARM->macro_stack_ptr >= PARM->macro_stack_size )) {
                     PARM->alt_stack =
                       (MACRON*)
                       csound->ReAlloc(csound, PARM->alt_stack,
                                       sizeof(MACRON)*(PARM->macro_stack_size+=10));
                     if (UNLIKELY(PARM->alt_stack == NULL)) {
                       csound->Message(csound, Str("Memory exhausted"));
                       csound->LongJmp(csound, 1);
                     }
                     /* csound->DebugMsg(csound, "alt_stack now %d long\n", */
                     /*                  PARM->macro_stack_size); */
                   }
                   PARM->alt_stack[PARM->macro_stack_ptr].n = 0;
                   PARM->alt_stack[PARM->macro_stack_ptr].line =
                     csound_preget_lineno(yyscanner);
                   PARM->alt_stack[PARM->macro_stack_ptr++].s = NULL;
                   yypush_buffer_state(YY_CURRENT_BUFFER, yyscanner);
                   csound_preset_lineno(1, yyscanner);
                   if (PARM->depth>1022) {
                     csound->Message(csound,
                                     Str("macros/include nested too deep: "));
                     csound->LongJmp(csound, 1);
                   }
                   PARM->lstack[++PARM->depth] =
                     (strchr(mm->body,'\n') ?file_to_int(csound, yytext) : 63);
                   yy_scan_string(mm->body, yyscanner);
                   /* csound->DebugMsg(csound,"%p\n", YY_CURRENT_BUFFER); */
                 }
{MACRONAMEA}    {
                   MACRO     *mm = PARM->macros;
                   char      *mname;
                   int c, i, j, cnt=0;
                   //csound->DebugMsg(csound,"Macro with arguments call %s\n",
                   //                 yytext);
                   yytext[yyleng-1] = '\0';
                   mm = find_definition(PARM->macros, yytext+1);
                   if (UNLIKELY(mm == NULL)) {
                     csound->Message(csound,Str("Undefined macro: '%s'"), yytext);
                     csound->LongJmp(csound, 1);
                   }
                   mname = yytext;
                   /* Need to read from macro definition */
                   csound->DebugMsg(csound,"Looking for %d args\n", mm->acnt);
                   for (j = 0; j < mm->acnt; j++) {
                     char  term = (j == mm->acnt - 1 ? ')' : '\'');
 /* Compatability */
                     char  trm1 = (j == mm->acnt - 1 ? ')' : '#');
                     MACRO *nn = (MACRO*) csound->Malloc(csound, sizeof(MACRO));
                     int   size = 100;
                     if (UNLIKELY(nn == NULL)) {
                       csound->Message(csound, Str("Memory exhausted"));
                       csound->LongJmp(csound, 1);
                     }
                     nn->name = csound->Malloc(csound, strlen(mm->arg[j]) + 1);
                     if (UNLIKELY(nn->name == NULL)) {
                       csound->Message(csound, Str("Memory exhausted"));
                       csound->LongJmp(csound, 1);
                     }
                     csound->DebugMsg(csound,"Arg %d: %s\n", j+1, mm->arg[j]);
                     strcpy(nn->name, mm->arg[j]);
                     csound->Message(csound, "defining argument %s ",
                                        nn->name);
                     i = 0;
                     nn->body = (char*) csound->Malloc(csound, 100);
                     if (UNLIKELY(nn->body == NULL)) {
                       csound->Message(csound, Str("Memory exhausted"));
                       csound->LongJmp(csound, 1);
                     }
                     while (1) {
                       c = input(yyscanner);
                       if (cnt==0 && ( c==term || c==trm1)) break;
                       if (cnt==0 && c == ')') {
                         csound->Die(csound, Str("Too few arguments to macro\n"));
                       }
                       if (c=='(') cnt++;
                       if (c==')') cnt--;
                       if (c == '\\') {
                         int newc = input(yyscanner);
                         if (newc == ')')
{'fraction_non_alphanumeric': 0.14900048086831078, 'fraction_numerical': 0.010579102837123034, 'mean_word_length': 1.2463544479592623, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 257, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4361982', 'n_tokens_mistral': 9932, 'n_tokens_neox': 9056, 'n_words': 1758}