Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re (3): Can awk...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 7 Topic 2193 of 2236
Post > Topic >>

Re (3): Can awk easily simulate an AFSM

by problems@[EMAIL PROTECTED] Mar 20, 2008 at 06:02 AM

In article <64agc9F2b555cU1@[EMAIL PROTECTED]
>,
=?ISO-8859-1?Q?J=FCrgen_Kahrs?= <Juergen.KahrsDELETETHIS@[EMAIL PROTECTED]
> wrote:


> problems@[EMAIL PROTECTED]
 wrote:
> 
> > OK, apparently "Encode" is the code generation.
> > Since I haven't worked with my stuff for many years,
> > I only now realise that awk would give me a program
> > driven implementation, rather than a data-driven AFSM,
> > which is what I want.
> 
> AWK can do both. The example I gave was
> an implementation similar to C style.
> If you really want it data-driven, you
> can have it in AWK (few users prefer this
> style).
> 
> > Apparently I need first to get familiar with *nix regex to
> > clean-up my fetched texts ?
> 
> It helps, but you can also get along without
> too much regexp if you want.
> 
> > Apparently my ideas of an AFSM compiler is closer to the 
> > table-driven compilers ?
> 
> I wouldnt say it this way. I was only surprised
> that you would prefer the data-driven style.
> A data-driven implementation in canonic AWK may
> look like this:
> 
> BEGIN { state = "" }
> 
> state == ""   && /IF/     { state = "IF"   ; Encode(...) }
> state == "IF" && /ELSE/   { state = "ELSE" ; Encode(...) }
> 
OK.
You know there's p2c: translating pascal to c-code; but no c2p.
I'd like to hack one even if it couldn't give compilable code -
a bit like the old babblefish translator.

Any thing that reduces the work load of routine tasks and just 
leaves the final complex details for human tweeking is usefull.
Apparently there's a "standard" perl regex-engine open source 
implementation.  The regex tools of ETH-oberon whaich I use
are not too good.  I guess the "standard" perl one has been tested
a million times ?

I once built a minimum assembler for some 68/3xx 8-bit processor, 
where I used my prefered [more descriptive IMO] mnemonics:
   #3 -> A;    instead of eg.      movi #3, a       and
   [B] -> Port1 ; instead of eg.    outport 1, b

Perhaps I just used some big nested case statements, but for tasks 
like this, if you've got the syntax diagram on a big sheet of paper,
then re-arranging it with all the nodes on the left, translates 
naturally to a data-driven [perhaps awk] implementation.

The thinking is done on the [perhaps paper] 'node-map', and 
the awk-code would be just an implementation of the node-map.

== Chris Glur.




 7 Posts in Topic:
Can awk easily simulate an AFSM
problems@[EMAIL PROTECTED  2008-03-16 11:51:49 
Re: Can awk easily simulate an AFSM
=?ISO-8859-1?Q?J=FCrgen_K  2008-03-16 20:24:41 
Re: Can awk easily simulate an AFSM
Janis Papanagnou <Jani  2008-03-18 04:00:05 
Re (2): Can awk easily simulate an AFSM
problems@[EMAIL PROTECTED  2008-03-18 05:46:17 
Re: Re (2): Can awk easily simulate an AFSM
=?ISO-8859-1?Q?J=FCrgen_K  2008-03-18 19:35:53 
Re (3): Can awk easily simulate an AFSM
problems@[EMAIL PROTECTED  2008-03-20 06:02:39 
Re: Re (3): Can awk easily simulate an AFSM
=?ISO-8859-1?Q?J=FCrgen_K  2008-03-20 20:28:16 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 0:51:04 CDT 2008.