Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arkaeriit/preforth
A Forth preprocessor written in Forth
https://github.com/arkaeriit/preforth
forth preprocessors
Last synced: 26 days ago
JSON representation
A Forth preprocessor written in Forth
- Host: GitHub
- URL: https://github.com/arkaeriit/preforth
- Owner: Arkaeriit
- License: mit
- Created: 2020-03-30T16:34:26.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-11-22T11:44:25.000Z (about 1 month ago)
- Last Synced: 2024-11-22T12:33:21.384Z (about 1 month ago)
- Topics: forth, preprocessors
- Language: Forth
- Size: 14.6 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Preforth
A Forth preprocessor written in Forth.
## User manual
### Usage
```
preforth
```
This program parse the input file, searching for some tags. If no tags are found at the beginning of a line, the line is copied on the output file.
List of tags:
* `\ #IN filename` : include non-recursively. Dump the content of `filename` in the output file.
* `\ #IR filename` : include recursively. Process `filename` and put the result in the output file. Similar to #include in C preprocessors.
* `\ #SI` : stop the inclusion. Stop the preprocessing of the file. Useful when used alongside `#IR`.### Example
Let's imagine we have three files.
file1
```
Some text 1
\ #IN file2
Some text 2
\ #IR file2
Some text 3
```
file2
```
Some text 4
\ #IN file3
Some text 5
\ #SI
Some text 6
```file3
```
Some text 7
```If you typed `./preforth file1 file4` the content of file4 would be:
```
Some text 1
Some text 4
\ #IN file3
Some text 5
\ #SI
Some text 6
Some text 2
Some text 4
Some text 7
Some text 5
Some text 3
```
When we included file2 with the tag #IN the tags #IN and #SI inside of file2 were ignored. But when we included it with #IR they were taken into account.## Utilisation and installation
Preforth is meant to be run with [Gforth](https://gforth.org) or [SEForth](https://github.com/Arkaeriit/SEForth) but it could works with other Forth implementation. A version working with Ciforth can be found in the git branch named `ciforth`.
Here is how you can install it if you want to use Gforth:
```sh
sudo cp preforth.frt /usr/local/bin/
printf '#!/bin/sh\n/usr/bin/env gforth /usr/local/bin/preforth.frt "$@"\n' | sudo tee /usr/local/bin/preforth > /dev/null
sudo chmod +x /usr/local/bin/preforth
```Here is how you can install it if you want to use SEForth:
```sh
printf '#!/usr/bin/env seforth\n' | sudo tee /usr/local/bin/preforth > /dev/null
cat preforth.frt | sudo tee -a /usr/local/bin/preforth > /dev/null
sudo chmod +x /usr/local/bin/preforth
```