Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #20667

Re: Where to find papers on Forth

From Bernd Paysan <bernd.paysan@gmx.de>
Newsgroups comp.lang.forth
Subject Re: Where to find papers on Forth
Date 2013-03-14 17:30 +0100
Organization 1&1 Internet AG
Message-ID <khstvf$d2l$1@online.de> (permalink)
References <934ce567-c443-4a43-8782-734540bad605@googlegroups.com> <khpqa9$3nd$1@online.de> <f3c94146-5cee-47b3-b9ec-5443d8dbdffc@googlegroups.com>

Show all headers | View raw


Eduardo Costa wrote:
> It would be a great service to the Forth community to keep that page
> active. In particular, it would be great if you could fix Brad Rodriguez'
> program. The way it is, it does not work on gforth, sp-forth, and
> bigforth. I guess that this would do the trick:

I try to stay as close to the original as possible.  The version I've online 
does work in Gforth and bigForth.  Don't know about sp-Forth.  The only non-
standard word in there is recursive.

> It would be great if you agree in providing a link to examples. Of course,
> the examples don't need to meet the requirement of 16 lines. Here is an
> example for Brad Rodriguez' parser:

That example doesn't use the original parser, and needs fixing.  This 
version works, and it doesn't use the bad idea of a 0 terminator outside the 
input buffer.

\ BNF example
include bnf.fs
: 0bnf ( -- )  true success ! ;
: /bnf ( -- )  source nip >in ! ;
: tkn create dup c, bounds ?do I c@ c, loop
  does> count bounds ?do I C@ =token loop ;
S" cat" tkn <cat>
S" ball" tkn <ball>
bnf: <noun> <cat> | <ball> | ; 
S" the" tkn <the>   S" your" tkn <your>
bnf: <det> <the> | <your> | ;bnf 
: <end-of-line> source nip >in @ = success ! ;
bl token <blank>
bnf: <np>  <det> <blank> <noun>  ;bnf
: parsex 0bnf <np> <end-of-line> /bnf
  cr success @ if ." matched " CR 
  else ." failed " CR then ;

parsex your cat
parsex the ball

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/

Back to comp.lang.forth | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Where to find papers on Forth Eduardo Costa <edu500ac@gmail.com> - 2013-03-13 03:24 -0700
  Re: Where to find papers on Forth Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-13 13:09 +0100
    Re: Where to find papers on Forth Brad Eckert <hwfwguy@gmail.com> - 2013-03-13 09:50 -0700
    Re: Where to find papers on Forth Eduardo Costa <edu500ac@gmail.com> - 2013-03-14 08:04 -0700
      Re: Where to find papers on Forth Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-14 17:30 +0100

csiph-web