forth

Does gforth contain network socket capability?

安稳与你 提交于 2019-12-06 06:51:36
问题 Often, when learning a language I'll write a server of some sort. Does gforth have the capability to use network sockets? I don't see anything about sockets in the manual. 回答1: Though I don't see any documentation about it, there is a socket.fs which binds to libc. You can find some examples of FORTH that use sockets.fs on Rosetta Code, specifically the ECHO server example Provided under the GNU FDL, from Rossetta code by IanOsgood (commit) include unix/socket.fs 128 constant size : (echo) (

Compiling Gforth without Gforth?

与世无争的帅哥 提交于 2019-12-05 17:48:21
When I try to compile Gforth 0.7.0, I get the following error: $ ./configure $ make #compiling… Undefined symbols: "_main", referenced from: start in crt1.10.6.o ld: symbol(s) not found collect2: ld returned 1 exit status make[3]: *** [gforth-ll] Error 1 ./preforth -p ".:~+:." -e 's" mach16b.fs"' ./kernel/main.fs -e "save-cross kernl16b.fi- /usr/local/bin/gforth-0.7.0 bye" You need to configure with a gforth in $PATH to build this part make[3]: *** [kernl16b.fi-] Error 1 make[2]: *** [gforth-ll] Error 2 make[1]: *** [optgforth] Error 2 make: *** [gforth] Error 2 [22:16:01] gforth-0.7.0$ I get

Does gforth contain network socket capability?

北慕城南 提交于 2019-12-04 16:27:26
Often, when learning a language I'll write a server of some sort. Does gforth have the capability to use network sockets? I don't see anything about sockets in the manual . Though I don't see any documentation about it, there is a socket.fs which binds to libc. You can find some examples of FORTH that use sockets.fs on Rosetta Code , specifically the ECHO server example Provided under the GNU FDL, from Rossetta code by IanOsgood ( commit ) include unix/socket.fs 128 constant size : (echo) ( sock buf -- sock buf ) begin cr ." waiting..." 2dup 2dup size read-socket nip dup 0> while ." got: "

How to implement LOOP in a FORTH-like language interpreter written in C

孤街浪徒 提交于 2019-12-04 08:11:18
问题 I'm writing a simple stack-based language in C and was wondering how I should go about implementing a loop structure of some kind, and/or lookahead symbols. Since the code is a bit long for this page (over 200 lines) I've put it in a GitHub repository. EDIT: The main program is in file stack.c . EDIT: The code just takes in input in words , kind of like FORTH. It uses scanf and works left to right. Then it uses a series of if s and strcmp s to decide what to do. That's really it. 回答1: The

How do I debug jonesforth with GDB?

不打扰是莪最后的温柔 提交于 2019-12-04 05:34:48
问题 jonesforth is typically started as follows: cat jonesforth.f - | ./jonesforth What's a good way to debug jonesforth ? 回答1: On Ubuntu? If you're on Ubuntu, allow gdb to attach to running processes: echo 0 > /proc/sys/kernel/yama/ptrace_scope If you'd like that setting to remain across reboots: vim /etc/sysctl.d/10-ptrace.conf Update Makefile Add the g flag to your jonesforth Makefile recipe: jonesforth: jonesforth.S gcc -g -m32 -nostdlib -static $(BUILD_ID_NONE) -o $@ $< Starting gdb Then,

Memory management in Forth

末鹿安然 提交于 2019-12-03 07:22:55
问题 So I'm just learning Forth and was curious if anyone could help me understand how memory management generally works. At the moment I only have (some) experience with the C stack-vs-heap paradigm. From what I understand, one can allocate in the Dictionary, or on the heap. Is the Dictionary faster/preferred like the stack in C? But unlike in C, there aren't scopes and automatic stack reclamation, so I'm wondering if one only uses the dictionary for global data structures (if at all). As far as

How to implement LOOP in a FORTH-like language interpreter written in C

痞子三分冷 提交于 2019-12-02 22:59:51
I'm writing a simple stack-based language in C and was wondering how I should go about implementing a loop structure of some kind, and/or lookahead symbols. Since the code is a bit long for this page (over 200 lines) I've put it in a GitHub repository . EDIT: The main program is in file stack.c . EDIT: The code just takes in input in words , kind of like FORTH. It uses scanf and works left to right. Then it uses a series of if s and strcmp s to decide what to do. That's really it. The Forth approach is to add a separate loop stack alongside the data stack. You then define operations that work

Memory management in Forth

别来无恙 提交于 2019-12-02 20:57:32
So I'm just learning Forth and was curious if anyone could help me understand how memory management generally works. At the moment I only have (some) experience with the C stack-vs-heap paradigm. From what I understand, one can allocate in the Dictionary, or on the heap. Is the Dictionary faster/preferred like the stack in C? But unlike in C, there aren't scopes and automatic stack reclamation, so I'm wondering if one only uses the dictionary for global data structures (if at all). As far as the heap goes, is it pretty much like C? Is heap management a standard ( ANS ) concept, or is it

Forth language EBNF rule for an infinite loop or if statement

青春壹個敷衍的年華 提交于 2019-12-02 00:07:14
问题 Is there an EBNF rule that describes a Forth infinite loop or if statement? 回答1: EBNF is used to describe syntax . A loop being infinite or otherwise wouldn't normally fall within what it would describe. As such, you'd be looking at the EBNF for an indefinite loop, which looks something like: indefinite_loop ::= 'BEGIN' statements cond 'UNTIL' Normally the cond will be something that pushes a 0 or 1 on the stack to determine whether to continue the loop ( 0 means continue the loop, 1 means

What are the primitive Forth operators? [closed]

一世执手 提交于 2019-11-29 20:37:57
I'm interested in implementing a Forth system, just so I can get some experience building a simple VM and runtime. When starting in Forth, one typically learns about the stack and its operators (DROP, DUP, SWAP, etc.) first, so it's natural to think of these as being among the primitive operators. But they're not. Each of them can be broken down into operators that directly manipulate memory and the stack pointers. Later one learns about store (!) and fetch (@) which can be used to implement DUP, SWAP, and so forth (ha!). So what are the primitive operators? Which ones must be implemented