Программный код должен быть в кодировке UTF-8. Символы вне диапазона [32.. 127] допускаются только внутри строковых литералов. Табуляция запрещена.
Виды лексем:
- Пунктуация
| let assert = require('assert') | |
| let util = require('util') | |
| let defined = value => value !== undefined | |
| let notDefined = value => value === undefined | |
| let not = value => ! value | |
| let log = console.log | |
| let say = (msg, value) => (log(msg), value) |
| import Control.Exception ( SomeException(..), catch ) | |
| import Control.Monad ( when ) | |
| import Data.Foldable ( for_ ) | |
| import System.Directory ( doesDirectoryExist | |
| , doesPathExist | |
| , listDirectory | |
| , pathIsSymbolicLink | |
| ) | |
| import System.FilePath ( (</>) ) |
| module.exports.Struct = (thunk) => { | |
| let klass = null | |
| return class { | |
| constructor(args) { | |
| Object.assign(this, args) | |
| } | |
| static of(args) { | |
| if (!klass) { |
| var same = x => x | |
| /* | |
| data Either e a = Ok { value: a } | Err { msg: e } | |
| This means, the "Either e a" (for any types "a" and "e") | |
| is the type of either: | |
| - type Ok, containing field "value" of type "a"; | |
| - type Err, containing field "msg" of type "e". |
| fun readLine () = TextIO.inputLine TextIO.stdIn | |
| fun writeLine str = TextIO.outputSubstr (TextIO.stdOut, Substring.full str) | |
| fun main () = | |
| let | |
| val words = String.tokens (fn x => x = #" ") | |
| fun input keys vals = | |
| case readLine () of |
| """ | |
| I want to store some call tree, like | |
| > push 1 | |
| > seq do | |
| > dup | |
| > push 1 | |
| > drop | |
| > end |
| // append elem to list with number of the list cell - 'time' | |
| var Push = (head, tail) => ({head, tail, time: ++Push.time}) | |
| Push.time = 0 | |
| // this is the empty list - append to it or other list only | |
| var Empty = {empty: true} | |
| // flip(f) is 'f' but with args swapped | |
| var flip = (f) => (x, y) => f(y, x) |
| require 'set' | |
| def contents(filename) | |
| acc = [] | |
| File.open(filename, 'r') do |fin| | |
| while (line = fin.gets) | |
| acc << line | |
| end | |
| end |
| /* | |
| * Here we build simple virtual machine for Joy programming language, | |
| * or smth like that. Go google it. No, seriously. | |
| */ | |
| /* | |
| * We want to distingush constants 'foo' and funcalls `new Name('foo')` | |
| */ | |
| class Name { |