Home > Archive > Tcl > June 2007 > question lex+yacc -> tcl parser
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 |
question lex+yacc -> tcl parser
|
|
|
| Hi,
I have a parser written in lex and yacc. It=B4s about 700 linex lex and
10000 yacc (most of it outputs).
Is it possible to do the same in tcl ... sure it is :) But which tool
should I use?
And how much time it takes to convert and run?
Here some tools I found yet:
* fickle+tackle - the souces are no more reachable
* tcLex - complement to lex
* Yeti/Ylex
Have you any recommendations?
Thank you
rene
| |
| Helmut Giese 2007-06-27, 4:22 am |
| >I have a parser written in lex and yacc. It´s about 700 linex lex and
>10000 yacc (most of it outputs).
>Is it possible to do the same in tcl ... sure it is :) But which tool
>should I use?
>And how much time it takes to convert and run?
Hi rene,
I have had good success with Yeti in the past - but I started from
scratch, so there weren't any lex and yacc files to convert. It's been
ages since I worked with lex & yacc, but I think it should be rather
straight forward to convert your files (using a little script, of
course).
Ha, I just remember one thing: Yeti does not (at least then) support
yacc's options for resolving ambiguities, preferences and such. So you
might want to check if your grammar uses these before committing to
much effort.
HTH
Helmut Giese
| |
| Gerald W. Lester 2007-06-27, 4:22 am |
| rene wrote:
> Hi,
>
> I have a parser written in lex and yacc. It´s about 700 linex lex and
> 10000 yacc (most of it outputs).
> Is it possible to do the same in tcl ... sure it is :) But which tool
> should I use?
> And how much time it takes to convert and run?
>
> Here some tools I found yet:
> * fickle+tackle - the souces are no more reachable
> * tcLex - complement to lex
> * Yeti/Ylex
>
> Have you any recommendations?
Can what you are parsing fit the syntax for Tcl command plus argument?
If so just write Tcl commands and let Tcl do the parsing for you!
--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
| |
|
|
Gerald W. Lester schrieb:
> Can what you are parsing fit the syntax for Tcl command plus argument?
No, it=B4s comming from binary code, converted to hex and then parsed to
built C-code.
rene
| |
|
|
Helmut Giese schrieb:
> Hi rene,
> I have had good success with Yeti in the past - but I started from
> scratch, so there weren't any lex and yacc files to convert. It's been
> ages since I worked with lex & yacc, but I think it should be rather
> straight forward to convert your files (using a little script, of
> course).
>
> Ha, I just remember one thing: Yeti does not (at least then) support
> yacc's options for resolving ambiguities, preferences and such. So you
> might want to check if your grammar uses these before committing to
> much effort.
> HTH
> Helmut Giese
Have you only used Yeti or Ylex to? Because I have both, lex and yacc.
As a first step I have made the existing parser tcl-ready as a
extension.
But for further development I would prefer a tcl-only solution.
rene
| |
| Cameron Laird 2007-06-27, 4:22 am |
| In article <1182890200.648894.159200@x35g2000prf.googlegroups.com>,
rene <r.zaumseil@freenet.de> wrote:
>
>Gerald W. Lester schrieb:
>No, it´s comming from binary code, converted to hex and then parsed to
>built C-code.
>
>rene
>
Aha! While your answer is sensible, other possibilities might
turn up. Do I understand correctly that you're not translating
from general lex-yacc, but specifically working with C syntax?
Perhaps Colin will say whether he sees any potential for <URL:
http://wiki.tcl.tk/12796 > in your project.
| |
| Cameron Laird 2007-06-27, 4:22 am |
| In article <1182890200.648894.159200@x35g2000prf.googlegroups.com>,
rene <r.zaumseil@freenet.de> wrote:
>
>Gerald W. Lester schrieb:
>No, it´s comming from binary code, converted to hex and then parsed to
>built C-code.
>
>rene
>
<URL: http://wiki.tcl.tk/3906 > will interest you.
| |
| Tom Poindexter 2007-06-27, 4:22 am |
| In article <hvh8l4-ol9.ln1@lairds.us>, Cameron Laird <claird@lairds.us> wrote:
>In article <1182890200.648894.159200@x35g2000prf.googlegroups.com>,
>rene <r.zaumseil@freenet.de> wrote:
Early in this thread someone mentioned that the sources to
taccle (http://wiki.tcl.tk/11425) and fickle (http://wiki.tcl.tk/3555)
were unavailable due to the author's website being offline. I have
copies of the latest release of each package squirreled away, and will
mail them to anyone who can host them for public consumption.
--
Tom Poindexter
tpoindex@nyx.net
| |
| George Petasis 2007-06-27, 4:22 am |
| O/H Tom Poindexter Ýãñáøå:
> In article <hvh8l4-ol9.ln1@lairds.us>, Cameron Laird <claird@lairds.us> wrote:
>
> Early in this thread someone mentioned that the sources to
> taccle (http://wiki.tcl.tk/11425) and fickle (http://wiki.tcl.tk/3555)
> were unavailable due to the author's website being offline. I have
> copies of the latest release of each package squirreled away, and will
> mail them to anyone who can host them for public consumption.
>
I can publically host them if you e-mail them to me.
George
| |
|
|
Cameron Laird schrieb:
> Aha! While your answer is sensible, other possibilities might
> turn up. Do I understand correctly that you're not translating
> from general lex-yacc, but specifically working with C syntax?
> Perhaps Colin will say whether he sees any potential for <URL:
> http://wiki.tcl.tk/12796 > in your project.
Thanks for your replay. But I will create and not parse C-code.
The generated C-code will end as tcl extension and compiled using
<http://wiki.tcl.tk/18146>.
rene
| |
| Helmut Giese 2007-06-27, 4:22 am |
| >Have you only used Yeti or Ylex to? Because I have both, lex and yacc.
AFAIR I only used Yeti (cannot check since I don't have access to the
machine in question right now).
Helmut Giese
| |
| Cameron Laird 2007-06-27, 7:12 pm |
| In article <1182924798.225628.266640@m36g2000hse.googlegroups.com>,
rene <r.zaumseil@freenet.de> wrote:
>
>Cameron Laird schrieb:
>Thanks for your replay. But I will create and not parse C-code.
>The generated C-code will end as tcl extension and compiled using
><http://wiki.tcl.tk/18146>.
>
>rene
>
Now I'm more lost--'though it certainly sounds interesting.
If I understand you correctly, you want a machine that will
produce C (perhaps a restricted C?). You'd like the machine
to be implemented in Tcl. The input to the machine is ...
well, I don't know, but it's something hex-ish that you've
previously parsed with lex and yacc.
It might well be that clever Tcl coding could make this a
shockingly simple application. If there's a way to regard
the input language as a "command" sequence, you're almost
home <URL: http://wiki.tcl.tk/12165 >. Perhaps it will help
for you to explain a tiny example input and output to the
desired machine.
| |
|
|
Cameron Laird schrieb:
> Now I'm more lost--'though it certainly sounds interesting.
> If I understand you correctly, you want a machine that will
> produce C (perhaps a restricted C?). You'd like the machine
> to be implemented in Tcl. The input to the machine is ...
> well, I don't know, but it's something hex-ish that you've
> previously parsed with lex and yacc.
The original input is "mc5" code from Siemens. It is used in the
Siemens control system
TelepermXP. I use this binary input files, convert to hex format,
parse with lex and yacc ...
and get C-code ready to compile and use in a simulator. The way is
from Siemens machine
code to normal C-code. Now I can run all control computer programs in
one simulation
computer and can add the necessary simulation functions like stop/
start/backtrack....
Only the display system is original.
rene
| |
| Andrew Mangogna 2007-06-27, 7:12 pm |
| rene wrote:
> Hi,
>
> I have a parser written in lex and yacc. It´s about 700 linex lex and
> 10000 yacc (most of it outputs).
> Is it possible to do the same in tcl ... sure it is :) But which tool
> should I use?
> And how much time it takes to convert and run?
>
> Here some tools I found yet:
> * fickle+tackle - the souces are no more reachable
> * tcLex - complement to lex
> * Yeti/Ylex
>
> Have you any recommendations?
>
>
> Thank you
>
> rene
I've written parsers in both Yeti/Ylex and in fickle/tackle. These days I my
preference tends toward fickle/tackle. Particularly if you already have
lex/yacc (or flex/bison) source, fickle/tackle sources are almost
completely compatible modulo the obvious differences between actions coded
in Tcl rather than "C" and a few things made necessary by Tcl syntax
conventions. My move away from Yeti had more to do with my desire to remove
the dependency upon Incr Tcl than anything in particular about Yeti.
All that being said, I am still rather cautious about Tcl generated parsers.
The solutions lack some of the more robust aspects of flex/bison parsers
and I usually find myself resorting to those parsers when I have a "big"
language to deal with. Also, there are a number of interesting parser
generators out there besides the venerable lex/yacc pair which would
deserve consideration for a serious language project. However,
for "smallish" parsers the all Tcl solution is very, very convenient. Also,
be prepared for the fact that Tcl lexical analyzers are significantly
slower than flex ones. In most cases it won't matter, but for interactive
programs it might show up.
--
Andrew Mangogna
| |
| Arnulf Wiedemann 2007-06-27, 7:12 pm |
| rene wrote:
>
> Cameron Laird schrieb:
> The original input is "mc5" code from Siemens. It is used in the
> Siemens control system
> TelepermXP. I use this binary input files, convert to hex format,
> parse with lex and yacc ...
> and get C-code ready to compile and use in a simulator. The way is
> from Siemens machine
> code to normal C-code. Now I can run all control computer programs in
> one simulation
> computer and can add the necessary simulation functions like stop/
> start/backtrack....
> Only the display system is original.
>
> rene
One question: would it be feasable to convert from hex to Tcl code and
execute that in the simulation, as I think that could be much easier.
Just for curiosity: are you working at siemens? I am asking, as I am working
there.
Arnulf
| |
|
|
|
|
|