9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Config File parsing
@ 2012-02-27  9:53 Mohanasundaram VIT
  0 siblings, 0 replies; 8+ messages in thread
From: Mohanasundaram VIT @ 2012-02-27  9:53 UTC (permalink / raw)
  To: 9fans

global{
    verb
    test
    rl0
    rand (or) rand =0      [Two cases]
}

thread{
    frac_value = (0.2,(0.1,0.5))
    random_thread

}
OUTPUT should be this:

If i give the above input to lex and yacc, based upon the checking of
[ rand (or) rand=0 ]

if it is "rand", then it should print as " verb test rl0 rand
frac_value:L=0.1 frac_value:H=0.5"
if it is "rand=0", then it should print as " verb test rl0 rand=0
frac_value=0.2".
For this could someone please tell me how to write a lex and yacc
program.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] Config File parsing
  2012-02-28 16:46   ` Bakul Shah
@ 2012-02-28 16:57     ` erik quanstrom
  0 siblings, 0 replies; 8+ messages in thread
From: erik quanstrom @ 2012-02-28 16:57 UTC (permalink / raw)
  To: 9fans

On Tue Feb 28 11:53:17 EST 2012, bakul@bitblocks.com wrote:
> I have almost always used a handwritten lexer as it seemed about the
> same amount of work and the end result is much smaller and easier to
> understand and lexers for different languages are not all that
> different so once you've written one it is pretty easy to write
> another; and somehow lex or flex interface never felt quite right.

for an extreme example, see /sys/src/cmd/upas/smtp/smtpd.y.

imho, the trick in lexing is to do as little as possible.  context rules
tend to sneak in in the lex phase.  for example, rc's free carets and
willingness to eat newlines under rules that seem obvious until they
need explaining.

- erik



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] Config File parsing
  2012-02-28  4:03 ` Nick LaForge
  2012-02-28 14:57   ` Aram Hăvărneanu
@ 2012-02-28 16:46   ` Bakul Shah
  2012-02-28 16:57     ` erik quanstrom
  1 sibling, 1 reply; 8+ messages in thread
From: Bakul Shah @ 2012-02-28 16:46 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I have almost always used a handwritten lexer as it seemed about the same amount of work and the end result is much smaller and easier to understand and lexers for different languages are not all that different so once you've written one it is pretty easy to write another; and somehow lex or flex interface never felt quite right.

On Feb 27, 2012, at 8:03 PM, Nick LaForge <nicklaforge@gmail.com> wrote:

> Are you certain you want to use Lex?  If no, you may like this
> fascinating and instructive lecture by Rob Pike, which solves a lexing
> problem using Golang: http://www.youtube.com/watch?v=HxaD_trXwRE
> 
> If you have "The Unix Programming Environment" handy, you will also
> find a lucid tutorial of Lex and Yacc both (in the later chapters).
> 
> Nick
> 
> On 2/27/12, arnold@skeeve.com <arnold@skeeve.com> wrote:
>> O'Reilly's "lex & yacc" is somewhat more user-friendly a reference than
>> the dragon book, although the latter certainly has its value. :-)
>> 
>> Arnold
>> 
>> 
> 



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] Config File parsing
  2012-02-28  4:03 ` Nick LaForge
@ 2012-02-28 14:57   ` Aram Hăvărneanu
  2012-02-28 16:46   ` Bakul Shah
  1 sibling, 0 replies; 8+ messages in thread
From: Aram Hăvărneanu @ 2012-02-28 14:57 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Nick LaForge wrote:
> If you have "The Unix Programming Environment" handy, you will also
> find a lucid tutorial of Lex and Yacc both (in the later chapters).

A great complement to this great book is the yacc paper in tenth
edition's manual.

-- 
Aram Hăvărneanu



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] Config File parsing
  2012-02-27 13:23 arnold
@ 2012-02-28  4:03 ` Nick LaForge
  2012-02-28 14:57   ` Aram Hăvărneanu
  2012-02-28 16:46   ` Bakul Shah
  0 siblings, 2 replies; 8+ messages in thread
From: Nick LaForge @ 2012-02-28  4:03 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Are you certain you want to use Lex?  If no, you may like this
fascinating and instructive lecture by Rob Pike, which solves a lexing
problem using Golang: http://www.youtube.com/watch?v=HxaD_trXwRE

If you have "The Unix Programming Environment" handy, you will also
find a lucid tutorial of Lex and Yacc both (in the later chapters).

Nick

On 2/27/12, arnold@skeeve.com <arnold@skeeve.com> wrote:
> O'Reilly's "lex & yacc" is somewhat more user-friendly a reference than
> the dragon book, although the latter certainly has its value. :-)
>
> Arnold
>
>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] Config File parsing
  2012-02-27 13:18 ` erik quanstrom
@ 2012-02-27 14:06   ` Jack Norton
  0 siblings, 0 replies; 8+ messages in thread
From: Jack Norton @ 2012-02-27 14:06 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 2/27/2012 7:18 AM, erik quanstrom wrote:
>> For this could someone please tell me how to write a lex and yacc
>> program.
>
> you may wish to consult the dragon book.  just google it.
>
> - erik
>

FYI I just bought my copy on Amazon used for $3.48 USD ($3.99
shipping....).  It is a hardcopy in great shape too!

-Jack



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] Config File parsing
@ 2012-02-27 13:23 arnold
  2012-02-28  4:03 ` Nick LaForge
  0 siblings, 1 reply; 8+ messages in thread
From: arnold @ 2012-02-27 13:23 UTC (permalink / raw)
  To: 9fans

O'Reilly's "lex & yacc" is somewhat more user-friendly a reference than
the dragon book, although the latter certainly has its value. :-)

Arnold



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] Config File parsing
       [not found] <199d7d8a-c02f-4b21-bb9b-c9be189024bc@w27g2000yqm.googlegroups.co>
@ 2012-02-27 13:18 ` erik quanstrom
  2012-02-27 14:06   ` Jack Norton
  0 siblings, 1 reply; 8+ messages in thread
From: erik quanstrom @ 2012-02-27 13:18 UTC (permalink / raw)
  To: 9fans

> For this could someone please tell me how to write a lex and yacc
> program.

you may wish to consult the dragon book.  just google it.

- erik



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-02-28 16:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-27  9:53 [9fans] Config File parsing Mohanasundaram VIT
     [not found] <199d7d8a-c02f-4b21-bb9b-c9be189024bc@w27g2000yqm.googlegroups.co>
2012-02-27 13:18 ` erik quanstrom
2012-02-27 14:06   ` Jack Norton
2012-02-27 13:23 arnold
2012-02-28  4:03 ` Nick LaForge
2012-02-28 14:57   ` Aram Hăvărneanu
2012-02-28 16:46   ` Bakul Shah
2012-02-28 16:57     ` erik quanstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).