For Programmers: Free Programming Magazines  


Home > Archive > AWK > March 2008 > Re (3): Can awk easily simulate an AFSM









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re (3): Can awk easily simulate an AFSM
problems@gmail

2008-03-20, 7:58 am

In article <64agc9F2b555cU1@mid.individual.net>, =?ISO-8859-1?Q?J=FCrgen_Kahrs?= <Juergen.KahrsDELETETHIS@vr-web.de> wrote:

> problems@gmail wrote:
>
>
> 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).
>
>
> It helps, but you can also get along without
> too much regexp if you want.
>
>
> 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 twing 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.


Jürgen Kahrs

2008-03-20, 6:59 pm

problems@gmail schrieb:

> 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.


Hmm, try lcc or tinyC

http://fabrice.bellard.free.fr/tcc/
http://www.cs.princeton.edu/software/lcc/

tcc produces x86 code, lcc comes with several back ends.
If I had to compile from C to pascal (or p-code),
then I would start with lcc.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com