Skip to content

Commit f894772

Browse files
committed
Initial commit
Add readme. Add license. Add .gitignore. Add .gitattributes. Add repository logo.
0 parents  commit f894772

File tree

5 files changed

+139
-0
lines changed

5 files changed

+139
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Prevent Linguist from detecting Funcy files as Fancy files:
2+
*.fy linguist-language=Text

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OS:
2+
.DS_Store
3+
desktop.ini
4+
Thumbs.db
5+
6+
# IDE:
7+
.idea/*
8+
.vscode/*
9+
*.code-workspace
10+
*.sublime-project
11+
*.sublime-workspace
12+
*.suo
13+
14+
# Python:
15+
__pycache__/*
16+
*$py.class
17+
*.pyc
18+
*.pyd
19+
*.pyo
20+
*.so
21+
22+
# Ignore:
23+
ignore/*

license.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Chris Roberts
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.

logo.png

170 Bytes
Loading

readme.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Funcy
2+
_A toy functional language written in Python._
3+
__Copyright © 2022 Chris Roberts__ (Krobbizoid).
4+
5+
# Contents
6+
1. [About](#about)
7+
2. [Example](#example)
8+
3. [Grammar](#grammar)
9+
4. [License](#license)
10+
11+
# About
12+
Funcy is a toy functional language written in Python. It is developed as an
13+
exercise to test implementing functions in an interpreted language. It is _not_
14+
suitable as a practical language, or as a guide for creating a programming
15+
language.
16+
17+
# Example
18+
Below is a 'hello world' program written in Funcy that demonstrates the feature
19+
set for its initial implementation. The initial implementation is only useful
20+
for printing a fixed sequence of integers:
21+
```
22+
/*
23+
* Funcy uses C-like line and block comments. Funcy source code files should be
24+
* named with the file extension '.fy'.
25+
*
26+
* /*
27+
* * Block comments may be nested inside of other block comments.
28+
* */
29+
*/
30+
31+
/*
32+
* A Funcy program contains 0 or more top-level function declarations. These
33+
* begin with the 'func' keyword and a function name, followed by a list of
34+
* parameter names in parentheses, and a function body in a compound statement.
35+
* In the initial implementation, functions are not callable and their
36+
* parameters can't be used.
37+
*/
38+
func foo(bar, baz){}
39+
40+
/*
41+
* If a function named 'main' exists, it will be used as the entry point for the
42+
* program.
43+
*/
44+
func main(){
45+
/*
46+
* In the initial implementation, 'print' is a keyword, and not the name of
47+
* a standard function. In this example, '(123)' is actually a parenthesized
48+
* expression. The parentheses may be omitted, but they improve
49+
* compatibility with potential future versions. Only integers are available
50+
* in the initial implementation, so '123' is printed instead of a hello
51+
* world message.
52+
*/
53+
print(123);
54+
55+
/*
56+
* Curly braces mark compound statements that contain 0 or more statements
57+
* in their own scope.
58+
*/
59+
{
60+
/*
61+
* A statement may contain a standalone expression. No operations are
62+
* available in the initial implementation.
63+
*/
64+
456;
65+
66+
; // A semicolon on its own marks a no operation statement.
67+
}
68+
}
69+
```
70+
71+
# Grammar
72+
The EBNF (Extended Backus-Naur Form) grammar for Funcy's initial implementation
73+
is as follows:
74+
```EBNF
75+
program = { func_decl }, EOF ;
76+
func_decl = "func", IDENTIFIER, "(", [ param_decls ], ")", stmt_compound ;
77+
param_decls = IDENTIFIER, { ",", IDENTIFIER } ;
78+
79+
stmt = stmt_compound | stmt_nop | stmt_print | stmt_expr ;
80+
stmt_compound = "{", { stmt }, "}" ;
81+
stmt_nop = ";" ;
82+
stmt_print = "print", expr, ";" ;
83+
stmt_expr = expr, ";" ;
84+
85+
expr = expr_primary ;
86+
expr_primary = "(", expr, ")" | LITERAL_INT ;
87+
```
88+
89+
# License
90+
Funcy is released under the MIT License:
91+
https://krobbi.github.io/license/2022/mit.txt
92+
93+
See [license.txt](./license.txt) for a full copy of the license text.

0 commit comments

Comments
 (0)