From Eric.Armstrong at Sun.COM Sun Jan 27 14:42:41 2008 From: Eric.Armstrong at Sun.COM (Eric Armstrong) Date: Sun, 27 Jan 2008 11:42:41 -0800 Subject: [Mediacloth-talk] MediaCloth grammar Message-ID: <479CDEB1.9090602@sun.com> Hey, guys. I signed up for mediacloth-talk, and sent my confirmation, but haven't seen a message come back. Hopefully this goes through. I was just wondering what a MediaCloth grammar file looks like. I know I can use the MediaClothHtmlGenerator once I have one, and I see the steps for running the code, but I haven't yet found an example grammar that I could think about extending... -- Eric Armstrong, Document Systems Architect, Sun Microsystems http://blogs.sun.com/coolstuff http://www.artima.com/weblogs/index.jsp?blogger=cooltools From Eric.Armstrong at Sun.COM Sun Jan 27 15:08:24 2008 From: Eric.Armstrong at Sun.COM (Eric Armstrong) Date: Sun, 27 Jan 2008 12:08:24 -0800 Subject: [Mediacloth-talk] MediaCloth grammar In-Reply-To: <479CDEB1.9090602@sun.com> References: <479CDEB1.9090602@sun.com> Message-ID: <479CE4B8.8040304@sun.com> Yup. I'm on the list. I missed the message. Eric Armstrong wrote: > Hey, guys. > > I signed up for mediacloth-talk, and sent my > confirmation, but haven't seen a message come > back. Hopefully this goes through. > > I was just wondering what a MediaCloth grammar > file looks like. I know I can use the > MediaClothHtmlGenerator once I have one, and > I see the steps for running the code, but I > haven't yet found an example grammar that I > could think about extending... > > -- Eric Armstrong, Document Systems Architect, Sun Microsystems http://blogs.sun.com/coolstuff http://www.artima.com/weblogs/index.jsp?blogger=cooltools From Gregory.Murphy at Sun.COM Mon Jan 28 12:12:50 2008 From: Gregory.Murphy at Sun.COM (Gregory Murphy) Date: Mon, 28 Jan 2008 09:12:50 -0800 Subject: [Mediacloth-talk] MediaCloth grammar In-Reply-To: <479CDEB1.9090602@sun.com> References: <479CDEB1.9090602@sun.com> Message-ID: <479E0D12.7050307@sun.com> Eric Armstrong wrote: > Hey, guys. > > I signed up for mediacloth-talk, and sent my > confirmation, but haven't seen a message come > back. Hopefully this goes through. > > I was just wondering what a MediaCloth grammar > file looks like. I know I can use the > MediaClothHtmlGenerator once I have one, and > I see the steps for running the code, but I > haven't yet found an example grammar that I > could think about extending... > > > Mediacloth uses the RACC parser generator, and so the grammar file follows RACC conventions. You can learn more about RACC here: http://i.loveruby.net/en/projects/racc/ The Mediacloth grammar is in the subversion repository, in ./lib/mediacloth/mediawikiparser.y You shouldn't need to modify the grammar, unless you want to support a syntax that is different from Mediawiki. Mediawiki has the notion of arbitrary definitions "{{ ... }}", called variables, which Mediacloth supports. You can write a handler to interpret these by extending the HTML generator class, and implementing parseVariable(). This method is invoked every time that a variable is encountered, and passed the contents. // Gregory From Eric.Armstrong at Sun.COM Mon Jan 28 16:55:03 2008 From: Eric.Armstrong at Sun.COM (Eric Armstrong) Date: Mon, 28 Jan 2008 13:55:03 -0800 Subject: [Mediacloth-talk] MediaCloth grammar In-Reply-To: <479E0D12.7050307@sun.com> References: <479CDEB1.9090602@sun.com> <479E0D12.7050307@sun.com> Message-ID: <479E4F37.3060205@sun.com> Thanks, Gregory. I have a further question, but it is decidedly not urgent. Answer at leisure (or point me to a good entry point to the subject, if you can) ... The racc manual page had this example: class Calcparser rule target: exp { print val[0] } exp: exp '+' exp | exp '*' exp | '(' exp ')' | NUMBER end The idea of "rule" and "exp" is clear. I assume that "target" is specifying the right side of the production rule. Yes? So what is "val[0]", in that context? The manual gets a little cryptic at this point, saying yacc's $$ is 'result', $0, $1... is an array 'val', $-1, $-2... is an array '_values' and Then you must prepare parse entry method... Gregory Murphy wrote: > Eric Armstrong wrote: >> Hey, guys. >> >> I signed up for mediacloth-talk, and sent my >> confirmation, but haven't seen a message come >> back. Hopefully this goes through. >> >> I was just wondering what a MediaCloth grammar >> file looks like. I know I can use the >> MediaClothHtmlGenerator once I have one, and >> I see the steps for running the code, but I >> haven't yet found an example grammar that I >> could think about extending... >> >> >> > > Mediacloth uses the RACC parser generator, and so the grammar file > follows RACC conventions. You can learn more about RACC here: > http://i.loveruby.net/en/projects/racc/ > > The Mediacloth grammar is in the subversion repository, in > ./lib/mediacloth/mediawikiparser.y > > You shouldn't need to modify the grammar, unless you want to support a > syntax that is different from Mediawiki. Mediawiki has the notion of > arbitrary definitions "{{ ... }}", called variables, which Mediacloth > supports. You can write a handler to interpret these by extending the > HTML generator class, and implementing parseVariable(). This method is > invoked every time that a variable is encountered, and passed the contents. > > // Gregory > _______________________________________________ > Mediacloth-talk mailing list > Mediacloth-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/mediacloth-talk -- Eric Armstrong, Document Systems Architect, Sun Microsystems http://blogs.sun.com/coolstuff http://www.artima.com/weblogs/index.jsp?blogger=cooltools From thiago.arrais at gmail.com Thu Jan 31 12:26:28 2008 From: thiago.arrais at gmail.com (Thiago Arrais) Date: Thu, 31 Jan 2008 14:26:28 -0300 Subject: [Mediacloth-talk] MediaCloth grammar In-Reply-To: <479E4F37.3060205@sun.com> References: <479CDEB1.9090602@sun.com> <479E0D12.7050307@sun.com> <479E4F37.3060205@sun.com> Message-ID: Eric, On Jan 28, 2008 6:55 PM, Eric Armstrong wrote: > The racc manual page had this example: > > class Calcparser > rule > target: exp { print val[0] } > > exp: exp '+' exp > | exp '*' exp > | '(' exp ')' > | NUMBER > end > > The idea of "rule" and "exp" is clear. I > assume that "target" is specifying the right > side of the production rule. Yes? So what > is "val[0]", in that context? The array `val` holds the results from matching each of the productions inside the grammar rule. In this case it will contain anything returned from the `exp` rule which, by default, is _its_ `val[0]` value [1] and in the end boils down to either a number or an opening parenthesis. Cheers, Thiago Arrais [1] http://i.loveruby.net/en/projects/racc/doc/grammar.html