| Hi Tito,
Thanks for reporting, I've added it to the bug tracker:
https://sourceforge.net/tracker/?group_id=81968&atid=564599
Cheers,
Andrés
On Sat, Nov 12, 2011 at 5:05 PM, Tito Latini wrote:
> Hi All, there is a bug with `#include' in the new parser (only for orc
> file or CsInstruments section in the csd file). The last line of a
> file included through `#include' is analyzed two times by the lexer.
> For example:
>
> ;; foo.txt
> prints "=== FIRST LINE ===\n"
> prints "=== SECOND LINE ===\n"
> prints "=== LAST LINE ===\n"
>
>
>
>
> #include "foo.txt"
> instr 1
> endin
>
>
> i1 0 0
>
>
>
>
> Tested with Csound 5.14, git commit 78d3db0ff720c7feec3914a20850aeeb75c084ef
>
> uname -a
> Linux pantera 2.6.33.7.2-rt30 #2 SMP PREEMPT RT Mon Oct 24 12:33:25 CEST 2011
> x86_64 AMD Phenom(tm) II X6 1090T Processor AuthenticAMD GNU/Linux
>
> csound -n include_test.csd
> ...
> ********************
> * USING NEW PARSER *
> ********************
> Testing...
> ...
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ...
> === FIRST LINE ===
> === SECOND LINE ===
> === LAST LINE ===
> === LAST LINE ===
> orch now loaded
> ...
>
>
> The cause is `PARM->buffer' (or yyextra->buffer) in csound_orc.l. The
> scanner works well in the buffer state "yypushed" in the `do_include'
> function, but after the `yypop_buffer_state', in the <> rule,
> PARM->buffer is still 'prints "=== LAST LINE ===\n"' and PARM->lBuffer
> is 31 (the lenght of PARM->buffer), so this buffered line will be
> analyzed again (in `get_next_char' used by `YY_INPUT'). A temporary
> solution is
>
>
> diff -ur csound5~/Engine/csound_orc.l csound5/Engine/csound_orc.l
> --- csound5~/Engine/csound_orc.l 2011-11-08 13:51:46.000000000 +0100
> +++ csound5/Engine/csound_orc.l 2011-11-12 17:36:27.000000000 +0100
> @@ -432,6 +432,8 @@
> yypop_buffer_state(yyscanner);
> if ( !YY_CURRENT_BUFFER ) yyterminate();
> printf("End of input; popping to %p\n", YY_CURRENT_BUFFER);
> + if (PARM->isInclude)
> + PARM->lBuffer = PARM->isInclude = 0;
> n = PARM->alt_stack[--PARM->macro_stack_ptr].n;
> printf("n=%d\n", n);
> if (n!=0) {
> @@ -530,6 +532,7 @@
> }
> PARM->alt_stack[PARM->macro_stack_ptr].n = 0;
> PARM->alt_stack[PARM->macro_stack_ptr++].s = NULL;
> + PARM->isInclude = 1;
> yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE, yyscanner), yyscanner);
> }
>
> diff -ur csound5~/Engine/parse_param.h csound5/Engine/parse_param.h
> --- csound5~/Engine/parse_param.h 2011-11-08 13:51:46.000000000 +0100
> +++ csound5/Engine/parse_param.h 2011-11-12 17:36:45.000000000 +0100
> @@ -30,6 +30,7 @@
> unsigned int macro_stack_ptr;
> char *xstrbuff;
> int xstrptr,xstrmax;
> + unsigned char isInclude;
> } PARSE_PARM;
>
> #define lMaxBuffer (1000)
>
>
> The `if' condition is necessary, otherwise the $NAME macro doesn't work.
>
> This is my first message, my English is *underground* but I know how to say
>
> Thank you very much for Csound
>
> tito
>
> ------------------------------------------------------------------------------
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-de |