Does GNU FORTH have an editor?

♀尐吖头ヾ 提交于 2019-12-11 04:15:53

问题


Chapter 3 of Starting FORTH says,

Now that you've made a block "current", you can list it by simply typing the word L. Unlike LIST, L does not want to be proceeded by a block number; instead it lists the current block.

When I run 180 LIST, I get

Screen 180 not modified     
0                                                                 
...                                                             
15                                                                 
 ok

But when I run L, I get an error

:30: Undefined word
>>>L<<<
Backtrace:
$7F0876E99A68 throw 
$7F0876EAFDE0 no.extensions 
$7F0876E99D28 interpreter-notfound1 

What am I doing wrong?


回答1:


Yes, gForth supports an internal (BLOCK) editor. Start gforth

  1. type: use blocked.fb (a demo page)
  2. type: 1 load
  3. type editor
  4. words will show the editor words,

    s b n bx nx qx dl il f y r d i t 'par 'line 'rest c a m  ok
    
  5. type 0 l to list screen 0 which describes the editor,

    Screen 0 not modified     
     0 \\ some comments on this simple editor                 29aug95py
     1 m marks current position        a goes to marked position       
     2 c moves cursor by n chars       t goes to line n and inserts    
     3 i inserts                       d deletes marked area           
     4 r replaces marked area          f search and mark               
     5 il insert a line                dl delete a line                
     6 qx gives a quick index          nx gives next index             
     7 bx gives previous index                                         
     8 n goes to next screen           b goes to previous screen       
     9 l goes to screen n              v goes to current screen        
    10 s searches until screen n       y yank deleted string           
    11                                                                 
    12 Syntax and implementation style a la PolyFORTH                  
    13 If you don't like it, write a block editor mode for Emacs!      
    14                                                                 
    15                                                                 
     ok
    

Creating your own block file

To create your own new block file myblocks.fb

  1. type: use blocked.fb
  2. type: 1 load
  3. type editor

Then

  1. type use myblocks.fb
  2. 1 load will show BLOCK #1 (lines 0 till 15. 16 Lines of 64 characters each)
  3. 1 t will highlight line 1
  4. Type i this is text to [i]nsert into line 1
  5. After the current BLOCK is edited type flush in order to write BLOCK #1 to the file myblocks.fb

For more information see, gForth Blocks




回答2:


gforth is well integrated with emacs. In my xemacs here, by default any file called *.fs is considered FORTH source. "C-h m", as usual, gives the available commands.




回答3:


It turns out these are "Editor Commands" the book says,

For Those Whose EDITOR Doesn't Follow These Rules

The FORTH-79 Standard does not specify editor commands. Your system may use a different editor; if so, check your systems documentation

I don't believe gforth supports an internal editor at all. So L, T, I, P, F, E, D, R are all presumably unsupported.




回答4:


No, GNU Forth doesn't have an internal editor; I use Vim :)



来源:https://stackoverflow.com/questions/48837115/does-gnu-forth-have-an-editor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!