https://github.com/gmpalter/cl-forth Skip to content Navigation Menu Toggle navigation Sign in * Product + GitHub Copilot Write better code with AI + Security Find and fix vulnerabilities + Actions Automate any workflow + Codespaces Instant dev environments + Issues Plan and track work + Code Review Manage code changes + Discussions Collaborate outside of code + Code Search Find more, search less Explore + All features + Documentation + GitHub Skills + Blog * Solutions By size + Enterprise + Teams + Startups By industry + Healthcare + Financial services + Manufacturing By use case + CI/CD & Automation + DevOps + DevSecOps * Resources Topics + AI + DevOps + Security + Software Development + View all Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} gmpalter / cl-forth Public * Notifications You must be signed in to change notification settings * Fork 3 * Star 69 Common Lisp implementation of the Forth 2012 Standard License MIT license 69 stars 3 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 1 * Pull requests 1 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights gmpalter/cl-forth This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main BranchesTags Go to file Code Folders and files Last commit Last Name Name message commit date Latest commit History 311 Commits examples examples forth-words forth-words tests @ 3514102 tests @ 3514102 .gitignore .gitignore .gitmodules .gitmodules FFI.md FFI.md LICENSE LICENSE README.md README.md asdf-support.lisp asdf-support.lisp ccl-application.lisp ccl-application.lisp cl-forth.asd cl-forth.asd compatibility.lisp compatibility.lisp dummy-ffi.lisp dummy-ffi.lisp exceptions.lisp exceptions.lisp execution-tokens.lisp execution-tokens.lisp ffi.lisp ffi.lisp files.lisp files.lisp helpers.lisp helpers.lisp in-memory-streams.lisp in-memory-streams.lisp lw-application.lisp lw-application.lisp memory.lisp memory.lisp numbers.lisp numbers.lisp packages.lisp packages.lisp prefixed-stream.lisp prefixed-stream.lisp run.lisp run.lisp sbcl-application.lisp sbcl-application.lisp stacks.lisp stacks.lisp strings.lisp strings.lisp system.lisp system.lisp templates.lisp templates.lisp timestamped-stream.lisp timestamped-stream.lisp version.text version.text words.lisp words.lisp View all files Repository files navigation * README * MIT license CL-Forth Common Lisp implementation of the Forth 2012 Standard, CL-Forth Supported Platforms CL-Forth is fully supported by CCL v1.12.2-82 or later. CL-Forth also supports SBCL 2.1.0 or later. However, at present, the word RESIZE-FILE will always return an error indication, resulting in 7 failures in the File-Access word set tests. CL-Forth compiles with LispWorks but crashes running the Forth test suite. Supported Operating Systems CL-Forth is supported on macOS, Linux, and Windows. On macOS, it has been verified to run on macOS Ventura or later. On Linux, it has been verified to run on distributions with 5.10.162 kernels or later. On Windows, it has been verified to run on Windows 10 or later. License CL-Forth is made available under the terms of the MIT License. Usage CL-Forth is defined using ASDF and is dependent on the CFFI and trivial-gray-streams libraries. To fetch a copy of CL-Forth and the Forth 2012 Test Suite configured to only run tests for those word sets implemented by CL-Forth. git clone https://github.com/gmpalter/cl-forth.git --recurse-submodules To load CL-Forth into Lisp (require '#:asdf) (load "cl-forth.asd") (asdf:load-system '#:cl-forth) You can run the Forth 2012 Test Suite (asdf:test-system '#:cl-forth) To start the CL-Forth interpreter loop (forth:run) CL-Forth is case-insensitive. Building a Standalone CL-Forth You can build a standalone CL-Forth application. Launch Lisp and evaluate the forms (require '#:asdf) (load "cl-forth.asd") (asdf:load-system '#:cl-forth/application) (forth-app:save-application "cl-forth") This will create an executable named cl-forth. When you run cl-forth, it will startup directly into the Forth interpreter loop. ./cl-forth CL-Forth Version 1.3 Running under Clozure Common Lisp Version 1.13 (v1.13) DarwinX8664 1 1 + . 2 OK. : hello-world ." Hello World!" cr ; OK. hello-world Hello World! OK. see hello-world Source code for hello-world: (DEFUN FORTH-WORDS::HELLO-WORLD (FS &REST PARAMETERS) (DECLARE (IGNORABLE PARAMETERS)) (WITH-FORTH-SYSTEM (FS) (TAGBODY (WRITE-STRING "Hello World!") (TERPRI) :EXIT))) OK. bye In this session: 1 definition created 240 bytes of object code generated The application recognizes these command line arguments Evaluate EXPR before entering the Forth interpreter --interpret EXPR, loop. EXPR may need to be quoted to avoid -i EXPR interpretation by the shell. This argument may be used multiple times. --transcript PATH Record a timestamped transcript of this session in the file PATH --help, -h Display the available command line arguments and exit --version, -V Display the version of CL-Forth and exit Missing Words CL-Forth does not implement the optional Block word set. CL-Forth does not implement the optional Extended-Character word set. CL-Forth does not implement KEY which is part of the Core word set. The following words that are part of the optional Facility and Facility extensions word set are not implemented. AT-XY KEY? PAGE EKEY EKEY>CHAR EKEY>FKEY EKEY? EMIT? K-ALT-MASK K-CTRL-MASK K-DELETE K-DOWN K-END K-F1 K-F10 K-F11 K-F12 K-F2 K-F3 K-F4 K-F5 K-F6 K-F7 K-K8 K-F9 K-HOME K-INSERT K-LEFT K-NEXT K-PRIOR K-RIGHT K-SHIFT-MASK K-UP Foreign Function Interface CL-Forth includes a foreign function interface (FFI) loosely based on the External Library Interface in SwiftForth. See FFI.md for details. Additional Words CL-Forth includes a number of words defined by other implementation that are not part of the Forth 2012 Standard. These words are specific to CL-Forth. .SF Display the contents of the floating-point stack .SR Display the contents of the return stack ALL-WORDS Display all words in all word lists in the search order BREAK Enter a Lisp break loop INLINEABLE Mark that the most recent definition's code may be inlined NOTINTERPRETED Mark that the most recent definition must only appear in definitions RELOAD Reload a predefined definition (i.e., created by define-word) REMOVE Erase a single word SHOW-BACKTRACES Controls whether exceptions display the return and data stacks SHOW-CODE Controls whether completing a definition shows the generated code STATISTICS Report some useful statistics about this CL-Forth session These words are defined as "Common Usage" in the Forth Programmer's Manual, 3rd Edition. ," 2+ 2- C+! CONTEXT CURRENT CVARIABLE M- M/ NOT NUMBER NUMBER? VOCABULARY These words are defined by SwiftForth. -? EMPTY GILD OFF ON OPTIONAL SILENT VERBOSE WARNING \\ { Implementation TO BE SUPPLIED Native Code Support CL-Forth implements CODE and ;CODE to allow the definition of words written in Lisp rather than Forth. The terminator for the Lisp code block is ;ENDCODE. Here is an example of using native code. \ ( c-addr1 u - c-addr2 u) \ Converts the string at C-ADDR1 U to uppercase and leaves the result in transient space at C-ADDR2 U. CODE UPCASE (let ((count (cell-signed (stack-pop data-stack))) (address (stack-pop data-stack))) (unless (plusp count) (forth-exception :invalid-numeric-argument "Count to UPCASE must be positive")) (multiple-value-bind (data offset) (memory-decode-address memory address) (let* ((original (forth-string-to-native data offset count)) (upcased (string-upcase original)) (string-space (reserve-string-space memory)) (address (transient-space-base-address memory string-space))) (ensure-transient-space-holds memory string-space count) (multiple-value-bind (data offset) (memory-decode-address memory address) (native-into-forth-string upcased data offset) (seal-transient-space memory string-space) (stack-push data-stack address) (stack-push data-stack count))))) ;ENDCODE About Common Lisp implementation of the Forth 2012 Standard Topics forth forth-2012 Resources Readme License MIT license Activity Stars 69 stars Watchers 7 watching Forks 3 forks Report repository Releases 4 CL-Forth 1.3.5 Latest Sep 12, 2024 + 3 releases Packages 0 No packages published Languages * Common Lisp 100.0% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.