funcity 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +109 -0
- package/dist/index.cjs +2005 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +2005 -0
- package/dist/index.mjs.map +1 -0
- package/dist/parser.d.ts +220 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/reducer.d.ts +125 -0
- package/dist/reducer.d.ts.map +1 -0
- package/dist/scripting.d.ts +36 -0
- package/dist/scripting.d.ts.map +1 -0
- package/dist/standards.d.ts +53 -0
- package/dist/standards.d.ts.map +1 -0
- package/dist/tokenizer.d.ts +96 -0
- package/dist/tokenizer.d.ts.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# funcity
|
|
2
|
+
|
|
3
|
+
A functional language interpreter with text processing.
|
|
4
|
+
|
|
5
|
+
[](https://www.repostatus.org/#wip)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## What is this?
|
|
11
|
+
|
|
12
|
+
This is a lightweight functional language processor implemented in TypeScript, featuring syntax extensions for text processing.
|
|
13
|
+
It includes a CLI application and a library package containing only the core engine.
|
|
14
|
+
|
|
15
|
+
funcity can be considered a type of [text template processor](https://en.wikipedia.org/wiki/Template_processor).
|
|
16
|
+
For example, entering code like this:
|
|
17
|
+
|
|
18
|
+
```funcity
|
|
19
|
+
Today is {{if weather.sunny}}nice{{else}}bad{{end}}weather.
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Evaluates the value of the `weather` variable manually bound to the core engine beforehand and generates different text outputs:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
Today is bad weather.
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The `if ... else ... end` statements in the text indicate that the script is being executed.
|
|
29
|
+
So, you might ask, what makes this a "Functional language"?
|
|
30
|
+
Or how is it different from existing text processors?
|
|
31
|
+
|
|
32
|
+
Let me show you another equivalent example:
|
|
33
|
+
|
|
34
|
+
```funcity
|
|
35
|
+
Today is {{cond weather.sunny 'nice' 'bad'}} weather.
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This is an example of function application,
|
|
39
|
+
inserting the result of applying three arguments to the `cond` function.
|
|
40
|
+
The first argument is a conditional expression.
|
|
41
|
+
|
|
42
|
+
The following code may further interest you:
|
|
43
|
+
|
|
44
|
+
```funcity
|
|
45
|
+
{{
|
|
46
|
+
set printWeather (fun w cond w.sunny 'nice' 'bad')
|
|
47
|
+
}}
|
|
48
|
+
Today is {{printWeather weather}} weather.
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- `fun` defines an anonymous lambda function.
|
|
52
|
+
- `set` performs a mutable binding in the current scope.
|
|
53
|
+
|
|
54
|
+
In other words, funcity is an interpreter that brings the power of functional programming to text template processors, making them easier to handle!
|
|
55
|
+
|
|
56
|
+
### Features
|
|
57
|
+
|
|
58
|
+
- A lightweight functional language processor for handling untyped lambda calculus.
|
|
59
|
+
Adopted the simplest possible syntax.
|
|
60
|
+
Additionally, selected the syntax extensions that should be prioritized for text processing.
|
|
61
|
+
- All function objects are treated as asynchronous functions.
|
|
62
|
+
You do not need to be aware that they are asynchronous functions when applying them.
|
|
63
|
+
- There is also a CLI using the core engine.
|
|
64
|
+
The CLI has both REPL mode and text processing mode.
|
|
65
|
+
- The core engine includes a tokenizer, parser, and reducer (interpreter).
|
|
66
|
+
- The core engine library is highly independent,
|
|
67
|
+
requiring no dependencies on other libraries or packages.
|
|
68
|
+
It can be easily integrated into your application.
|
|
69
|
+
- Parsers and interpreters support both interpreting pure expressions and interpreting full text-processing syntax.
|
|
70
|
+
This means that even when an interpreter for a purely functional language is required,
|
|
71
|
+
it is possible to completely ignore the (somewhat incongruous) syntax of text processing.
|
|
72
|
+
- Allows pre-binding of useful standard function implementations.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Installation (CLI)
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm install -D funcity-cli
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Or, global installation:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm install -g funcity-cli
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Installation (Library)
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm install funcity
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Documentation
|
|
97
|
+
|
|
98
|
+
For detailed documentation and advanced features, please visit our [GitHub repository](https://github.com/kekyo/funcity).
|
|
99
|
+
|
|
100
|
+
## Note
|
|
101
|
+
|
|
102
|
+
funcity was separated from the document site generator [mark-the-ripper](https://github.com/kekyo/mark-the-ripper) during its design phase,
|
|
103
|
+
as it seemed better suited to function as an independent scripting engine.
|
|
104
|
+
|
|
105
|
+
Therefore, mark-the-ripper can leverage the power of funcity's functional language.
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
Under MIT.
|