https://github.com/mrcsparker/crispy
DLR-based programming language. Somewhat functional, somewhat procedural. Made to be fun and easy to use.
https://github.com/mrcsparker/crispy
Last synced: 2 months ago
JSON representation
DLR-based programming language. Somewhat functional, somewhat procedural. Made to be fun and easy to use.
- Host: GitHub
- URL: https://github.com/mrcsparker/crispy
- Owner: mrcsparker
- License: mit
- Created: 2014-08-16T05:27:45.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-05-12T21:39:31.000Z (about 10 years ago)
- Last Synced: 2025-02-14T02:22:55.017Z (4 months ago)
- Language: C#
- Homepage:
- Size: 2.94 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Crispy
======## Introduction
Crispy is a kind-of functional programming language that targets the .NET DLR. It targets both the MS .NET runtime and the Mono .net runtime. It was developed using Mono on Mac OS X and runs on Windows, Mac OS X, and GNU/Linux.
Crispy compiles down to .NET bytecode, so it is very, very fast.
It was developed as a prototype for a rules language.
## License
Crispy uses a MIT License, which means that you can do what you want with it:
+ Use it to learn about the .NET DLR
+ Use it in your FOSS program
+ Use it in your proprietary programPlease send me any bug fixes or enhancements.
## Syntax
Crispy is a simple language.
An example Crispy syntax would be:
if (time == now) then
send("ready")
endifif (1 > 2) then
if (a or b) then
...
endif
elsif (3 < 4) then
...
else
...
endif
Note that you can use if/then/else/elsif/endif or `{`, `}`. Crispy doesn't really care how you like to group your expressions.The other syntax has functions, variables, loops, arrays, lambda expressions, first class functions, namespaces, closures, and .NET integration.
An example of the more advanced syntax would be:
// arrays (well, hashes in this case)
var x = array()x.add('xxx')
x.add(2)
x.add('abc')print(x[0])
x[0] = 'yyy'
// functions
defun add(a, b) {
a + b
}
// variables
var foo = add(1, 2)// lambda expressions
var add2 = lambda(x, y) {
x + y
}add2(3, 4)
// loops
var start = 0
var stop = 10
loop {
start += 1
if (start == stop) {
break
}
}
// combine those, and you can add all sorts of things...
defun map(fn, a) {
var i = 0
loop {
a[i] = fn(a[i])
i = i + 1
if (i == a.count) {
break
}
}
}
var a = array();
a.add(1)
a.add(2)
a.add(3)
var results = map(lambda(x) { x * 2 }, a);
## Crispy EBNF (old, will update)
Expression =
LogicalOrNodeLogicalOrNode =
LogicalAndNode { ( '||' 'OR' ) LogicalAndNode }LogicalAndNode =
ComparisonNode { ( '&&' 'AND' ) ComparisonNode }ComparisonNode =
AdditiveNode { ( '=' '==' '!=' '<>' '>' '>=' '<' '<=' ) AdditiveNode }AdditiveNode =
MultiplicativeNode { ( '+' '-' ) MultiplicativeNode }MultiplicativeNode =
UnaryNode { ( '*' '/' '%' 'MOD' '^' ) UnaryNode }UnaryNode =
(( '-' '!' 'NOT' ) PrimaryNode ) UnaryNode
PrimaryNode =
IdentifierNode | StringLiteralNode | NumberLiteralNode | ParenExpressionNode
IdentifierNode =
FunctionCallNodeStringLiteralNode =
'"' ( Anything )* '"' | ''' ( Anything )* '''FunctionCallNode =
Identifier '(' (ParenExpressionNode)? ')'ParenExpressionNode =
Expression ( ',' Expression ) *NumberLiteralNode =
NumberIdentifier =
Letter ( Letter | Digit | '_' )*Number =
Digit * ( '.' Digit + )? (('e'|'E') ('+'|'-')? Digit + )?Letter =
'a' .. 'z' | 'A' .. 'Z'Digit =
'0' | '1' .. '9'Anything =
Pretty much anything