librelist archives

« back to archive

Willing to know how jison works

Willing to know how jison works

From:
钟驰宇
Date:
2012-12-19 @ 00:27
Hi guys, I'm new to jison and I'm really interested in it. When reading the
source code, I figure out that jison seemed to use bnf to define program
language. And the most interesting part is it also use bnf to define bnf.
My question is, where does the first bnf come from. namely, where
lib/jison/utils/bnf-parser.js and lex-parser.js come from? I realize that
they are generate automatically by lib/jison.js. However, it also seemed
that lib/jison.js are depended on these two files. I'm really appreciate if
anybody could help me out of this.

-- 
Thanks
About Me:http://cattail2012.wordpress.com/about

Re: [jison] Willing to know how jison works

From:
Zachary Carter
Date:
2012-12-19 @ 01:35
On Tue, Dec 18, 2012 at 4:27 PM, 钟驰宇 <cattail2012@gmail.com> wrote:

> Hi guys, I'm new to jison and I'm really interested in it. When reading
> the source code, I figure out that jison seemed to use bnf to define
> program language. And the most interesting part is it also use bnf to
> define bnf. My question is, where does the first bnf come from. namely,
> where lib/jison/utils/bnf-parser.js and lex-parser.js come from? I realize
> that they are generate automatically by lib/jison.js. However, it also
> seemed that lib/jison.js are depended on these two files. I'm really
> appreciate if anybody could help me out of this.
>
>
Excellent question.

jison will accept language grammars defined in BNF or JSON, but originally
it could only accept JSON. To build the initial BNF parser I defined a
grammar in JSON format and fed it to jison. After jison spit out a parser
capable of parsing BNF (and normalizing it to JSON), it could be integrated
back into jison. At that point, the old JSON grammar for BNF could be
replaced by the new BNF grammar for BNF. Every time an enhancement is made
to the BNF grammar, a new parser must be generated to before the
enhancement can be used in the BNF grammar definition itself. Bootstrapping
is fun.

-- 
Zach Carter

Re: [jison] Willing to know how jison works

From:
钟驰宇
Date:
2012-12-19 @ 01:44
Thanks. Aha, when reading the code, I think it may be a manual JSON file to
start everything. I think it will be better to upload the original JSON
file for some people like me could understand the source code better.
Thanks for making such a powerful tool to make life better !!

On Wed, Dec 19, 2012 at 9:35 AM, Zachary Carter <zack.carter@gmail.com>wrote:

>
> On Tue, Dec 18, 2012 at 4:27 PM, 钟驰宇 <cattail2012@gmail.com> wrote:
>
>> Hi guys, I'm new to jison and I'm really interested in it. When reading
>> the source code, I figure out that jison seemed to use bnf to define
>> program language. And the most interesting part is it also use bnf to
>> define bnf. My question is, where does the first bnf come from. namely,
>> where lib/jison/utils/bnf-parser.js and lex-parser.js come from? I realize
>> that they are generate automatically by lib/jison.js. However, it also
>> seemed that lib/jison.js are depended on these two files. I'm really
>> appreciate if anybody could help me out of this.
>>
>>
> Excellent question.
>
> jison will accept language grammars defined in BNF or JSON, but originally
> it could only accept JSON. To build the initial BNF parser I defined a
> grammar in JSON format and fed it to jison. After jison spit out a parser
> capable of parsing BNF (and normalizing it to JSON), it could be integrated
> back into jison. At that point, the old JSON grammar for BNF could be
> replaced by the new BNF grammar for BNF. Every time an enhancement is made
> to the BNF grammar, a new parser must be generated to before the
> enhancement can be used in the BNF grammar definition itself. Bootstrapping
> is fun.
>
> --
> Zach Carter
>



-- 
Thanks
About Me:http://cattail2012.wordpress.com/about

Re: [jison] Willing to know how jison works

From:
Zachary Carter
Date:
2012-12-19 @ 01:50
Did I forget to link to the original? Here it is, still hanging around as a
test: https://github.com/zaach/jison/blob/master/tests/grammar/bnf.js

Enjoy :)


On Tue, Dec 18, 2012 at 5:44 PM, 钟驰宇 <cattail2012@gmail.com> wrote:

