From MAILER-DAEMON Tue May 01 13:47:25 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HiwRh-0002hv-1Z for mharc-help-bison@gnu.org; Tue, 01 May 2007 13:47:25 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HiwRf-0002fr-LG for help-bison@gnu.org; Tue, 01 May 2007 13:47:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HiwRf-0002eu-6U for Help-bison@gnu.org; Tue, 01 May 2007 13:47:23 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HiwRe-0002eW-V4 for Help-bison@gnu.org; Tue, 01 May 2007 13:47:22 -0400 Received: from www.nabble.com ([72.21.53.35] helo=talk.nabble.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HiwLK-00047z-M1 for Help-bison@gnu.org; Tue, 01 May 2007 13:40:50 -0400 Received: from [72.21.53.38] (helo=jubjub.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1HiwLJ-0005c4-MC for Help-bison@gnu.org; Tue, 01 May 2007 10:40:49 -0700 Message-ID: <10272023.post@talk.nabble.com> Date: Tue, 1 May 2007 09:40:37 -0700 (PDT) From: Leviathan To: Help-bison@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: hmmmp@hotmail.com X-detected-kernel: Linux 2.4-2.6 Cc: Subject: Change yylex name X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2007 17:47:23 -0000 Hi everybody, My intention is to change yylex name to e.g my_yylex . I have read in bison's gnu manual that such thing is possible via the %name-prefix="my_yy" directive but it will also change prefix for yyparse , yyerror etc. I just want to change yylex's name and keep the default names for the rest .Is there a way to do that? Thanx in advance -- View this message in context: http://www.nabble.com/Change-yylex-name-tf3675999.html#a10272023 Sent from the Gnu - Bison - Help mailing list archive at Nabble.com. From MAILER-DAEMON Wed May 02 07:06:39 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HjCfP-000834-IY for mharc-help-bison@gnu.org; Wed, 02 May 2007 07:06:39 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HjCfO-00082r-8x for help-bison@gnu.org; Wed, 02 May 2007 07:06:38 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HjCfM-00082X-Pr for Help-bison@gnu.org; Wed, 02 May 2007 07:06:37 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HjCfM-00082U-Kh for Help-bison@gnu.org; Wed, 02 May 2007 07:06:36 -0400 Received: from ch-smtp02.sth.basefarm.net ([80.76.149.213]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HjCYx-0001tq-4f for Help-bison@gnu.org; Wed, 02 May 2007 06:59:59 -0400 Received: from c83-250-192-69.bredband.comhem.se ([83.250.192.69]:49828) by ch-smtp02.sth.basefarm.net with esmtp (Exim 4.63) (envelope-from ) id 1HjCYv-0000hn-7n; Wed, 02 May 2007 12:59:57 +0200 In-Reply-To: <10272023.post@talk.nabble.com> References: <10272023.post@talk.nabble.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <5FE715AA-A332-4146-A3BD-B654CE6463A1@math.su.se> Content-Transfer-Encoding: 7bit From: Hans Aberg Date: Wed, 2 May 2007 12:59:50 +0200 To: Leviathan X-Mailer: Apple Mail (2.752.2) X-Scan-Result: No virus found in message 1HjCYv-0000hn-7n. X-Scan-Signature: ch-smtp02.sth.basefarm.net 1HjCYv-0000hn-7n 7582acc477d46859e3f636039b39ca0d X-detected-kernel: Linux 2.6? (barebone, rare!) Cc: Help-bison@gnu.org Subject: Re: Change yylex name X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2007 11:06:38 -0000 On 1 May 2007, at 18:40, Leviathan wrote: > My intention is to change yylex name to e.g my_yylex . I have read in > bison's gnu manual that such thing is possible via the %name- > prefix="my_yy" > directive but it will also change prefix for yyparse , yyerror etc. > I just > want to change yylex's name and keep the default names for the > rest .Is > there a way to do that? I doubt it, because the idea is to create a name space, avoiding name conflicts in case one uses more than one parser. Instead, define a new function calling it, or if that is not possible, use the C/C++ preprocessor, something like: #define yylex my_yy ... /* Changes yylex -> my_yy here */ #undef yylex Hans Aberg From MAILER-DAEMON Wed May 02 09:12:29 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HjEdB-0008NQ-Nj for mharc-help-bison@gnu.org; Wed, 02 May 2007 09:12:29 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HjEdA-0008Mv-Ea for help-bison@gnu.org; Wed, 02 May 2007 09:12:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HjEd8-0008Mf-TH for Help-bison@gnu.org; Wed, 02 May 2007 09:12:28 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HjEd8-0008Ma-Nu for Help-bison@gnu.org; Wed, 02 May 2007 09:12:26 -0400 Received: from ch-smtp01.sth.basefarm.net ([80.76.149.212]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HjEWi-0004In-Ar for Help-bison@gnu.org; Wed, 02 May 2007 09:05:48 -0400 Received: from c83-250-192-69.bredband.comhem.se ([83.250.192.69]:49857) by ch-smtp01.sth.basefarm.net with esmtp (Exim 4.63) (envelope-from ) id 1HjEWT-0007uf-43 for Help-bison@gnu.org; Wed, 02 May 2007 15:05:33 +0200 Resent-Message-Id: <6247a8cb0705020529i4c811eaaxc624c69f4b54f004@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v752.2) Resent-Date: Wed, 2 May 2007 15:05:30 +0200 Message-Id: <356A5446-77CE-4103-966F-3A4CC6EFE0A0@gmail.com> Resent-To: Bison Help From: "Arun K V" Resent-From: Hans Aberg Date: Wed, 2 May 2007 17:59:45 +0530 To: haberg@math.su.se X-Mailer: Apple Mail (2.752.2) X-Scan-Result: No virus found in message 1HjEWT-0007uf-43. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1HjEWT-0007uf-43 34589e2e33b0d6b862d01652a8e4db6b X-detected-kernel: Linux 2.6? (barebone, rare!) Resent-Date: Wed, 02 May 2007 09:12:28 -0400 Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: How to make the parser thread safe ? X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2007 13:12:28 -0000 Hi, To make parser thread safe, should i just declare a variable in my yacc file like this %pure-parser (as seen in the second line of my code given below) will it do everything to make my parser thread safe . should i use other locks and all in my code. what else should i take care along along with declaring %pure-parser to make my parser thread safe. i am a beginner in the field of lex and yacc .. please do help me.... expecting a reply .... thanks in advance Arun ------------------------------------------------------------------------ -------------------------------------------- %name Parser %pure-parser %header{ #define YYDEBUG 1 #define YYPRINTF 1 #define YYMAXDEPTH 600000 #define YYINITDEPTH 5000 #define YYSTYPE char * %} ------------------------------------------------------------------------ -------------------------------------------- From MAILER-DAEMON Wed May 02 09:23:16 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HjEnc-00050P-Cv for mharc-help-bison@gnu.org; Wed, 02 May 2007 09:23:16 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HjEna-0004w7-Q1 for help-bison@gnu.org; Wed, 02 May 2007 09:23:14 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HjEnX-0004uf-Oq for help-bison@gnu.org; Wed, 02 May 2007 09:23:14 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HjEnX-0004uc-HL for help-bison@gnu.org; Wed, 02 May 2007 09:23:11 -0400 Received: from [203.199.83.36] (helo=rediffmail.com) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1HjEh6-0005ci-TF for help-bison@gnu.org; Wed, 02 May 2007 09:16:33 -0400 Received: (qmail 1398 invoked by uid 510); 2 May 2007 13:15:49 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=redf; d=rediffmail.com; b=qfMdqqIgjz6QXQ12teYjEi1EBCPDiITtQaNMQuOxmjj6ZLGy/CyaiTJHclXWZ7NF0j0y0Arow+WEH4z9Tcu8Wt/Ev61IX2DHtA2WH055iDcFbsmlYn0q3tMfziEMklBpEelwxrpoIs3vTKltvb6tA2nNVlCczOKACgnJyFhwcgo= ; Date: 2 May 2007 13:15:49 -0000 Message-ID: <20070502131549.1396.qmail@webmail64.rediffmail.com> Received: from unknown (202.131.155.13) by rediffmail.com via HTTP; 02 may 2007 13:15:49 -0000 MIME-Version: 1.0 From: "arun kv" To: help-bison@gnu.org X-detected-kernel: Linux 2.6? (barebone, rare!) Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: how to make parser thread safe ? X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: arun kv List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2007 13:23:15 -0000 =A0Hi,=0A =0ATo make parser thread safe, should i just declare a variable= in my yacc file like this %pure-parser (as seen in the second line of my c= ode given below)=0A =0Awill it do everything to make my parser thread safe = . should i use other locks and all in my code.=0A =0Awhat else should i tak= e care along along with declaring %pure-parser to make my parser thread saf= e.=0A =0Ai am a beginner in the field of lex and yacc ..=0Aplease do help m= e....=0A =0Aexpecting a reply ....=0A =0Athanks in advance =0AArun=0A =0A--= ---------------------------------------------------------------------------= ---------------------------------------=0A%name Parser=0A =0A%pure-parser= =0A%header{=0A=0A#define YYDEBUG 1=0A#define YYPRINTF 1=0A#define = YYMAXDEPTH 600000=0A#define YYINITDEPTH 5000=0A#define YYSTYPE char *= =0A=0A%}=0A=0A-------------------------------------------------------------= -------------------------------------------------------=0A=0A=0A=0A=0A From MAILER-DAEMON Wed May 02 09:29:47 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HjEtu-0003pI-V1 for mharc-help-bison@gnu.org; Wed, 02 May 2007 09:29:47 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HjEtt-0003jO-CU for help-bison@gnu.org; Wed, 02 May 2007 09:29:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HjEts-0003gq-H2 for Help-bison@gnu.org; Wed, 02 May 2007 09:29:44 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HjEts-0003gO-Bi for Help-bison@gnu.org; Wed, 02 May 2007 09:29:44 -0400 Received: from www.nabble.com ([72.21.53.35] helo=talk.nabble.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HjEnS-0006hP-AS for Help-bison@gnu.org; Wed, 02 May 2007 09:23:06 -0400 Received: from [72.21.53.38] (helo=jubjub.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1HjEnR-0004o0-8s for Help-bison@gnu.org; Wed, 02 May 2007 06:23:05 -0700 Message-ID: <10285968.post@talk.nabble.com> Date: Wed, 2 May 2007 06:23:05 -0700 (PDT) From: Leviathan To: Help-bison@gnu.org In-Reply-To: <5FE715AA-A332-4146-A3BD-B654CE6463A1@math.su.se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: hmmmp@hotmail.com References: <10272023.post@talk.nabble.com> <5FE715AA-A332-4146-A3BD-B654CE6463A1@math.su.se> X-detected-kernel: Linux 2.4-2.6 Cc: Subject: Re: Change yylex name X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2007 13:29:45 -0000 Hans Aberg wrote: > > On 1 May 2007, at 18:40, Leviathan wrote: > >> My intention is to change yylex name to e.g my_yylex . I have read in >> bison's gnu manual that such thing is possible via the %name- >> prefix="my_yy" >> directive but it will also change prefix for yyparse , yyerror etc. >> I just >> want to change yylex's name and keep the default names for the >> rest .Is >> there a way to do that? > > I doubt it, because the idea is to create a name space, avoiding name > conflicts in case one uses more than one parser. Instead, define a > new function calling it, or if that is not possible, use the C/C++ > preprocessor, something like: > #define yylex my_yy > ... /* Changes yylex -> my_yy here */ > #undef yylex > > Hans Aberg > > First of all thanx a lot for your time.I am a bit confused about what you're suggesting . I have used gnu-flex to generate a lexer. The point is that i have created a wrapper function which calls int yylex() whose name is for instance my_yylex and has a different signature lets say int my_yylex( char * pointer , int * pointer2 , float * pointer2 ) ; This function apart from calling yylex() has some additional functionality . My question actually is : Is there any way that i can get bison to call this function instead of calling yylex() ?I hope i made some sense .Thanx again _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison -- View this message in context: http://www.nabble.com/Change-yylex-name-tf3675999.html#a10285968 Sent from the Gnu - Bison - Help mailing list archive at Nabble.com. From MAILER-DAEMON Wed May 02 11:55:01 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HjHAT-0003oA-0e for mharc-help-bison@gnu.org; Wed, 02 May 2007 11:55:01 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HivVP-0004X2-5d for help-bison@gnu.org; Tue, 01 May 2007 12:47:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HivVO-0004Wd-If for Help-bison@gnu.org; Tue, 01 May 2007 12:47:10 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HivVO-0004WW-9E for Help-bison@gnu.org; Tue, 01 May 2007 12:47:10 -0400 Received: from www.nabble.com ([72.21.53.35] helo=talk.nabble.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HivP4-0004Lc-8n for Help-bison@gnu.org; Tue, 01 May 2007 12:40:38 -0400 Received: from [72.21.53.38] (helo=jubjub.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1HivP3-0002Jn-7z for Help-bison@gnu.org; Tue, 01 May 2007 09:40:37 -0700 Message-ID: <10272023.post@talk.nabble.com> Date: Tue, 1 May 2007 09:40:37 -0700 (PDT) From: Leviathan To: Help-bison@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: hmmmp@hotmail.com X-detected-kernel: Linux 2.4-2.6 X-Mailman-Approved-At: Wed, 02 May 2007 11:54:59 -0400 Cc: Subject: Change yylex name X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2007 16:47:11 -0000 Hi everybody, My intention is to change yylex name to e.g my_yylex . I have read in bison's gnu manual that such thing is possible via the %name-prefix="my_yy" directive but it will also change prefix for yyparse , yyerror etc. I just want to change yylex's name and keep the default names for the rest .Is there a way to do that? Thanx in advance -- View this message in context: http://www.nabble.com/Change-yylex-name-tf3675999.html#a10272023 Sent from the Gnu - Bison - Help mailing list archive at Nabble.com. From MAILER-DAEMON Wed May 02 14:00:29 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HjJ7s-00032A-Lo for mharc-help-bison@gnu.org; Wed, 02 May 2007 14:00:28 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HjJ7r-00030X-FX for help-bison@gnu.org; Wed, 02 May 2007 14:00:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HjJ7p-0002ym-P9 for Help-bison@gnu.org; Wed, 02 May 2007 14:00:26 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HjJ7p-0002yS-GE for Help-bison@gnu.org; Wed, 02 May 2007 14:00:25 -0400 Received: from ch-smtp01.sth.basefarm.net ([80.76.149.212]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HjJ1O-0006HU-3G for Help-bison@gnu.org; Wed, 02 May 2007 13:53:46 -0400 Received: from c83-250-192-69.bredband.comhem.se ([83.250.192.69]:50159) by ch-smtp01.sth.basefarm.net with esmtp (Exim 4.63) (envelope-from ) id 1HjJ1M-0005EG-40; Wed, 02 May 2007 19:53:44 +0200 In-Reply-To: <10285968.post@talk.nabble.com> References: <10272023.post@talk.nabble.com> <5FE715AA-A332-4146-A3BD-B654CE6463A1@math.su.se> <10285968.post@talk.nabble.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Hans Aberg Date: Wed, 2 May 2007 19:53:40 +0200 To: Leviathan X-Mailer: Apple Mail (2.752.2) X-Scan-Result: No virus found in message 1HjJ1M-0005EG-40. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1HjJ1M-0005EG-40 70819afcc5c8e392f094a8f0816576c5 X-detected-kernel: Linux 2.6? (barebone, rare!) Cc: Help-bison@gnu.org Subject: Re: Change yylex name X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2007 18:00:27 -0000 On 2 May 2007, at 15:23, Leviathan wrote: > I have used gnu-flex to generate a lexer. The point is that i > have created a wrapper function which calls int yylex() whose name > is for > instance my_yylex and has a different signature lets say int > my_yylex( char > * pointer , int * pointer2 , float * pointer2 ) ; > This function apart from calling yylex() has some additional > functionality . > My question actually is : Is there any way that i can get bison to > call this > function instead of calling yylex() ?I hope i made some > sense .Thanx again See the Bison 2.3 manual, sec. 4.2.4, "Calling Conventions for Pure Parsers". When you invoke %pure-parser, the arguments of the parser and lexer functions can be set by %parse-param and %lex-param. Hans Aberg From MAILER-DAEMON Wed May 02 16:05:51 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HjL5D-000226-Gv for mharc-help-bison@gnu.org; Wed, 02 May 2007 16:05:51 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HjL5B-00021I-Mg for help-bison@gnu.org; Wed, 02 May 2007 16:05:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HjL5B-000216-89 for Help-bison@gnu.org; Wed, 02 May 2007 16:05:49 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HjL5B-00020z-3h for Help-bison@gnu.org; Wed, 02 May 2007 16:05:49 -0400 Received: from www.nabble.com ([72.21.53.35] helo=talk.nabble.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HjKyj-0001N0-84 for Help-bison@gnu.org; Wed, 02 May 2007 15:59:09 -0400 Received: from [72.21.53.38] (helo=jubjub.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1HjKyh-00064Z-Vb for Help-bison@gnu.org; Wed, 02 May 2007 12:59:07 -0700 Message-ID: <10293526.post@talk.nabble.com> Date: Wed, 2 May 2007 12:59:07 -0700 (PDT) From: Leviathan To: Help-bison@gnu.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: hmmmp@hotmail.com References: <10272023.post@talk.nabble.com> <5FE715AA-A332-4146-A3BD-B654CE6463A1@math.su.se> <10285968.post@talk.nabble.com> X-detected-kernel: Linux 2.4-2.6 Cc: Subject: Re: Change yylex name X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2007 20:05:49 -0000 Hans Aberg wrote: > > On 2 May 2007, at 15:23, Leviathan wrote: > >> I have used gnu-flex to generate a lexer. The point is that i >> have created a wrapper function which calls int yylex() whose name >> is for >> instance my_yylex and has a different signature lets say int >> my_yylex( char >> * pointer , int * pointer2 , float * pointer2 ) ; >> This function apart from calling yylex() has some additional >> functionality . >> My question actually is : Is there any way that i can get bison to >> call this >> function instead of calling yylex() ?I hope i made some >> sense .Thanx again > > See the Bison 2.3 manual, sec. 4.2.4, "Calling Conventions for Pure > Parsers". When you invoke %pure-parser, the arguments of the parser > and lexer functions can be set by %parse-param and %lex-param. > > Hans Aberg > > Hi Hans, I 've already read this section but still the problem remains. It is ok about the arguments however it does not provide a way to rename the yylex function . I did also a little search of my own throughout the web and i got more confused . From what i've read about the topic it seems that such thing isn't possible due to preserving the namespace which you mentioned earlier. So it is time for plan B i.e. move the functionality from the wrapper function to yylex .Thanx once again Hans -- View this message in context: http://www.nabble.com/Change-yylex-name-tf3675999.html#a10293526 Sent from the Gnu - Bison - Help mailing list archive at Nabble.com. From MAILER-DAEMON Wed May 02 17:28:11 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HjMMt-0005G4-7z for mharc-help-bison@gnu.org; Wed, 02 May 2007 17:28:11 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HjMMr-00058P-3e for help-bison@gnu.org; Wed, 02 May 2007 17:28:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HjMMp-00057w-EY for Help-bison@gnu.org; Wed, 02 May 2007 17:28:08 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HjMMp-00057t-AV for Help-bison@gnu.org; Wed, 02 May 2007 17:28:07 -0400 Received: from ch-smtp02.sth.basefarm.net ([80.76.149.213]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HjMGM-00041g-U4 for Help-bison@gnu.org; Wed, 02 May 2007 17:21:27 -0400 Received: from c83-250-192-69.bredband.comhem.se ([83.250.192.69]:50456) by ch-smtp02.sth.basefarm.net with esmtp (Exim 4.63) (envelope-from ) id 1HjMGK-0001YG-8e; Wed, 02 May 2007 23:21:25 +0200 In-Reply-To: <10293526.post@talk.nabble.com> References: <10272023.post@talk.nabble.com> <5FE715AA-A332-4146-A3BD-B654CE6463A1@math.su.se> <10285968.post@talk.nabble.com> <10293526.post@talk.nabble.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <72AC0D59-1AE4-4408-85EE-50D405E9531A@math.su.se> Content-Transfer-Encoding: 7bit From: Hans Aberg Date: Wed, 2 May 2007 23:21:21 +0200 To: Leviathan X-Mailer: Apple Mail (2.752.2) X-Scan-Result: No virus found in message 1HjMGK-0001YG-8e. X-Scan-Signature: ch-smtp02.sth.basefarm.net 1HjMGK-0001YG-8e fec2d6919ed2b195fbb308499f4fc473 X-detected-kernel: Linux 2.6? (barebone, rare!) Cc: Help-bison@gnu.org Subject: Re: Change yylex name X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2007 21:28:09 -0000 On 2 May 2007, at 21:59, Leviathan wrote: >> See the Bison 2.3 manual, sec. 4.2.4, "Calling Conventions for Pure >> Parsers". When you invoke %pure-parser, the arguments of the parser >> and lexer functions can be set by %parse-param and %lex-param. > I 've already read this section but still the problem remains. It > is ok > about the arguments however it does not provide a way to rename the > yylex > function . I did also a little search of my own throughout the web > and i got > more confused . From what i've read about the topic it seems that > such thing > isn't possible due to preserving the namespace which you mentioned > earlier. > So it is time for plan B i.e. move the functionality from the wrapper > function to yylex . At least older versions of Bison just writes a macro as I indicated #define yylex mylex ... Hans Aberg From MAILER-DAEMON Tue May 08 12:37:37 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HlSgz-0000pL-0a for mharc-help-bison@gnu.org; Tue, 08 May 2007 12:37:37 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HlSgx-0000p6-9v for help-bison@gnu.org; Tue, 08 May 2007 12:37:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HlSgu-0000mg-Ed for help-bison@gnu.org; Tue, 08 May 2007 12:37:34 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HlSgu-0000mH-Bn for help-bison@gnu.org; Tue, 08 May 2007 12:37:32 -0400 Received: from vsmtp1.tin.it ([212.216.176.141]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HlSZm-00089X-W6 for help-bison@gnu.org; Tue, 08 May 2007 12:30:11 -0400 Received: from debsim2.localnet (87.18.191.189) by vsmtp1.tin.it (7.2.072.1) id 464012490009FBAD for help-bison@gnu.org; Tue, 8 May 2007 18:30:07 +0200 Received: from localhost ([127.0.0.1] ident=stefano) by debsim2.localnet with esmtp (Exim 4.67) (envelope-from ) id 1HlSZk-0002eI-LL for help-bison@gnu.org; Tue, 08 May 2007 18:30:08 +0200 From: Stefano Simonucci To: help-bison@gnu.org Content-Type: multipart/mixed; boundary="=-H/AQX75XwWxlERsBG9X2" Date: Tue, 08 May 2007 18:30:08 +0200 Message-Id: <1178641808.8665.6.camel@debsim2.localnet> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 X-detected-kernel: Solaris 8 (1) Subject: Language with comments X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 May 2007 16:37:35 -0000 --=-H/AQX75XwWxlERsBG9X2 Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi! I try to make a syntactic recognizer. In the language can be included also comments of the type " # ". I have made two files: prova.lex and prova.y for flex and bison. A comment consists of a list (also empty) of identifier. But I get always syntax errors. We enclose the files prova.lex, prova.y, a file for the compilation (compila) and an input file (prova.E) Thank you. Stefano -- Stefano Simonucci GNU/Linux User: #81790 http://counter.li.org --=-H/AQX75XwWxlERsBG9X2 Content-Disposition: attachment; filename=prova.lex Content-Type: text/plain; name=prova.lex; charset=us-ascii Content-Transfer-Encoding: 7bit %{ #include %} delim [ \t\n] ws {delim}+ letter [A-Za-z] digit [0-9] id {letter}({letter}|{digit})* num {digit}+|{digit}+\.{digit}*|{digit}+\.{digit}*{digit}*e\-{digit}+ %% {ws} { printf("\n"); return '\n'; } {id} { strcpy(yylval.lexeme, yytext); printf("%s ",yytext); return ID; } {num} { strcpy(yylval.lexeme, yytext); return NUM; } "+" return '+'; "-" return '-'; "*" return '*'; "/" return '/'; "(" return '('; ")" return ')'; "," return ','; "=" return '='; "#" { printf("#"); return '#'; } --=-H/AQX75XwWxlERsBG9X2 Content-Disposition: attachment; filename=prova.y Content-Type: text/plain; name=prova.y; charset=us-ascii Content-Transfer-Encoding: 7bit %{ #include %} %union { char lexeme[100+1]; } %token ID %token NUM %left '+' '-' %left '*' '/' %right UNIMINUS UNIPLUS '#' %start init %type term %% init : /* empty */ | init line ; line : '\n' | '#' comment '\n' ; comment : /* empty line */ | comment term term : ID {sprintf($$,"%s",$1); } | NUM {sprintf($$,"%s",$1); } ; %% #include "lex.yy.c" int main() { return yyparse(); } --=-H/AQX75XwWxlERsBG9X2 Content-Disposition: attachment; filename=compila Content-Type: application/x-shellscript; name=compila Content-Transfer-Encoding: 7bit #! /bin/bash flex $1.lex bison $1.y gcc -g -O0 -o $1 $1.tab.c -lfl -ly --=-H/AQX75XwWxlERsBG9X2 Content-Disposition: attachment; filename=prova.E Content-Type: text/plain; name=prova.E; charset=us-ascii Content-Transfer-Encoding: 7bit reticolo=set(vecX,vecY); typefunction fespace(reticolo Q) { double A(Q.Nx,Q.Ny); symbol R=Q; } reticolo Q; VQ=fespace(Q); --=-H/AQX75XwWxlERsBG9X2-- From MAILER-DAEMON Tue May 08 12:52:57 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HlSvp-0003lN-Cz for mharc-help-bison@gnu.org; Tue, 08 May 2007 12:52:57 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HlSvm-0003iA-RW for help-bison@gnu.org; Tue, 08 May 2007 12:52:54 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HlSvk-0003f1-9t for help-bison@gnu.org; Tue, 08 May 2007 12:52:53 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HlSvk-0003ec-4W for help-bison@gnu.org; Tue, 08 May 2007 12:52:52 -0400 Received: from vsmtp4.tin.it ([212.216.176.224]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HlSod-0001D8-6g for help-bison@gnu.org; Tue, 08 May 2007 12:45:31 -0400 Received: from debsim2.localnet (87.18.191.189) by vsmtp4.tin.it (7.2.072.1) id 46408DBC0001D71C for help-bison@gnu.org; Tue, 8 May 2007 18:45:30 +0200 Received: from localhost ([127.0.0.1] ident=stefano) by debsim2.localnet with esmtp (Exim 4.67) (envelope-from ) id 1HlSod-0002f9-Ap for help-bison@gnu.org; Tue, 08 May 2007 18:45:31 +0200 From: Stefano Simonucci To: help-bison@gnu.org In-Reply-To: <1178641808.8665.6.camel@debsim2.localnet> References: <1178641808.8665.6.camel@debsim2.localnet> Content-Type: text/plain Date: Tue, 08 May 2007 18:45:31 +0200 Message-Id: <1178642731.8665.11.camel@debsim2.localnet> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-detected-kernel: Solaris 8 (1) Subject: Re: Language with comments X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 May 2007 16:52:55 -0000 On Tue, 2007-05-08 at 18:30 +0200, Stefano Simonucci wrote: > Hi! > I try to make a syntactic recognizer. In the language can be included > also comments of the type " # ". > I have made two files: prova.lex and prova.y for flex and bison. > A comment consists of a list (also empty) of identifier. > But I get always syntax errors. > We enclose the files prova.lex, prova.y, a file for the compilation > (compila) and an input file (prova.E) > Thank you. > Stefano > The file prova.E is wrong. The correct one is the following cat prova.E # # AA # -- Stefano Simonucci GNU/Linux User: #81790 http://counter.li.org From MAILER-DAEMON Tue May 08 14:06:16 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HlU4l-0001Hh-VM for mharc-help-bison@gnu.org; Tue, 08 May 2007 14:06:16 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HlU4k-0001BP-FQ for help-bison@gnu.org; Tue, 08 May 2007 14:06:14 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HlU4i-00016P-V6 for help-bison@gnu.org; Tue, 08 May 2007 14:06:13 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HlU4i-00016D-Qv for help-bison@gnu.org; Tue, 08 May 2007 14:06:12 -0400 Received: from web81912.mail.mud.yahoo.com ([68.142.207.191]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1HlTxb-0000yT-HD for help-bison@gnu.org; Tue, 08 May 2007 13:58:51 -0400 Received: (qmail 94353 invoked by uid 60001); 8 May 2007 17:58:39 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=swbell.net; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Message-ID; b=ZzgUk3g4QYKq/94nsl+BDmYfcV9c85/BCqDWPlnYr3QfuZ4lfgTwNwBZzvEDIiG6VKvF3sWj9FUvA/YW6FQQBWVIqtwZt2GmwI9G38CMeD5i+GdF+YXwjKRbRSBbLrEIxS1aWYNq53MVepCZhLBlgjdUelFiafnu1CdVrGduFWQ=; X-YMail-OSG: G3InCIkVM1kM81bYuTGEJL_QqNSViyohhex8koebzxDI2EsGI2IWXNaMio0MqX1vPrsgkVkatwD5niPF1d5EaCZuatkFvMCOhlJK3BX21WocwMUJT_8- Received: from [75.33.112.96] by web81912.mail.mud.yahoo.com via HTTP; Tue, 08 May 2007 10:58:39 PDT X-Mailer: YahooMailRC/478 YahooMailWebService/0.7.41.10 Date: Tue, 8 May 2007 10:58:37 -0700 (PDT) From: Kelly Leahy To: Stefano Simonucci , help-bison@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Message-ID: <538796.94038.qm@web81912.mail.mud.yahoo.com> X-detected-kernel: FreeBSD 4.7-5.2 (or MacOS X 10.2-10.4) (2) Cc: Subject: Re: Language with comments X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 May 2007 18:06:15 -0000 Stefano, You should recognize the entire comment in one lexical pass, and should NOT return the '#' token. In other words, treat the '#' begun comment as whitespace - do the same for it that you do for whitespace. Write a regular expression for single-line comments that matches everything to the end of the line (\n char). Kelly ----- Original Message ---- From: Stefano Simonucci To: help-bison@gnu.org Sent: Tuesday, May 8, 2007 11:30:08 AM Subject: Language with comments Hi! I try to make a syntactic recognizer. In the language can be included also comments of the type " # ". I have made two files: prova.lex and prova.y for flex and bison. A comment consists of a list (also empty) of identifier. But I get always syntax errors. We enclose the files prova.lex, prova.y, a file for the compilation (compila) and an input file (prova.E) Thank you. Stefano -- Stefano Simonucci GNU/Linux User: #81790 http://counter.li.org %{ #include %} delim [ \t\n] ws {delim}+ letter [A-Za-z] digit [0-9] id {letter}({letter}|{digit})* num {digit}+|{digit}+\.{digit}*|{digit}+\.{digit}*{digit}*e\-{digit}+ %% {ws} { printf("\n"); return '\n'; } {id} { strcpy(yylval.lexeme, yytext); printf("%s ",yytext); return ID; } {num} { strcpy(yylval.lexeme, yytext); return NUM; } "+" return '+'; "-" return '-'; "*" return '*'; "/" return '/'; "(" return '('; ")" return ')'; "," return ','; "=" return '='; "#" { printf("#"); return '#'; } %{ #include %} %union { char lexeme[100+1]; } %token ID %token NUM %left '+' '-' %left '*' '/' %right UNIMINUS UNIPLUS '#' %start init %type term %% init : /* empty */ | init line ; line : '\n' | '#' comment '\n' ; comment : /* empty line */ | comment term term : ID {sprintf($$,"%s",$1); } | NUM {sprintf($$,"%s",$1); } ; %% #include "lex.yy.c" int main() { return yyparse(); } reticolo=set(vecX,vecY); typefunction fespace(reticolo Q) { double A(Q.Nx,Q.Ny); symbol R=Q; } reticolo Q; VQ=fespace(Q); _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison From MAILER-DAEMON Thu May 10 05:21:37 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Hm4q9-0003Pv-0B for mharc-help-bison@gnu.org; Thu, 10 May 2007 05:21:37 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hm4q3-0003Lm-M1 for help-bison@gnu.org; Thu, 10 May 2007 05:21:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hm4q2-0003If-Nr for Help-bison@gnu.org; Thu, 10 May 2007 05:21:30 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hm4q1-0003IB-JC for Help-bison@gnu.org; Thu, 10 May 2007 05:21:30 -0400 Received: from kuber.nabble.com ([216.139.236.158]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Hm4ii-0001IG-Nw for Help-bison@gnu.org; Thu, 10 May 2007 05:13:57 -0400 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Hm4ih-0004Ej-Lf for Help-bison@gnu.org; Thu, 10 May 2007 02:13:55 -0700 Message-ID: <10394471.post@talk.nabble.com> Date: Wed, 9 May 2007 06:40:41 -0700 (PDT) From: Xaris To: Help-bison@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Nabble-From: xaroulis@gmail.com X-detected-kernel: Linux 2.6 (newer, 3) Cc: Subject: interpreter with bison X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 May 2007 09:21:32 -0000 I have made the parse tree with bison of a like html language which finds i= f the input file is written correctly or not. But i want to add code in order to make an interpreter which takes as input the like html language and as output it gives the html code. for example i want to give as input=20 Hello World and the output will be like this =09 gfdsa
Hello World
--=20 View this message in context: http://www.nabble.com/interpreter-with-bison-= tf3715814.html#a10394471 Sent from the Gnu - Bison - Help mailing list archive at Nabble.com. From MAILER-DAEMON Thu May 10 09:28:56 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Hm8hU-0005aW-Er for mharc-help-bison@gnu.org; Thu, 10 May 2007 09:28:56 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hm8hR-0005ZR-Tq for help-bison@gnu.org; Thu, 10 May 2007 09:28:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hm8hQ-0005ZF-4A for Help-bison@gnu.org; Thu, 10 May 2007 09:28:53 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hm8hP-0005ZC-Ri for Help-bison@gnu.org; Thu, 10 May 2007 09:28:51 -0400 Received: from wx-out-0506.google.com ([66.249.82.236]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hm8a5-0004w3-W6 for Help-bison@gnu.org; Thu, 10 May 2007 09:21:18 -0400 Received: by wx-out-0506.google.com with SMTP id s17so543340wxc for ; Thu, 10 May 2007 06:21:16 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ofQNi7c7j30H77ydbUOkSTHZLeNYg0hOkR+4ZWBVQZna+Z17Aqai9itH6Nb+17Oux/glLFmaNPNeN2cVsY1XIyYScLh8DesIqxRWTsNcbetAlcwO60vDXShAoWbxu0wbLhB9Nz7uoO3s0BS1MNUz8B4a3mKBgMBZcTfVZz9Nb8k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=GMe72McYmKCTptxBGs5tvr+73PsXAvZnnWztArAHz7MH1WEigdILTkPTMyqOC1+Z/i7x15n+/uew7L/Jvp4TnA9wmUkjFSpmU0Qr5J5dODhKBsSkHD0lEzyQ4WevRukGvU34xBA02lXGpWra2+pyVK5dmGkKiHG4AkqqHuAJKOw= Received: by 10.90.29.18 with SMTP id c18mr1465871agc.1178803276439; Thu, 10 May 2007 06:21:16 -0700 (PDT) Received: by 10.90.119.1 with HTTP; Thu, 10 May 2007 06:21:16 -0700 (PDT) Message-ID: Date: Thu, 10 May 2007 08:21:16 -0500 From: Satya To: Xaris In-Reply-To: <10394471.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <10394471.post@talk.nabble.com> X-detected-kernel: Linux 2.4-2.6 (Google crawlbot) Cc: Help-bison@gnu.org Subject: Re: interpreter with bison X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 May 2007 13:28:54 -0000 It looks like you are reinventing XSLT here :) Your html like language looks like XML to me, but it would not be valid XML since you do not have closing tags for all the elements. If you still prefer to write your custom parser you just have to make use of Bison's semantic actions. Read the Bison manual about how to use them. satya. On 5/9/07, Xaris wrote: > > I have made the parse tree with bison of a like html language which finds if > the input file is written correctly or not. > > But i want to add code in order to make an interpreter which takes as input > the like html language and as output it gives the html code. > > for example i want to give as input > > > > > Hello > World > > > and the output will be like this > > > > > > gfdsa > > > > > > > > > >
HelloWorld
> > > > > > -- > View this message in context: http://www.nabble.com/interpreter-with-bison-tf3715814.html#a10394471 > Sent from the Gnu - Bison - Help mailing list archive at Nabble.com. > > > > _______________________________________________ > help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison > -- ...what's remarkable, is that atoms have assembled into entities which are somehow able to ponder their origins. -- http://cs.uic.edu/~spopuri From MAILER-DAEMON Thu May 10 15:29:34 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HmEKU-0005YB-RH for mharc-help-bison@gnu.org; Thu, 10 May 2007 15:29:34 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HlmWa-0004pX-Bx for help-bison@gnu.org; Wed, 09 May 2007 09:48:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HlmWY-0004nF-Ox for Help-bison@gnu.org; Wed, 09 May 2007 09:48:11 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HlmWY-0004nB-Gt for Help-bison@gnu.org; Wed, 09 May 2007 09:48:10 -0400 Received: from kuber.nabble.com ([216.139.236.158]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HlmPL-0004KF-HK for Help-bison@gnu.org; Wed, 09 May 2007 09:40:43 -0400 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1HlmPJ-0000rJ-4W for Help-bison@gnu.org; Wed, 09 May 2007 06:40:41 -0700 Message-ID: <10394471.post@talk.nabble.com> Date: Wed, 9 May 2007 06:40:41 -0700 (PDT) From: Xaris To: Help-bison@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Nabble-From: xaroulis@gmail.com X-detected-kernel: Linux 2.6 (newer, 3) X-Mailman-Approved-At: Thu, 10 May 2007 15:29:32 -0400 Cc: Subject: interpreter with bison X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 May 2007 13:48:12 -0000 I have made the parse tree with bison of a like html language which finds i= f the input file is written correctly or not. But i want to add code in order to make an interpreter which takes as input the like html language and as output it gives the html code. for example i want to give as input=20 Hello World and the output will be like this =09 gfdsa
Hello World
--=20 View this message in context: http://www.nabble.com/interpreter-with-bison-= tf3715814.html#a10394471 Sent from the Gnu - Bison - Help mailing list archive at Nabble.com. From MAILER-DAEMON Thu May 10 16:48:29 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HmFYq-0003pC-Sl for mharc-help-bison@gnu.org; Thu, 10 May 2007 16:48:28 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HmFYo-0003os-Go for help-bison@gnu.org; Thu, 10 May 2007 16:48:26 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HmFYn-0003og-00 for Help-bison@gnu.org; Thu, 10 May 2007 16:48:25 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HmFYm-0003od-Ph for Help-bison@gnu.org; Thu, 10 May 2007 16:48:24 -0400 Received: from ch-smtp02.sth.basefarm.net ([80.76.149.213]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HmFRQ-0007bB-Lq for Help-bison@gnu.org; Thu, 10 May 2007 16:40:48 -0400 Received: from c83-250-192-69.bredband.comhem.se ([83.250.192.69]:50613) by ch-smtp02.sth.basefarm.net with esmtp (Exim 4.66) (envelope-from ) id 1HmFRP-0007dK-6m; Thu, 10 May 2007 22:40:47 +0200 In-Reply-To: <10394471.post@talk.nabble.com> References: <10394471.post@talk.nabble.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <6DD8BA6F-D6D0-4095-83EE-5AD406975822@math.su.se> Content-Transfer-Encoding: 7bit From: Hans Aberg Date: Thu, 10 May 2007 22:40:44 +0200 To: Xaris X-Mailer: Apple Mail (2.752.2) X-Scan-Result: No virus found in message 1HmFRP-0007dK-6m. X-Scan-Signature: ch-smtp02.sth.basefarm.net 1HmFRP-0007dK-6m 970df71f0e28bd9c37614bb150716873 X-detected-kernel: Linux 2.6? (barebone, rare!) Cc: Help-bison@gnu.org Subject: Re: interpreter with bison X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 May 2007 20:48:27 -0000 On 9 May 2007, at 15:40, Xaris wrote: > I have made the parse tree with bison of a like html language which > finds if > the input file is written correctly or not. > > But i want to add code in order to make an interpreter which takes > as input > the like html language and as output it gives the html code. As Satya pointed out, you might investigate similar solutions first, in order to save work. Perhaps the Usenet newsgroup comp.compilers can give you an input. But one method is to check what semantical structures, say in the form of ASTs (Abstract Syntax Trees), the HTML language produce, and how to write them back into HTML. Then you merely parse your language into those ASTs, and write it out as HTML. The AST differs from the parse tree in that for example parenthesizes are being removed, resulting in an operator structure. The parenthesizes can then be put back by checking the relative precedence of the operator and the argument. For example, suppose one language uses infix notation, like A => B, and the other prefix notation, => A B, then. Both get the AST => / \ A B And it is not difficult to write it out in either language. Hans Aberg From MAILER-DAEMON Sat May 19 08:44:23 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HpOIJ-0005DH-7t for mharc-help-bison@gnu.org; Sat, 19 May 2007 08:44:23 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HpOIG-0005D5-Uc for help-bison@gnu.org; Sat, 19 May 2007 08:44:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HpOIE-0005Ct-I2 for help-bison@gnu.org; Sat, 19 May 2007 08:44:19 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HpOIE-0005Cq-AY for help-bison@gnu.org; Sat, 19 May 2007 08:44:18 -0400 Received: from nz-out-0506.google.com ([64.233.162.232]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HpOIE-0006br-0D for help-bison@gnu.org; Sat, 19 May 2007 08:44:18 -0400 Received: by nz-out-0506.google.com with SMTP id x7so1520395nzc for ; Sat, 19 May 2007 05:44:16 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=lJcO6i1Q8kQciOzZQ8XypynVwi8spWuri3l9sQSN+G4PBB7VNDzrjETYgkjRISMiHbDuwOm/ljSvgCrGzcIB+r45Cq/f0nRby2sZWgqBc3BwUwNJWTJ3isBqDqfuvt8RIGUDoeHlerRuwJFcSKQ1D1jTh5IYyBAOdDl4fgRc5hg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=LjFnZaXNkWo7gK/GnGFyz1vIl9gB0Hswq6wY7U599NyF8v/KltePuWyu2GPJ4A6npRJHylAP16c/qEeKI95xQjErcCkN5Su6wK0qCHLDu8VCmDVesk7x0MBIuByIOSrdzsr9HziZEG7ZKNI907+AeyWysmKKltWMje8cPp6/37Q= Received: by 10.114.75.1 with SMTP id x1mr1408223waa.1179578656496; Sat, 19 May 2007 05:44:16 -0700 (PDT) Received: by 10.114.95.12 with HTTP; Sat, 19 May 2007 05:44:16 -0700 (PDT) Message-ID: Date: Sat, 19 May 2007 13:44:16 +0100 From: "Rob Quill" To: help-bison@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-detected-kernel: Linux 2.4-2.6 (Google crawlbot) Subject: Todo List? X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 May 2007 12:44:21 -0000 Hi, I was wondering if there wasa sort of todo list for Bison? As in a list of projects which need doing, as I am looking for a project to work on im my spare time. Rob From MAILER-DAEMON Sat May 19 10:23:59 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HpPqg-00017I-LP for mharc-help-bison@gnu.org; Sat, 19 May 2007 10:23:58 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HpPqe-000152-3B for help-bison@gnu.org; Sat, 19 May 2007 10:23:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HpPqY-00011O-Hb for help-bison@gnu.org; Sat, 19 May 2007 10:23:52 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HpPqY-00011G-7E for help-bison@gnu.org; Sat, 19 May 2007 10:23:50 -0400 Received: from wx-out-0506.google.com ([66.249.82.224]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HpPqX-0000bu-TW for help-bison@gnu.org; Sat, 19 May 2007 10:23:50 -0400 Received: by wx-out-0506.google.com with SMTP id s17so1179002wxc for ; Sat, 19 May 2007 07:23:48 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=fYQERPuFDsLnMU82I2ZhOB9Nr+TkFSYUqfaftHvx2YYRFmhvMoZZ+cpDxklkWlwLTMo7+BvOdW4t/9OZYAnE5l105+qmh75u60BojkvFXZ3L/TuueqTWbT8powQvgn5CqTFO0Dln0megYQf42dIanQjWqV4L8hjMRefcJKHDnys= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=VD8e3oy+Wj5V5J3FFq67FMYAWsK4nzQl4NI9AMWyUmFDjLFM7vyzoPyZKT8+TSZdsJtJNzlg4s40BdYbjwrMx9LAzzcIlzaVHCgHKEHABq8PBy51mGRus2Z0lmXmmKg27BuKSf/02IpSSamSKcz+vZRIpuh2j9TcHzUfIz8jaMY= Received: by 10.90.81.14 with SMTP id e14mr2562610agb.1179584628860; Sat, 19 May 2007 07:23:48 -0700 (PDT) Received: by 10.90.119.1 with HTTP; Sat, 19 May 2007 07:23:48 -0700 (PDT) Message-ID: Date: Sat, 19 May 2007 09:23:48 -0500 From: Satya To: "Rob Quill" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-detected-kernel: Linux 2.4-2.6 (Google crawlbot) Cc: help-bison@gnu.org Subject: Re: Todo List? X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 May 2007 14:23:57 -0000 There is a TODO file in the Bison cvs distribution. You can look here: http://cvs.savannah.gnu.org/viewvc/bison/TODO?revision=1.100&root=bison&view=markup On 5/19/07, Rob Quill wrote: > Hi, > > I was wondering if there wasa sort of todo list for Bison? As in a > list of projects which need doing, as I am looking for a project to > work on im my spare time. > > Rob > > > _______________________________________________ > help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison > -- ...what's remarkable, is that atoms have assembled into entities which are somehow able to ponder their origins. -- http://cs.uic.edu/~spopuri From MAILER-DAEMON Wed May 23 04:46:28 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HqmUD-0004oK-Em for mharc-help-bison@gnu.org; Wed, 23 May 2007 04:46:25 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HqmTy-0004TG-BG for help-bison@gnu.org; Wed, 23 May 2007 04:46:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HqmTt-0004Kk-7A for Help-bison@gnu.org; Wed, 23 May 2007 04:46:07 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HqmTs-0004Jp-Mm for Help-bison@gnu.org; Wed, 23 May 2007 04:46:04 -0400 Received: from kuber.nabble.com ([216.139.236.158]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HqmTr-0000hn-EU for Help-bison@gnu.org; Wed, 23 May 2007 04:46:03 -0400 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1HqmTl-00036S-QW for Help-bison@gnu.org; Wed, 23 May 2007 01:45:57 -0700 Message-ID: <10759771.post@talk.nabble.com> Date: Wed, 23 May 2007 01:45:57 -0700 (PDT) From: JPerez45 To: Help-bison@gnu.org In-Reply-To: <844247.18455.qm@web32112.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: delimitaciones45@netscape.net References: <844247.18455.qm@web32112.mail.mud.yahoo.com> X-detected-kernel: Linux 2.6 (newer, 3) Cc: Subject: Re: How to add "error" X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 May 2007 08:46:12 -0000 If this error it's not a token, if it's an error handler then you could redefine the yyerror function: yyerror(message) char *message; { fprintf(stderr, "%s near '%s'\n", message, yytext); exit(1); }; And everytime a syntactic error occurs it will display: kind_of_error 'near' text before the error ocurred. YACC and Bison includes so many usefull functions. -- View this message in context: http://www.nabble.com/How-to-add-%22error%22-tf3556241.html#a10759771 Sent from the Gnu - Bison - Help mailing list archive at Nabble.com. From MAILER-DAEMON Thu May 24 05:14:21 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Hr9On-0001SD-1p for mharc-help-bison@gnu.org; Thu, 24 May 2007 05:14:21 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hr9Oj-0001S6-7w for help-bison@gnu.org; Thu, 24 May 2007 05:14:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hr9Oe-0001Ru-J7 for help-bison@gnu.org; Thu, 24 May 2007 05:14:16 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hr9Od-0001Rr-Sw for help-bison@gnu.org; Thu, 24 May 2007 05:14:12 -0400 Received: from nz-out-0506.google.com ([64.233.162.235]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hr9Oc-0000gG-Qm for help-bison@gnu.org; Thu, 24 May 2007 05:14:11 -0400 Received: by nz-out-0506.google.com with SMTP id z3so423936nzf for ; Thu, 24 May 2007 02:14:04 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=HH4B61aPVH1HafCj0+lpg5D6wHgsUq9Dmw+A/V358Q2RCj33wsrUBEhtCcE3N5O8IRE3zvCD9aPk+XzPBnh1arFfM9lj0Nb6jk2EQ58OesKm566gz8fWxdVt1Q/RD4KoIQanEJYO05E0dgaX5TjMdHUZej7XX/LI8pYI1L6rCvI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=rfXKAG1uqzPKd3VwILIUY3NW71nOJ9y6JufNC3BgJ2vTRKszHZpiufwJhrMbH+H9sOgdnRwyf0xYS57EgFi+hIxHGqFkbgzJgVJYoGw3a7ou4+lIEB/YcQ5aYS436fhLwltGIIer+YAUF/qlTvIq5Zv3DEpWuznLR5MkbL68xqc= Received: by 10.115.46.9 with SMTP id y9mr772087waj.1179998044416; Thu, 24 May 2007 02:14:04 -0700 (PDT) Received: by 10.114.203.13 with HTTP; Thu, 24 May 2007 02:14:04 -0700 (PDT) Message-ID: <6491e1350705240214h72567733ka7248c4a7f876400@mail.gmail.com> Date: Thu, 24 May 2007 14:44:04 +0530 From: "satyaakam goswami" To: help-bison@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-detected-kernel: Linux 2.4-2.6 (Google crawlbot) Subject: recommended Bison version X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 May 2007 09:14:17 -0000 Hi, What is the Bison version recommended with gcc4.1.1 regards Satya From MAILER-DAEMON Fri May 25 10:45:23 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Hrb2h-0002gm-39 for mharc-help-bison@gnu.org; Fri, 25 May 2007 10:45:23 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hrb2f-0002gO-B2 for help-bison@gnu.org; Fri, 25 May 2007 10:45:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hrb2e-0002fG-6s for help-bison@gnu.org; Fri, 25 May 2007 10:45:21 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hrb2d-0002ep-CJ for help-bison@gnu.org; Fri, 25 May 2007 10:45:19 -0400 Received: from out2.smtp.messagingengine.com ([66.111.4.26]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hrb2c-0000Ak-Hv for help-bison@gnu.org; Fri, 25 May 2007 10:45:18 -0400 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 5263B222D1D for ; Fri, 25 May 2007 10:45:17 -0400 (EDT) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute1.internal (MEProxy); Fri, 25 May 2007 10:45:17 -0400 X-Sasl-enc: r6ISFCL+z/ikLcD2XqB21/C9GCezrZ380lD0sjqfLlCp 1180104317 Received: from localhost (nat0.troll.no [62.70.27.100]) by mail.messagingengine.com (Postfix) with ESMTP id 0805A19EE7 for ; Fri, 25 May 2007 10:45:17 -0400 (EDT) From: Frans Englich Date: Fri, 25 May 2007 16:43:08 +0200 User-Agent: KMail/1.9.1 MIME-Version: 1.0 Content-Disposition: inline X-Length: 1117 X-UID: 56 To: help-bison@gnu.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200705251643.08881.frans.englich@telia.com> X-detected-kernel: Genre and OS details not recognized. Subject: %glr-parser & %pure-parser X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 May 2007 14:45:21 -0000 Hello, If I to the following Bison grammar: -------------------------------------------------------- %{ void dummy(); %} %pure-parser %% Root: /* empty*/ { } %% -------------------------------------------------------- adds %glr-parser under %pure-parser, two things happens beyond changing the parser algorithm: * It copies all the code in the c++ section into the header. * It puts "extern YYSTYPE lval;" in the header. None of these two things I like nor would expect(at least, to not be different from a lr parser). Why does these things happen when I add %glr-parser? How do I avoid it from happening? This was produced with Bison 2.3, by invoking bison --defines=t.h t.ypp. Thanks in advance, Frans From MAILER-DAEMON Sat May 26 15:13:24 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Hs1hc-0008IL-8y for mharc-help-bison@gnu.org; Sat, 26 May 2007 15:13:24 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hs1ha-0008Hm-3e for help-bison@gnu.org; Sat, 26 May 2007 15:13:22 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hs1hY-0008Ha-Nl for help-bison@gnu.org; Sat, 26 May 2007 15:13:20 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hs1hY-0008HX-IJ; Sat, 26 May 2007 15:13:20 -0400 Received: from mailhost.ces.clemson.edu ([130.127.200.32] helo=ces.clemson.edu) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Hs1hY-0004Iw-6S; Sat, 26 May 2007 15:13:20 -0400 Received: from unixlab02.ces.clemson.edu (unixlab02.ces.clemson.edu [130.127.206.12]) by ces.clemson.edu (8.13.6/8.13.6) with ESMTP id l4QJDAu5013528; Sat, 26 May 2007 15:13:15 -0400 (EDT) Received: from localhost (jdenny@localhost) by unixlab02.ces.clemson.edu (8.9.3/8.9.3) with ESMTP id PAA02651; Sat, 26 May 2007 15:13:10 -0400 (EDT) X-Authentication-Warning: unixlab02.ces.clemson.edu: jdenny owned process doing -bs Date: Sat, 26 May 2007 15:13:10 -0400 (EDT) From: "Joel E. Denny" To: Frans Englich In-Reply-To: <200705251643.08881.frans.englich@telia.com> Message-ID: References: <200705251643.08881.frans.englich@telia.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.45 X-detected-kernel: Solaris 9 Cc: help-bison@gnu.org, bison-patches@gnu.org Subject: Re: %glr-parser & %pure-parser X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 May 2007 19:13:22 -0000 On Fri, 25 May 2007, Frans Englich wrote: > adds %glr-parser under %pure-parser, two things happens beyond changing the > parser algorithm: > > * It copies all the code in the c++ section into the header. This is addressed in test release 2.3a. See the heading "Handling of traditional Yacc prologue blocks" in NEWS. However, the "alternative to the traditional Yacc prologue blocks" presented there have been replaced in CVS, so be careful about using those. > * It puts "extern YYSTYPE lval;" in the header. Thanks. I committed the following to fix that. Index: ChangeLog =================================================================== RCS file: /sources/bison/bison/ChangeLog,v retrieving revision 1.1700 diff -p -u -r1.1700 ChangeLog --- ChangeLog 26 May 2007 18:19:33 -0000 1.1700 +++ ChangeLog 26 May 2007 19:04:58 -0000 @@ -4,6 +4,11 @@ that the yacc script isn't corrupt. Reported by Hans Aberg at . + * data/glr.c (yylval): As in yacc.c, don't extern in the header for + the case of pure parsers. Reported by Frans Englich at + . + * THANKS: Add Frans Englich. + 2007-05-20 Joel E. Denny Extend the front-end API for %define variables to more completely Index: THANKS =================================================================== RCS file: /sources/bison/bison/THANKS,v retrieving revision 1.73 diff -p -u -r1.73 THANKS --- THANKS 4 Apr 2007 22:41:58 -0000 1.73 +++ THANKS 26 May 2007 19:04:58 -0000 @@ -29,6 +29,7 @@ Evgeny Stambulchik fnevgeny@plasm Fabrice Bauzac noon@cote-dazur.com Florian Krohm florian@edamail.fishkill.ibm.com Frank Heckenbach frank@g-n-u.de +Frans Englich frans.englich@telia.com Guido Trentalancia trentalg@aston.ac.uk H. Merijn Brand h.m.brand@hccnet.nl Hans Aberg haberg@matematik.su.se Index: data/glr.c =================================================================== RCS file: /sources/bison/bison/data/glr.c,v retrieving revision 1.204 diff -p -u -r1.204 glr.c --- data/glr.c 24 Feb 2007 05:43:35 -0000 1.204 +++ data/glr.c 26 May 2007 19:04:59 -0000 @@ -2638,7 +2638,8 @@ b4_copyright([Skeleton interface for Bis b4_shared_declarations -extern YYSTYPE b4_prefix[]lval; +b4_pure_if([], +[[extern YYSTYPE b4_prefix][lval;]]) b4_locations_if([b4_pure_if([], [extern YYLTYPE b4_prefix[]lloc;]) From MAILER-DAEMON Sat May 26 15:47:10 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Hs2EI-00017X-La for mharc-help-bison@gnu.org; Sat, 26 May 2007 15:47:10 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hs1S1-0008Gw-2c for help-bison@gnu.org; Sat, 26 May 2007 14:57:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hs1S0-0008E4-0C for Help-bison@gnu.org; Sat, 26 May 2007 14:57:16 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hs1Rz-0008DM-PY for Help-bison@gnu.org; Sat, 26 May 2007 14:57:15 -0400 Received: from kuber.nabble.com ([216.139.236.158]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Hs1Rz-00038W-0Z for Help-bison@gnu.org; Sat, 26 May 2007 14:57:15 -0400 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Hs1Ry-0006pe-2s for Help-bison@gnu.org; Sat, 26 May 2007 11:57:14 -0700 Message-ID: <10818891.post@talk.nabble.com> Date: Sat, 26 May 2007 11:57:13 -0700 (PDT) From: kkc To: Help-bison@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: kaikongchan_98@hotmail.com X-detected-kernel: Linux 2.6 (newer, 3) X-Mailman-Approved-At: Sat, 26 May 2007 15:47:08 -0400 Cc: Subject: ex & yacc, Second Edition, ch1-06 X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 May 2007 18:57:17 -0000 I'm currently working on chapter1-06, I can't get the parser to a sentence properly. Do anyone know how to get it to work. I'm using linux the '-ly' library don't work in yacc or gcc compiler. So I have to use flex & bison instead. This is the book: http://www.oreilly.com/catalog/lex/ Please help! Thank You! By Kai /* $ flex http://www.nabble.com/file/p10818891/ch1-06.zip ch1-06.zip .l $ bison -y -d ch1-06.y $ cc -c lex.yy.c y.tab.c $ cc -o ch1-06 lex.yy.o y.tab.o -lfl $ ./ch1-06 noun kai kai Error message: syntax error verb kong kong kong Error message: syntax error noun chan chan Error message: syntax error kai kong chan Error message: syntax error Error message: syntax error kong $ ./ch1-06 noun kai verb kong noun chan kaikongchan kaikongchan: don't recognize kai kong chan Error message: syntax error Error message: syntax error Error message: syntax error $ v */ -- View this message in context: http://www.nabble.com/ex---yacc%2C-Second-Edition%2C-ch1-06-tf3821459.html#a10818891 Sent from the Gnu - Bison - Help mailing list archive at Nabble.com. From MAILER-DAEMON Sat May 26 15:47:11 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Hs2EJ-000188-5u for mharc-help-bison@gnu.org; Sat, 26 May 2007 15:47:11 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hs1TV-0000iu-2R for help-bison@gnu.org; Sat, 26 May 2007 14:58:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hs1TT-0000iW-CO for Help-bison@gnu.org; Sat, 26 May 2007 14:58:48 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hs1TT-0000iT-77 for Help-bison@gnu.org; Sat, 26 May 2007 14:58:47 -0400 Received: from kuber.nabble.com ([216.139.236.158]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Hs1TS-0003Ef-Oo for Help-bison@gnu.org; Sat, 26 May 2007 14:58:46 -0400 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Hs1TR-0006qa-U0 for Help-bison@gnu.org; Sat, 26 May 2007 11:58:45 -0700 Message-ID: <10818891.post@talk.nabble.com> Date: Sat, 26 May 2007 11:57:13 -0700 (PDT) From: kkc To: Help-bison@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: kaikongchan_98@hotmail.com X-detected-kernel: Linux 2.6 (newer, 3) X-Mailman-Approved-At: Sat, 26 May 2007 15:47:08 -0400 Cc: Subject: lex & yacc, Second Edition, ch1-06 X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 May 2007 18:58:49 -0000 I'm currently working on chapter1-06, I can't get the parser to a sentence properly. Do anyone know how to get it to work. I'm using linux the '-ly' library don't work in yacc or gcc compiler. So I have to use flex & bison instead. This is the book: http://www.oreilly.com/catalog/lex/ Please help! Thank You! By Kai http://www.nabble.com/file/p10818891/ch1-06.zip ch1-06.zip /* $ flex ch1-06.l $ bison -y -d ch1-06.y $ cc -c lex.yy.c y.tab.c $ cc -o ch1-06 lex.yy.o y.tab.o -lfl $ ./ch1-06 noun kai kai Error message: syntax error verb kong kong kong Error message: syntax error noun chan chan Error message: syntax error kai kong chan Error message: syntax error Error message: syntax error kong $ ./ch1-06 noun kai verb kong noun chan kaikongchan kaikongchan: don't recognize kai kong chan Error message: syntax error Error message: syntax error Error message: syntax error $ */ -- View this message in context: http://www.nabble.com/lex---yacc%2C-Second-Edition%2C-ch1-06-tf3821459.html#a10818891 Sent from the Gnu - Bison - Help mailing list archive at Nabble.com. From MAILER-DAEMON Sat May 26 15:47:11 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Hs2EJ-00018Y-C7 for mharc-help-bison@gnu.org; Sat, 26 May 2007 15:47:11 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hs1Uq-0000oJ-HF for help-bison@gnu.org; Sat, 26 May 2007 15:00:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hs1Uo-0000o4-7E for Help-bison@gnu.org; Sat, 26 May 2007 15:00:11 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hs1Uo-0000o1-2G for Help-bison@gnu.org; Sat, 26 May 2007 15:00:10 -0400 Received: from kuber.nabble.com ([216.139.236.158]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Hs1Un-0003LT-Kn for Help-bison@gnu.org; Sat, 26 May 2007 15:00:09 -0400 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Hs1Um-0006sq-Ps for Help-bison@gnu.org; Sat, 26 May 2007 12:00:08 -0700 Message-ID: <10818891.post@talk.nabble.com> Date: Sat, 26 May 2007 11:57:13 -0700 (PDT) From: kkc To: Help-bison@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: kaikongchan_98@hotmail.com X-detected-kernel: Linux 2.6 (newer, 3) X-Mailman-Approved-At: Sat, 26 May 2007 15:47:08 -0400 Cc: Subject: lex & yacc, Second Edition, ch1-06 X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 May 2007 19:00:12 -0000 Hello, I'm currently working on chapter1-06, I can't get the parser to a sentence properly. Do anyone know how to get it to work. I'm using linux the '-ly' library don't work in yacc or gcc compiler. So I have to use flex & bison instead. This is the book: http://www.oreilly.com/catalog/lex/ Please help! Thank You! By Kai http://www.nabble.com/file/p10818891/ch1-06.zip ch1-06.zip /* $ flex ch1-06.l $ bison -y -d ch1-06.y $ cc -c lex.yy.c y.tab.c $ cc -o ch1-06 lex.yy.o y.tab.o -lfl $ ./ch1-06 noun kai kai Error message: syntax error verb kong kong kong Error message: syntax error noun chan chan Error message: syntax error kai kong chan Error message: syntax error Error message: syntax error kong */ -- View this message in context: http://www.nabble.com/lex---yacc%2C-Second-Edition%2C-ch1-06-tf3821459.html#a10818891 Sent from the Gnu - Bison - Help mailing list archive at Nabble.com. From MAILER-DAEMON Tue May 29 03:55:55 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HswYd-0005Sg-3X for mharc-help-bison@gnu.org; Tue, 29 May 2007 03:55:55 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HswYb-0005S2-TN for help-bison@gnu.org; Tue, 29 May 2007 03:55:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HswYa-0005RH-9l for help-bison@gnu.org; Tue, 29 May 2007 03:55:53 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HswYY-0005Qo-Gf; Tue, 29 May 2007 03:55:50 -0400 Received: from out2.smtp.messagingengine.com ([66.111.4.26]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HswYX-0001JR-07; Tue, 29 May 2007 03:55:49 -0400 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 3B891226778; Tue, 29 May 2007 03:55:42 -0400 (EDT) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute1.internal (MEProxy); Tue, 29 May 2007 03:55:42 -0400 X-Sasl-enc: SchZvmsIbyafJYZVMD29nVLH2c3m0M5I9WRGb9cr44a9 1180425341 Received: from localhost (nat0.troll.no [62.70.27.100]) by mail.messagingengine.com (Postfix) with ESMTP id DC06920326; Tue, 29 May 2007 03:55:41 -0400 (EDT) From: Frans Englich To: "Joel E. Denny" Date: Tue, 29 May 2007 09:54:08 +0200 User-Agent: KMail/1.9.1 References: <200705251643.08881.frans.englich@telia.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200705290954.08738.frans.englich@telia.com> X-detected-kernel: Genre and OS details not recognized. Cc: help-bison@gnu.org, bison-patches@gnu.org Subject: Re: %glr-parser & %pure-parser X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2007 07:55:54 -0000 On Saturday 26 May 2007 21:13, Joel E. Denny wrote: > On Fri, 25 May 2007, Frans Englich wrote: > > adds %glr-parser under %pure-parser, two things happens beyond changing > > the parser algorithm: > > > > * It copies all the code in the c++ section into the header. > > This is addressed in test release 2.3a. See the heading "Handling of > traditional Yacc prologue blocks" in NEWS. However, the "alternative to > the traditional Yacc prologue blocks" presented there have been replaced > in CVS, so be careful about using those. > > > * It puts "extern YYSTYPE lval;" in the header. > > Thanks. I committed the following to fix that. Thanks for the swift fixes and reply. I tried out 2.3a and it seems to work better than expected: I don't get the "extern YYSTYPE lval;" line. I first thought the 2.3a package had been updated to contain your committed fix, but it seems to be something in 2.3a that made that bug disappear for me. Cheers, Frans From MAILER-DAEMON Tue May 29 05:51:30 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HsyMU-0008MY-EP for mharc-help-bison@gnu.org; Tue, 29 May 2007 05:51:30 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HsyMT-0008ML-0l for help-bison@gnu.org; Tue, 29 May 2007 05:51:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HsyMR-0008M9-HF for help-bison@gnu.org; Tue, 29 May 2007 05:51:28 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HsyMR-0008M6-9j for help-bison@gnu.org; Tue, 29 May 2007 05:51:27 -0400 Received: from out2.smtp.messagingengine.com ([66.111.4.26]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HsyMR-0003kI-A1 for help-bison@gnu.org; Tue, 29 May 2007 05:51:27 -0400 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 9D540228C78 for ; Tue, 29 May 2007 05:51:26 -0400 (EDT) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute1.internal (MEProxy); Tue, 29 May 2007 05:51:26 -0400 X-Sasl-enc: 1oEhvDHGVtefuXSVDcGZjzbJ8p7xxGY+6Ke2Pkm4tHYK 1180432286 Received: from localhost (nat0.troll.no [62.70.27.100]) by mail.messagingengine.com (Postfix) with ESMTP id 57B3D20344 for ; Tue, 29 May 2007 05:51:26 -0400 (EDT) From: Frans Englich To: help-bison@gnu.org Date: Tue, 29 May 2007 11:49:55 +0200 User-Agent: KMail/1.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200705291149.55264.frans.englich@telia.com> X-detected-kernel: Genre and OS details not recognized. Subject: C++, %glr-parser and non-POD semantic values X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2007 09:51:29 -0000 Hello, I'm switching a parser to be GLR in order to simplify the lexer. It's all i= n=20 C++, the parser & tokenizer must be exceptions safe(hence, Bison destructor= s=20 cannot be used to free values, as far as I know), and it must be reentrant. My current parser does not use the C++ skeleton despite being compiled as C= ++=20 code, which from my understanding is bad practice(correct?). My semantic=20 value is a class with non-POD members; I don't use %union. This functions=20 just fine but is something I again suspect is considered bad practice(becau= se=20 its ctor and dtor are not invoked?). Nevertheless, it is amazing it works,= =20 but maybe it explains the leaks valgrind tells me exists in the parser.. Is using a non-POD type as semantic value supported? I have a vague memory = of=20 Hans discussing this. When I simply added the %glr-parser directive, I ran into problems. Notably= ,=20 this code was generated: struct yyGLRState { /** Type tag: always true. */ yybool yyisState; /** Type tag for yysemantics. If true, yysval applies, otherwise * yyfirstVal applies. */ yybool yyresolved; /** Number of corresponding LALR(1) machine state. */ yyStateNum yylrState; /** Preceding state in this stack */ yyGLRState* yypred; /** Source position of the first token produced by my symbol */ size_t yyposn; union { /** First in a chain of alternative reductions producing the * non-terminal corresponding to this state, threaded through * yynext. */ yySemanticOption* yyfirstVal; /** Semantic value for this state. */ YYSTYPE yysval; } yysemantics; /** Source location for this state. */ YYLTYPE yyloc; }; which naturally gave compiler warnings like "member=20 =E2=80=98yyGLRState::::yysval=E2=80=99 with constructor not allow= ed in union" since=20 YYSTYPE is not a POD. However, do note that the parser worked with the LR=20 parser. What direction do you recommend me to take? I like the C skeleton because it's simple and it doesn't have dependencies = on=20 the STL, which is a no go for me, unfortunately. So, I simply need a=20 parser(GLR, or non GLR, if necessary) that can have non-POD semantic values= ,=20 in a safe manner. Cheers, Frans From MAILER-DAEMON Tue May 29 06:05:34 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Hsya6-0000ak-5r for mharc-help-bison@gnu.org; Tue, 29 May 2007 06:05:34 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hsya3-0000Y3-HD for help-bison@gnu.org; Tue, 29 May 2007 06:05:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hsya0-0000Vj-SO for help-bison@gnu.org; Tue, 29 May 2007 06:05:29 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HsyZz-0000UV-9x for help-bison@gnu.org; Tue, 29 May 2007 06:05:27 -0400 Received: from 179.75-78-194.adsl-static.isp.belgacom.be ([194.78.75.179] helo=mail.anubex.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HsyZy-0005Ff-PH for help-bison@gnu.org; Tue, 29 May 2007 06:05:27 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.anubex.com (Postfix) with ESMTP id 87E7410BD5B; Tue, 29 May 2007 12:05:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at anubex.com Received: from mail.anubex.com ([127.0.0.1]) by localhost (mail.anubex.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Z3z074EtZ+7P; Tue, 29 May 2007 12:05:22 +0200 (CEST) Received: from [127.0.0.1] (177.75-78-194.adsl-static.isp.belgacom.be [194.78.75.177]) by mail.anubex.com (Postfix) with ESMTP id 5689610C062; Tue, 29 May 2007 12:05:22 +0200 (CEST) Message-ID: <465BFA40.4090608@telenet.be> Date: Tue, 29 May 2007 12:02:40 +0200 From: Tim Van Holder User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Frans Englich References: <200705291149.55264.frans.englich@telia.com> In-Reply-To: <200705291149.55264.frans.englich@telia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-kernel: Linux 2.6 (newer, 3) Cc: help-bison@gnu.org Subject: Re: C++, %glr-parser and non-POD semantic values X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2007 10:05:31 -0000 Frans Englich wrote: > Hello, > > What direction do you recommend me to take? > > I like the C skeleton because it's simple and it doesn't have dependencies on > the STL, which is a no go for me, unfortunately. So, I simply need a > parser(GLR, or non GLR, if necessary) that can have non-POD semantic values, > in a safe manner. The easiest is to simply use a pointer to your class as YYSTYPE; the lexer can then construct an object if there is a relevant semantic value, or set it to 0 to indicate there isn't (a distinction that can be useful in some cases). This way, you can use the C skeleton without problems, and the GLR skeleton should work too. Of course, without the use of bison destructors and/or error handling code you can have leaks using this approach (in my case, my YYSTYPE is a pointer to an AST node, and the constructor of such nodes adds the node to a global 'orphaned_nodes' list, from which it is removed when it's added to a tree, so it's easy to detect & clean up 'leaked' nodes). From MAILER-DAEMON Tue May 29 06:27:32 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HsyvM-0001Y1-CL for mharc-help-bison@gnu.org; Tue, 29 May 2007 06:27:32 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HsyvJ-0001Tv-Th for help-bison@gnu.org; Tue, 29 May 2007 06:27:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HsyvI-0001QD-54 for help-bison@gnu.org; Tue, 29 May 2007 06:27:29 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HsyvH-0001Pu-Vx for help-bison@gnu.org; Tue, 29 May 2007 06:27:28 -0400 Received: from out2.smtp.messagingengine.com ([66.111.4.26]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HsyvH-0007ju-7t for help-bison@gnu.org; Tue, 29 May 2007 06:27:27 -0400 Received: from compute2.internal (compute2.internal [10.202.2.42]) by out1.messagingengine.com (Postfix) with ESMTP id C3DB0227CEA; Tue, 29 May 2007 06:27:24 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute2.internal (MEProxy); Tue, 29 May 2007 06:27:24 -0400 X-Sasl-enc: x636DPwQQcBmn7VyfMt4NPlmloSshQHna/ENgEDF2mMg 1180434444 Received: from localhost (nat0.troll.no [62.70.27.100]) by mail.messagingengine.com (Postfix) with ESMTP id 4273B2461F; Tue, 29 May 2007 06:27:24 -0400 (EDT) From: Frans Englich To: Tim Van Holder Date: Tue, 29 May 2007 12:25:52 +0200 User-Agent: KMail/1.9.1 References: <200705291149.55264.frans.englich@telia.com> <465BFA40.4090608@telenet.be> In-Reply-To: <465BFA40.4090608@telenet.be> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200705291225.53061.frans.englich@telia.com> X-detected-kernel: Genre and OS details not recognized. Cc: help-bison@gnu.org Subject: Re: C++, %glr-parser and non-POD semantic values X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2007 10:27:30 -0000 On Tuesday 29 May 2007 12:02, Tim Van Holder wrote: > Frans Englich wrote: > > Hello, > > > > What direction do you recommend me to take? > > > > I like the C skeleton because it's simple and it doesn't have > > dependencies on the STL, which is a no go for me, unfortunately. So, I > > simply need a parser(GLR, or non GLR, if necessary) that can have non-POD > > semantic values, in a safe manner. > > The easiest is to simply use a pointer to your class as YYSTYPE; the > lexer can then construct an object if there is a relevant semantic > value, or set it to 0 to indicate there isn't (a distinction that can > be useful in some cases). > This way, you can use the C skeleton without problems, and the GLR > skeleton should work too. > Of course, without the use of bison destructors and/or error handling > code you can have leaks using this approach Yes, that's the big problem. And destructors won't do it for me, due to exceptions. > (in my case, my YYSTYPE is > a pointer to an AST node, and the constructor of such nodes adds the > node to a global 'orphaned_nodes' list, from which it is removed when > it's added to a tree, so it's easy to detect & clean up 'leaked' nodes). Yes, that would work I guess. A custom memory pool/handler. It seems like it would be a "custom token value stack." Though, to me it seems it would turn out verbose since Bison can't help you with the semantic types. For instance, currently my code reads '$3 == "foo"', where the type of $3 has been set to the string class member by Bison due to a %type declaration. With a pointer, it would turn into '$3->stringMember == "foo"'. This is a significant amount of work/code, my grammar file is about 3000 lines long.. But it does indeed seem like it would work, at least. Cheers, Frans From MAILER-DAEMON Tue May 29 07:18:09 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HsziL-0003QO-G8 for mharc-help-bison@gnu.org; Tue, 29 May 2007 07:18:09 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HsziK-0003Ow-0R for help-bison@gnu.org; Tue, 29 May 2007 07:18:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HsziJ-0003Ng-4D for help-bison@gnu.org; Tue, 29 May 2007 07:18:07 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HsziI-0003N8-PM for help-bison@gnu.org; Tue, 29 May 2007 07:18:06 -0400 Received: from ch-smtp02.sth.basefarm.net ([80.76.149.213]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HsziI-0004bB-2T for help-bison@gnu.org; Tue, 29 May 2007 07:18:06 -0400 Received: from c83-250-192-69.bredband.comhem.se ([83.250.192.69]:63183) by ch-smtp02.sth.basefarm.net with esmtp (Exim 4.66) (envelope-from ) id 1HsziG-0006dJ-9K; Tue, 29 May 2007 13:18:05 +0200 In-Reply-To: <200705291149.55264.frans.englich@telia.com> References: <200705291149.55264.frans.englich@telia.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <4BDA9D5F-A7BE-47DD-A7A8-8A3D12CED77C@math.su.se> Content-Transfer-Encoding: 7bit From: Hans Aberg Date: Tue, 29 May 2007 13:17:58 +0200 To: Frans Englich X-Mailer: Apple Mail (2.752.2) X-Originating-IP: 83.250.192.69 X-Scan-Result: No virus found in message 1HsziG-0006dJ-9K. X-Scan-Signature: ch-smtp02.sth.basefarm.net 1HsziG-0006dJ-9K 75b826ddf9a279f8d0097e65f5d1920f X-detected-kernel: Linux 2.6? (barebone, rare!) Cc: help-bison@gnu.org Subject: Re: C++, %glr-parser and non-POD semantic values X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2007 11:18:08 -0000 On 29 May 2007, at 11:49, Frans Englich wrote: > I'm switching a parser to be GLR in order to simplify the lexer. > It's all in > C++, the parser & tokenizer must be exceptions safe(hence, Bison > destructors > cannot be used to free values, as far as I know), and it must be > reentrant. > > My current parser does not use the C++ skeleton despite being > compiled as C++ > code, which from my understanding is bad practice(correct?). I don't know about the GLR parser, but the ordinary C parser stack does not invoke the copy constructors correctly when it reallocates: it just copies over the memory data. > My semantic > value is a class with non-POD members; I don't use %union. So either use a semantic type which does not use non-trivial copy constructors, or a stack that does not re-allocate (using say std::vector or std::deque), or a C++ stack. Hans Aberg From MAILER-DAEMON Tue May 29 07:35:11 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Hszyo-0001AZ-W3 for mharc-help-bison@gnu.org; Tue, 29 May 2007 07:35:11 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hszyn-0001AC-89 for help-bison@gnu.org; Tue, 29 May 2007 07:35:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hszyl-00019o-QQ for help-bison@gnu.org; Tue, 29 May 2007 07:35:08 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hszyl-00019l-OA for help-bison@gnu.org; Tue, 29 May 2007 07:35:07 -0400 Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Hszyl-00067z-4u for help-bison@gnu.org; Tue, 29 May 2007 07:35:07 -0400 Received: from root by ciao.gmane.org with local (Exim 4.43) id 1Hszyg-0005Kp-LA for help-bison@gnu.org; Tue, 29 May 2007 13:35:02 +0200 Received: from 218.28.21.230 ([218.28.21.230]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 29 May 2007 13:35:02 +0200 Received: from post2li by 218.28.21.230 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 29 May 2007 13:35:02 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: help-bison@gnu.org From: Bunny Joy Date: Tue, 29 May 2007 19:23:02 +0800 Lines: 19 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 218.28.21.230 X-Newsreader: Forte Agent 3.3/32.846 Sender: news X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) Subject: Flex/Bison Segment Fault? X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2007 11:35:09 -0000 I am trying to test the code in the book "Lex & Yacc, 2nd", however, it didn't work as described. Pls. # uname -a Linux redhat9 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686 i386 # flex -V flex version 2.5.4 # bison -V bison (GNU Bison) 1.35 # flex -olexa.yy.c ch1-05.l # bison -obisa.tab.c ch1-05.y # gcc -o ex bisa.tab.c lexa.yy.c -ll # ./ex Segmentation fault From MAILER-DAEMON Tue May 29 10:04:17 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Ht2J7-0002RO-3c for mharc-help-bison@gnu.org; Tue, 29 May 2007 10:04:17 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ht2J5-0002R8-MX for help-bison@gnu.org; Tue, 29 May 2007 10:04:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ht2J3-0002Px-UC for help-bison@gnu.org; Tue, 29 May 2007 10:04:15 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ht2J3-0002Pn-R6 for help-bison@gnu.org; Tue, 29 May 2007 10:04:13 -0400 Received: from fisher.stats.uwo.ca ([129.100.76.201]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Ht2J3-0008UI-Bp for help-bison@gnu.org; Tue, 29 May 2007 10:04:13 -0400 Received: from [192.168.0.176] (djm.stats.uwo.ca [129.100.76.113]) by fisher.stats.uwo.ca (8.13.1/8.13.1) with ESMTP id l4TE4CQC028718 for ; Tue, 29 May 2007 10:04:12 -0400 Message-ID: <465C332F.1020002@stats.uwo.ca> Date: Tue, 29 May 2007 10:05:35 -0400 From: Duncan Murdoch User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: help-bison@gnu.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) Subject: Why only one "expected"? X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2007 14:04:15 -0000 We're using a GNU Bison 2.3 parser, with verbose error messages. However, we only see messages with a single "expected" token. For example, if a user forgets to give a function name in a function call and types "(1,1)" they'll get the error syntax error, unexpected ',', expecting ')' when in fact there are lots of legal tokens at that spot: any arithmetic operator would be fine, such as "(1+1)", "(1-1)", etc. Looking through the generated code, it appears that the yysyntax_error function should be able to handle up to 4 expected tokens, and if there are more than that (as here), it should default to showing none at all. But that's not what's happening. Can anyone suggest what we might be doing wrong, or is this a Bison bug? If anyone is interested the full source is visible at https://svn.r-project.org/R/trunk/src/main/gram.y and the Bison output is at https://svn.r-project.org/R/trunk/src/main/gram.c but I'm willing to track this down myself, if I can get a hint about where to start looking. Duncan Murdoch From MAILER-DAEMON Tue May 29 13:13:58 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Ht5Gg-0006bj-69 for mharc-help-bison@gnu.org; Tue, 29 May 2007 13:13:58 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ht5Gd-0006Wi-JX for help-bison@gnu.org; Tue, 29 May 2007 13:13:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ht5Gb-0006TY-US for help-bison@gnu.org; Tue, 29 May 2007 13:13:55 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ht5Gb-0006TN-O0 for help-bison@gnu.org; Tue, 29 May 2007 13:13:53 -0400 Received: from fisher.stats.uwo.ca ([129.100.76.201]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Ht5Gb-0004j7-E5 for help-bison@gnu.org; Tue, 29 May 2007 13:13:53 -0400 Received: from [192.168.0.176] (djm.stats.uwo.ca [129.100.76.113]) by fisher.stats.uwo.ca (8.13.1/8.13.1) with ESMTP id l4THDqrE001520; Tue, 29 May 2007 13:13:52 -0400 Message-ID: <465C5FA3.8030601@stats.uwo.ca> Date: Tue, 29 May 2007 13:15:15 -0400 From: Duncan Murdoch User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Duncan Murdoch References: <465C332F.1020002@stats.uwo.ca> In-Reply-To: <465C332F.1020002@stats.uwo.ca> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) Cc: help-bison@gnu.org Subject: Re: Why only one "expected"? X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2007 17:13:56 -0000 On 5/29/2007 10:05 AM, Duncan Murdoch wrote: > We're using a GNU Bison 2.3 parser, with verbose error messages. > However, we only see messages with a single "expected" token. For > example, if a user forgets to give a function name in a function call > and types "(1,1)" they'll get the error > > syntax error, unexpected ',', expecting ')' > > when in fact there are lots of legal tokens at that spot: any > arithmetic operator would be fine, such as "(1+1)", "(1-1)", etc. Sorry about the noise. I see what's happening now. One of the rules we have is expr : '(' expr_or_assign ')' and the first "1" is matching the expr_or_assign rule, so ')' really is the only possibility at that point. Duncan Murdoch From MAILER-DAEMON Wed May 30 06:13:50 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HtLBe-00013r-8a for mharc-help-bison@gnu.org; Wed, 30 May 2007 06:13:50 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HtLBc-00013M-Nw for help-bison@gnu.org; Wed, 30 May 2007 06:13:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HtLBb-000131-VY for help-bison@gnu.org; Wed, 30 May 2007 06:13:48 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HtLBb-00012t-Ak for help-bison@gnu.org; Wed, 30 May 2007 06:13:47 -0400 Received: from out2.smtp.messagingengine.com ([66.111.4.26]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HtLBb-0000e1-5E for help-bison@gnu.org; Wed, 30 May 2007 06:13:47 -0400 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id D26AF223D61 for ; Wed, 30 May 2007 06:13:45 -0400 (EDT) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute1.internal (MEProxy); Wed, 30 May 2007 06:13:45 -0400 X-Sasl-enc: TQdaEpp8xI940HlWdMVo0TOXi9zgcru7S9ejDlXhHY3L 1180520025 Received: from localhost (nat0.troll.no [62.70.27.100]) by mail.messagingengine.com (Postfix) with ESMTP id 77479109E8 for ; Wed, 30 May 2007 06:13:45 -0400 (EDT) From: Frans Englich To: help-bison@gnu.org Date: Wed, 30 May 2007 12:12:24 +0200 User-Agent: KMail/1.9.1 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_I4UXGVvnwgnX4uz" Message-Id: <200705301212.24219.frans.englich@telia.com> X-detected-kernel: Genre and OS details not recognized. Subject: Grammar failing single lookahead X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 May 2007 10:13:49 -0000 --Boundary-00=_I4UXGVvnwgnX4uz Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline See attached grammar. Its essence is this: ----------------------------------------- %token DECLARE %token FOO %token BAR Root: Prolog Prolog: FirstProlog SecondProlog FirstProlog: /* empty */ | FirstProlog A SecondProlog: /* empty */ | SecondProlog B A: DECLARE FOO B: DECLARE BAR ----------------------------------------- The intent of the grammar is to enforce that declarations appear in a certain order(FirstProlog, SecondProlog), that the declarations are optional, and they take the form of "declare ". This is something that naturally leads to a shift/reduce conflict. As far as I know, this can be solved in two ways: * Tokenize "declare foo" into one token, instead of two(the conflict goes away). * Generate a GLR parser. The conflict stays, but the parser survives it. For the user, I think the latter is a better alternative since it will yield better error reporting(since the token granularity is higher). But is it solvable in some other way? For instance, can the grammar be rewritten in some way such that it can be parsed as LR(1)? I doubt it. Cheers, Frans --Boundary-00=_I4UXGVvnwgnX4uz Content-Type: text/x-csrc; charset="us-ascii"; name="withglr.ypp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="withglr.ypp" %{ #include "t.tab.hpp" int yylex(YYSTYPE *lvalp); #include int tokenPos = -1; void yyerror(char const *s) { QTextStream(stderr) << "Error:" << s; } %} %token DECLARE %token FOO %token BAR %defines %debug %error-verbose %glr-parser %verbose %pure-parser %expect 1 %% Root: Prolog Prolog: FirstProlog SecondProlog FirstProlog: /* empty */ | FirstProlog A SecondProlog: /* empty */ | SecondProlog B A: DECLARE FOO B: DECLARE BAR %% int yylex(YYSTYPE *) { static QList tokens; static int pos = -1; if(tokens.isEmpty()) { tokens.append(DECLARE); tokens.append(FOO); tokens.append(DECLARE); tokens.append(BAR); tokens.append(0); } ++pos; return tokens.at(pos); } int main() { yydebug = 1; return yyparse(); } --Boundary-00=_I4UXGVvnwgnX4uz-- From MAILER-DAEMON Wed May 30 06:58:15 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HtLsc-0001Ps-Vg for mharc-help-bison@gnu.org; Wed, 30 May 2007 06:58:15 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HtLsc-0001PA-3u for help-bison@gnu.org; Wed, 30 May 2007 06:58:14 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HtLsb-0001Or-FX for help-bison@gnu.org; Wed, 30 May 2007 06:58:13 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HtLsb-0001Oo-9U for help-bison@gnu.org; Wed, 30 May 2007 06:58:13 -0400 Received: from 179.75-78-194.adsl-static.isp.belgacom.be ([194.78.75.179] helo=mail.anubex.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HtLsa-0005OS-PG for help-bison@gnu.org; Wed, 30 May 2007 06:58:13 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.anubex.com (Postfix) with ESMTP id 2E94210D8FC; Wed, 30 May 2007 12:58:08 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at anubex.com Received: from mail.anubex.com ([127.0.0.1]) by localhost (mail.anubex.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zTJ16H5X0GDD; Wed, 30 May 2007 12:58:07 +0200 (CEST) Received: from [127.0.0.1] (177.75-78-194.adsl-static.isp.belgacom.be [194.78.75.177]) by mail.anubex.com (Postfix) with ESMTP id 25B71109346; Wed, 30 May 2007 12:58:07 +0200 (CEST) Message-ID: <465D581D.7090000@telenet.be> Date: Wed, 30 May 2007 12:55:25 +0200 From: Tim Van Holder User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Frans Englich References: <200705301212.24219.frans.englich@telia.com> In-Reply-To: <200705301212.24219.frans.englich@telia.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-kernel: Linux 2.6 (newer, 3) Cc: help-bison@gnu.org Subject: Re: Grammar failing single lookahead X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 May 2007 10:58:14 -0000 Frans Englich wrote: > The intent of the grammar is to enforce that declarations appear in a certain > order(FirstProlog, SecondProlog), that the declarations are optional, and > they take the form of "declare ". > > This is something that naturally leads to a shift/reduce conflict. As far as I > know, this can be solved in two ways: > > * Tokenize "declare foo" into one token, instead of two(the conflict goes > away). > * Generate a GLR parser. The conflict stays, but the parser survives it. > > For the user, I think the latter is a better alternative since it will yield > better error reporting(since the token granularity is higher). > > But is it solvable in some other way? For instance, can the grammar be > rewritten in some way such that it can be parsed as LR(1)? I doubt it. Try moving semantic checks like this out of the actual grammar definition; often conflicts like this can be avoided by doing so. Simply allow a sequence of any type of declaration, and do the are-they-in-an-acceptable-order check on the AST. You could do this in actions during the parse, or as part of a dedicated semantic check phase on the full AST once it's constructed by yyparse(). You only need a GLR parser when it's not an error condition, i.e. if DECLARE A should be parsed differently if it's after DECLARE B. So instead of: foo : mul_declare_a mul_declare_b rest_of_program ; mul_declare_a : | mul_declare_a declare_a ; mul_declare_b : | mul_declare_b declare_b ; declare_a : DECLARE A rest_of_a_decl ; declare_b : DECLARE B rest_of_b_decl ; You could simply have: foo : mul_declaration rest_of_program { // Alernative 1 - validate list in its entirety if (!validate_declaration_order($1)) YYABORT; } ; mul_declaration : | mul_declaration declaration { // Alternative 2 - check when adding to the list if ($1 != 0 && !validate_declaration_order($1->last_one, $2)) YYABORT; } ; declaration : DECLARE A rest_of_a_decl | DECLARE B rest_of_b_decl ; (note about my rule naming: I use plus_ and mul_ prefixes to indicate the equivalents of + and * regex operators) From MAILER-DAEMON Wed May 30 08:14:02 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HtN3y-0003ol-Nb for mharc-help-bison@gnu.org; Wed, 30 May 2007 08:14:02 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HtN3y-0003og-18 for help-bison@gnu.org; Wed, 30 May 2007 08:14:02 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HtN3w-0003oT-Hg for help-bison@gnu.org; Wed, 30 May 2007 08:14:01 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HtN3w-0003oN-9N for help-bison@gnu.org; Wed, 30 May 2007 08:14:00 -0400 Received: from out2.smtp.messagingengine.com ([66.111.4.26]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HtN3v-0005Bd-Nr for help-bison@gnu.org; Wed, 30 May 2007 08:13:59 -0400 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 5AE56227920; Wed, 30 May 2007 08:13:59 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 30 May 2007 08:13:59 -0400 X-Sasl-enc: pI1l61eT/7JJwWnSyamMQP+r82NOHcAC25vHLAPz9Kjr 1180527238 Received: from localhost (nat0.troll.no [62.70.27.100]) by mail.messagingengine.com (Postfix) with ESMTP id EEC852A428; Wed, 30 May 2007 08:13:58 -0400 (EDT) From: Frans Englich To: help-bison@gnu.org Date: Wed, 30 May 2007 14:12:38 +0200 User-Agent: KMail/1.9.1 References: <200705301212.24219.frans.englich@telia.com> <465D581D.7090000@telenet.be> In-Reply-To: <465D581D.7090000@telenet.be> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200705301412.38277.frans.englich@telia.com> X-detected-kernel: Genre and OS details not recognized. Cc: Tim Van Holder Subject: Re: Grammar failing single lookahead X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 May 2007 12:14:02 -0000 On Wednesday 30 May 2007 12:55, Tim Van Holder wrote: > Frans Englich wrote: > > The intent of the grammar is to enforce that declarations appear in a > > certain order(FirstProlog, SecondProlog), that the declarations are > > optional, and they take the form of "declare ". > > > > This is something that naturally leads to a shift/reduce conflict. As far > > as I know, this can be solved in two ways: > > > > * Tokenize "declare foo" into one token, instead of two(the conflict goes > > away). > > * Generate a GLR parser. The conflict stays, but the parser survives it. > > > > For the user, I think the latter is a better alternative since it will > > yield better error reporting(since the token granularity is higher). > > > > But is it solvable in some other way? For instance, can the grammar be > > rewritten in some way such that it can be parsed as LR(1)? I doubt it. > > Try moving semantic checks like this out of the actual grammar > definition; often conflicts like this can be avoided by doing so. > Simply allow a sequence of any type of declaration, and do the > are-they-in-an-acceptable-order check on the AST. You could do this in > actions during the parse, or as part of a dedicated semantic check phase > on the full AST once it's constructed by yyparse(). Yeah. It's of course one of those design decisions one can ponder: to what degree one lets semantics be imposed by the grammar, or to what degree business logic should sit in the parser. Of course, that would start with deciding on what is "semantics" and what is physical grammar. In my case, I let the grammar flag it, since it naturally imposed the physical order. But indeed, moving it into a logical check is probably the easiest way to solve the problem I posed. Thanks, Frans From MAILER-DAEMON Wed May 30 10:37:09 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HtPIT-00016o-3e for mharc-help-bison@gnu.org; Wed, 30 May 2007 10:37:09 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HtPIR-00015j-46 for help-bison@gnu.org; Wed, 30 May 2007 10:37:07 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HtPIO-00015X-TA for help-bison@gnu.org; Wed, 30 May 2007 10:37:05 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HtPIO-00015U-OG for help-bison@gnu.org; Wed, 30 May 2007 10:37:04 -0400 Received: from mailout02.dsvr.x-isp.net ([213.253.179.6]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HtPIO-0004Hp-7t for help-bison@gnu.org; Wed, 30 May 2007 10:37:04 -0400 Received: from river-42084-001.dsvr.co.uk ([212.69.207.81]) by mailout02.dsvr.x-isp.net with esmtp id 1HtPIM-0006Ly-0B; Wed, 30 May 2007 15:37:02 +0100 Received: from [82.70.243.134] (helo=[192.168.1.33]) by river-42084-001.dsvr.co.uk with esmtp (Exim 4.62) (envelope-from ) id 1HtPII-00065c-Bd; Wed, 30 May 2007 15:36:58 +0100 Message-ID: <465D8C08.6000604@cyconix.com> Date: Wed, 30 May 2007 15:36:56 +0100 From: Evan Lavelle User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Frans Englich References: <200705301212.24219.frans.englich@telia.com> In-Reply-To: <200705301212.24219.frans.englich@telia.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) Cc: help-bison@gnu.org Subject: Re: Grammar failing single lookahead X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 May 2007 14:37:07 -0000 > Root: Prolog > > Prolog: FirstProlog SecondProlog > > FirstProlog: /* empty */ > | FirstProlog A > > SecondProlog: /* empty */ > | SecondProlog B > > A: DECLARE FOO > B: DECLARE BAR How about this: ---- Root: Prolog; Prolog : FirstPrologList | SecondPrologList | FirstPrologList SecondPrologList ; FirstPrologList : A | FirstPrologList A ; SecondPrologList : B | SecondPrologList B ; A : DECLARE FOO ; B : DECLARE BAR ; ---- ? Evan From MAILER-DAEMON Wed May 30 16:18:16 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HtUca-0004Nq-R8 for mharc-help-bison@gnu.org; Wed, 30 May 2007 16:18:16 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HtUcZ-0004NU-Te for help-bison@gnu.org; Wed, 30 May 2007 16:18:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HtUcY-0004Mc-3g for help-bison@gnu.org; Wed, 30 May 2007 16:18:15 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HtUcX-0004MK-Lx for help-bison@gnu.org; Wed, 30 May 2007 16:18:13 -0400 Received: from viefep18-int.chello.at ([213.46.255.22] helo=viefep16-int.chello.at) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HtUcX-0002Vp-1X for help-bison@gnu.org; Wed, 30 May 2007 16:18:13 -0400 Received: from [192.168.0.3] (really [84.73.145.101]) by viefep24-int.chello.at (InterMail vM.7.08.02.00 201-2186-121-20061213) with ESMTP id <20070530201748.PIQM10293.viefep24-int.chello.at@[192.168.0.3]> for ; Wed, 30 May 2007 22:17:48 +0200 From: henrik.sorensen@balcab.ch To: help-bison@gnu.org Date: Wed, 30 May 2007 07:22:24 +0200 User-Agent: KMail/1.9.5 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200705300722.24777.henrik.sorensen@balcab.ch> X-detected-kernel: Solaris 10 (beta) Subject: Re: Flex/Bison Segment Fault? X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 May 2007 20:18:16 -0000 On Tuesday 29 May 2007 13:23, Bunny Joy wrote: > flex version 2.5.4 consider to upgrade to 2.5.33 > bison (GNU Bison) 1.35 consider to upgrade to v2.2 or later > > # flex -olexa.yy.c ch1-05.l > # bison -obisa.tab.c ch1-05.y > # gcc -o ex bisa.tab.c lexa.yy.c -ll which version of gcc ? Try to disable any optimisations from gcc, and enable all warnings: # gcc -O0 -Wall -o ex bisa.tab.c lexa.yy.c -ll > # ./ex > Segmentation fault good luck Henrik From MAILER-DAEMON Wed May 30 16:57:19 2007 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HtVEN-0004kT-NZ for mharc-help-bison@gnu.org; Wed, 30 May 2007 16:57:19 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HtVEM-0004kJ-2i for help-bison@gnu.org; Wed, 30 May 2007 16:57:18 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HtVEJ-0004k6-OL for help-bison@gnu.org; Wed, 30 May 2007 16:57:16 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HtVEJ-0004k3-Iz for help-bison@gnu.org; Wed, 30 May 2007 16:57:15 -0400 Received: from mailout02.dsvr.x-isp.net ([213.253.179.6]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HtVEJ-0006HC-6E for help-bison@gnu.org; Wed, 30 May 2007 16:57:15 -0400 Received: from river-42084-001.dsvr.co.uk ([212.69.207.81]) by mailout02.dsvr.x-isp.net with esmtp id 1HtVEH-000372-Bj; Wed, 30 May 2007 21:57:13 +0100 Received: from [82.70.243.134] (helo=[192.168.1.33]) by river-42084-001.dsvr.co.uk with esmtp (Exim 4.62) (envelope-from ) id 1HtVEG-0000mC-KC; Wed, 30 May 2007 21:57:12 +0100 Message-ID: <465DE528.8060805@cyconix.com> Date: Wed, 30 May 2007 21:57:12 +0100 From: Evan Lavelle User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Frans Englich References: <200705301212.24219.frans.englich@telia.com> <465D8C08.6000604@cyconix.com> In-Reply-To: <465D8C08.6000604@cyconix.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) Cc: help-bison@gnu.org Subject: Re: Grammar failing single lookahead X-BeenThere: help-bison@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Bison parser generator List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 May 2007 20:57:18 -0000 Evan Lavelle wrote: > Prolog > : FirstPrologList > | SecondPrologList > | FirstPrologList SecondPrologList > ; I missed the case of no prolog at all, but this has no conflicts: Prolog : /* nothing */ | FirstPrologList | SecondPrologList | FirstPrologList SecondPrologList ; Evan