From: Gerald W. Lester on
Fredrik Karlsson wrote:
> Hi,
>
> I've been trying to get hold of a parser generator + lexer combination
> that would give me a parser implemented in Tcl, that actually works.
>
> My experience so far:
>
> taccle + fickle - just outputs nothing. Even the demos fails to give
> any ouput.
> Yeti - I get bus error every time I use either the parser or the lexer
> demos.
>
> I am using UTF-8 encoding.. Are there other options out there that I
> should try before continuing my current work of rolling my own parser
> from scratch?

If you have control over the input language, how about using a safe interp
and letting the Tcl parser parse it for you.

You define the language elements as commands aliased back to your main
interp (or that do things directly if that is what you want). I've seen an
"compiler" written this way. From a language that Tcl's parser could parse
it generated a binary output file that was then uploaded to a computer as
its program (also was first uploaded to a simulator to verify the program
did what it was supposed to do). From what I've been reading in the press,
it sounds like the program will be retired later this year after the last
use of the hardware.


--
+------------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald.Lester(a)kng-consulting.net |
+------------------------------------------------------------------------+
From: Will Duquette on
On Jun 5, 11:28 am, "Gerald W. Lester" <Gerald.Les...(a)KnG-
Consulting.net> wrote:
> Fredrik Karlsson wrote:
> > Hi,
>
> > I've been trying to get hold of a parser generator + lexer combination
> > that would give me a parser implemented in Tcl, that actually works.
>
> > My experience so far:
>
> > taccle + fickle - just outputs nothing. Even the demos fails to give
> > any ouput.
> > Yeti - I get bus error every time I use either the parser or the lexer
> > demos.
>
> > I am using UTF-8 encoding.. Are there other options out there that I
> > should try before continuing my current work of rolling my own parser
> > from scratch?
>
> If you have control over the input language, how about using a safe interp
> and letting the Tcl parser parse it for you.
>
> You define the language elements as commands aliased back to your main
> interp (or that do things directly if that is what you want).  I've seen an
> "compiler" written this way.  From a language that Tcl's parser could parse
> it generated a binary output file that was then uploaded to a computer as
> its program (also was first uploaded to a simulator to verify the program
> did what it was supposed to do).  From what I've been reading in the press,
> it sounds like the program will be retired later this year after the last
> use of the hardware.
>
> --
> +------------------------------------------------------------------------+
> | Gerald W. Lester, President, KNG Consulting LLC                        |
> | Email: Gerald.Les...(a)kng-consulting.net                                |
> +------------------------------------------------------------------------+

This approach is close to being one of the most used techniques in my
bag of tricks. I must have implemented hundreds of tiny, application
specific languages for particular tasks in this manner.
From: tom.rmadilo on
On Jun 5, 11:28 am, "Gerald W. Lester" <Gerald.Les...(a)KnG-
Consulting.net> wrote:
> Fredrik Karlsson wrote:
> > Hi,
>
> > I've been trying to get hold of a parser generator + lexer combination
> > that would give me a parser implemented in Tcl, that actually works.
>
> > My experience so far:
>
> > taccle + fickle - just outputs nothing. Even the demos fails to give
> > any ouput.
> > Yeti - I get bus error every time I use either the parser or the lexer
> > demos.
>
> > I am using UTF-8 encoding.. Are there other options out there that I
> > should try before continuing my current work of rolling my own parser
> > from scratch?
>
> If you have control over the input language, how about using a safe interp
> and letting the Tcl parser parse it for you.

I don't understand, if the Tcl parser can parse the language, wouldn't
it be Tcl? But even so, since the Tcl parser doesn't enforce command
structure, how does this end up working? There must be a simple
example of this concept, which would be very helpful if you don't
really need a flex/bison type generator.

From: Uwe Klein on
tom.rmadilo wrote:
> On Jun 5, 11:28 am, "Gerald W. Lester" <Gerald.Les...(a)KnG-
> Consulting.net> wrote:
>
>>Fredrik Karlsson wrote:
>>
>>>Hi,
>>
>>>I've been trying to get hold of a parser generator + lexer combination
>>>that would give me a parser implemented in Tcl, that actually works.
>>
>>>My experience so far:
>>
>>>taccle + fickle - just outputs nothing. Even the demos fails to give
>>>any ouput.
>>>Yeti - I get bus error every time I use either the parser or the lexer
>>>demos.
>>
>>>I am using UTF-8 encoding.. Are there other options out there that I
>>>should try before continuing my current work of rolling my own parser
>>>from scratch?
>>
>>If you have control over the input language, how about using a safe interp
>>and letting the Tcl parser parse it for you.
>
>
> I don't understand, if the Tcl parser can parse the language, wouldn't
> it be Tcl?

Sure.

> But even so, since the Tcl parser doesn't enforce command
> structure, how does this end up working? There must be a simple
> example of this concept, which would be very helpful if you don't
> really need a flex/bison type generator.

The basic idea about tcl:
Being a framework for most "domain specific language" instances
you could need,


uwe

>
From: Will Duquette on
On Jun 5, 9:18 pm, "tom.rmadilo" <tom.rmad...(a)gmail.com> wrote:
> On Jun 5, 11:28 am, "Gerald W. Lester" <Gerald.Les...(a)KnG-
>
>
>
>
>
> Consulting.net> wrote:
> > Fredrik Karlsson wrote:
> > > Hi,
>
> > > I've been trying to get hold of a parser generator + lexer combination
> > > that would give me a parser implemented in Tcl, that actually works.
>
> > > My experience so far:
>
> > > taccle + fickle - just outputs nothing. Even the demos fails to give
> > > any ouput.
> > > Yeti - I get bus error every time I use either the parser or the lexer
> > > demos.
>
> > > I am using UTF-8 encoding.. Are there other options out there that I
> > > should try before continuing my current work of rolling my own parser
> > > from scratch?
>
> > If you have control over the input language, how about using a safe interp
> > and letting the Tcl parser parse it for you.
>
> I don't understand, if the Tcl parser can parse the language, wouldn't
> it be Tcl? But even so, since the Tcl parser doesn't enforce command
> structure, how does this end up working? There must be a simple
> example of this concept, which would be very helpful if you don't
> really need a flex/bison type generator.

The trick is, you define a set of Tcl commands that provide the
functionality you're looking for. These commands do all necessary
error checking. Then, you put these commands in a safe interpreter
that contains only the commands in your little language, along with
any standard Tcl commands you want to provide (like expr).

As you say, the resulting language is Tcl--in just the same sense as
little languages built on Lisp remain Lisp. But for many
applications, that's fine. Which is why Gerald asked whether Fredrik
had control of the input syntax or not.
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12
Prev: BLT
Next: how can i bind page up/down to a large option menu