> Thanks. Aha, when reading the code, I think it may be a manual JSON file
> to start everything. I think it will be better to upload the original JSON
> file for some people like me could understand the source code better.
> Thanks for making such a powerful tool to make life better !!
>
>
> On Wed, Dec 19, 2012 at 9:35 AM, Zachary Carter <zack.carter@gmail.com>wrote:
>
>>
>> On Tue, Dec 18, 2012 at 4:27 PM, 钟驰宇 <cattail2012@gmail.com> wrote:
>>
>>> Hi guys, I'm new to jison and I'm really interested in it. When reading
>>> the source code, I figure out that jison seemed to use bnf to define
>>> program language. And the most interesting part is it also use bnf to
>>> define bnf. My question is, where does the first bnf come from. namely,
>>> where lib/jison/utils/bnf-parser.js and lex-parser.js come from? I realize
>>> that they are generate automatically by lib/jison.js. However, it also
>>> seemed that lib/jison.js are depended on these two files. I'm really
>>> appreciate if anybody could help me out of this.
>>>
>>>
>> Excellent question.
>>
>> jison will accept language grammars defined in BNF or JSON, but
>> originally it could only accept JSON. To build the initial BNF parser I
>> defined a grammar in JSON format and fed it to jison. After jison spit out
>> a parser capable of parsing BNF (and normalizing it to JSON), it could be
>> integrated back into jison. At that point, the old JSON grammar for BNF
>> could be replaced by the new BNF grammar for BNF. Every time an enhancement
>> is made to the BNF grammar, a new parser must be generated to before the
>> enhancement can be used in the BNF grammar definition itself. Bootstrapping
>> is fun.
>>
>> --
>> Zach Carter
>>
>
>
>
> --
> Thanks
> About Me:http://cattail2012.wordpress.com/about
>
>


-- 
Zach Carter

Re: [jison] Willing to know how jison works

From:
Robert Plummer
Date:
2012-12-19 @ 00:48
Is it just javascript you want to use?  There is also a php port of jison
that works rather well in the ports folder.

On Tue, Dec 18, 2012 at 7:27 PM, 钟驰宇 <cattail2012@gmail.com> wrote:

> Hi guys, I'm new to jison and I'm really interested in it. When reading
> the source code, I figure out that jison seemed to use bnf to define
> program language. And the most interesting part is it also use bnf to
> define bnf. My question is, where does the first bnf come from. namely,
> where lib/jison/utils/bnf-parser.js and lex-parser.js come from? I realize
> that they are generate automatically by lib/jison.js. However, it also
> seemed that lib/jison.js are depended on these two files. I'm really
> appreciate if anybody could help me out of this.
>
> --
> Thanks
> About Me:http://cattail2012.wordpress.com/about
>
>


-- 
Robert Plummer

Re: [jison] Willing to know how jison works

From:
钟驰宇
Date:
2012-12-19 @ 00:52
Yes, what I want to do is to understand how jison works. And I really want
to know how it was being write, the most important part is  lex-parser.js
and bnf-parser.js

On Wed, Dec 19, 2012 at 8:48 AM, Robert Plummer <
robertleeplummerjr@gmail.com> wrote:

> Is it just javascript you want to use?  There is also a php port of jison
> that works rather well in the ports folder.
>
>
> On Tue, Dec 18, 2012 at 7:27 PM, 钟驰宇 <cattail2012@gmail.com> wrote:
>
>> Hi guys, I'm new to jison and I'm really interested in it. When reading
>> the source code, I figure out that jison seemed to use bnf to define
>> program language. And the most interesting part is it also use bnf to
>> define bnf. My question is, where does the first bnf come from. namely,
>> where lib/jison/utils/bnf-parser.js and lex-parser.js come from? I realize
>> that they are generate automatically by lib/jison.js. However, it also
>> seemed that lib/jison.js are depended on these two files. I'm really
>> appreciate if anybody could help me out of this.
>>
>> --
>> Thanks
>> About Me:http://cattail2012.wordpress.com/about
>>
>>
>
>
> --
> Robert Plummer




-- 
Thanks
About Me:http://cattail2012.wordpress.com/about