streamscript

所属分类:编程语言基础
开发工具:TypeScript
文件大小:0KB
下载次数:0
上传日期:2023-10-18 18:42:19
上 传 者sh-1993
说明:  一种基于流的编程语言,
(A stream-based programming language,)

文件列表:
.babelrc (145, 2023-10-18)
.eslintignore (29, 2023-10-18)
.eslintrc (1462, 2023-10-18)
.npmrc (18, 2023-10-18)
LICENSE (1083, 2023-10-18)
dist/ (0, 2023-10-18)
dist/index.html (440, 2023-10-18)
dist/main.css (2019, 2023-10-18)
package-lock.json (590667, 2023-10-18)
package.json (1961, 2023-10-18)
src/ (0, 2023-10-18)
src/compiler/ (0, 2023-10-18)
src/compiler/graph.ts (3420, 2023-10-18)
src/compiler/graph_builder.ts (9348, 2023-10-18)
src/compiler/index.ts (7424, 2023-10-18)
src/compiler/util.ts (842, 2023-10-18)
src/main.ts (2832, 2023-10-18)
src/parser/ (0, 2023-10-18)
src/parser/ast.ts (3540, 2023-10-18)
src/parser/grammar.ohm (2543, 2023-10-18)
src/parser/index.ts (3799, 2023-10-18)
src/runtime/ (0, 2023-10-18)
src/runtime/component_loader.ts (1994, 2023-10-18)
src/runtime/components/ (0, 2023-10-18)
src/runtime/components/core.ts (7340, 2023-10-18)
src/runtime/components/io.ts (1022, 2023-10-18)
src/runtime/components/operators.ts (1868, 2023-10-18)
src/runtime/graph_runner.ts (3397, 2023-10-18)
src/runtime/index.ts (165, 2023-10-18)
src/runtime/lib/ (0, 2023-10-18)
src/runtime/lib/BaseComponent.ts (3075, 2023-10-18)
src/runtime/lib/GeneratorComponent.ts (940, 2023-10-18)
src/runtime/lib/InPort.ts (3051, 2023-10-18)
src/runtime/lib/Mailbox.ts (566, 2023-10-18)
src/runtime/lib/OutPort.ts (3076, 2023-10-18)
... ...

# StreamScript A stream-based programming language. This is an experiment to see how far we can take streams as the basic unit of computation on a language. ## Computation Model StreamScript's runtime model is heavily inspired in concepts from [Flow-Based Programming](https://en.wikipedia.org/wiki/Flow-based_programming) and [Reactive Streams](https://www.reactive-streams.org). StreamScript programs get compiled to a computation graph. Nodes in this computation graphs are _components_ - black boxes with a fixed number of _input ports_ and _output ports_ - while edges are connections from out ports to in ports. Initial values can be connected to in ports to inject constant data into the graph. When executed, components are instantiated as asynchronous _processes_ which exchange messages (_packets_) between them until all components _terminate_ (come to a halt). Contrary to flow-based programming, streams in StreamScript are pull-based: a process cannot emit elements to an out port unless connected in ports request them. Internally, component ports follow [the JavaScript's spec](https://github.com/reactive-streams/reactive-streams-js/) of [Reactive Streams](https://www.reactive-streams.org). This means a few things: - Communication between ports is actually bidirectional: data and completion/error signals flow downstream, while demand signals flow upstream; - A back pressure mechanism is in place to prevent fast producers overloading slow consumers; - Processes are typically lazy: they don't pull from in ports and perform work until demand is signalled from consumers connected to out ports. ## Language For example programs, take a look at [test/runtime/_sstests](https://github.com/ruippeixotog/streamscript/tree/master/test/runtime/_sstests). If you're feeling brave you can also read the [PEG grammar](https://github.com/ruippeixotog/streamscript/blob/master/src/parser/grammar.ohm). ### Element Types Elements emitted and received by components are of any JavaScript primitive value (anything representable as JSON). ### Constants Constants compile to components that emit the value a single time and then complete. ### Symbols Symbols (akin to variables in other languages) compile to single-input, single-output identity components. They can be used to give nicer names to certain pipes and connect different components. ### Operators `->` and `<-` are special operators used to connect components: - `a -> b` (equivalent to `b <- a`) connects the out ports of `a` to the in ports of `b`. The out-arity of `a` is expected to match the in-arity of `b`; - `(a1, a2) -> b` connects the out ports of `a1` and `a2` to the in ports of `b` (ports in components are ordered, so the left side is treated as the concatenation of out ports of `a1` and `a2`). Pairing can be used on both sides of the expression. All other operators apply operations element-wise, pairing input elements in case of binary operations. For example: - `a + b` pairs each element emitted by `a` with an element emitted by `b` and emits an element with value `a + b`; - `a[idx]` pairs each element emitted by `a` (expected to be an array or object) with an element emitted by `idx` and emits an element with value `arr[idx]` (`arr` indexed by `idx`). Type coercion in StreamScript occurs with the same semantics as JavaScript. ### Functions Functions define a new type of component that can be instantiated multiple times later. ## Standard Library You can take a look at [this folder](https://github.com/ruippeixotog/streamscript/tree/master/src/runtime/sslib). Function names are mostly taken from [Akka Streams](https://doc.akka.io/docs/akka/current/stream/index.html), so if you're unsure of what some function does try to find it [here](https://doc.akka.io/docs/akka/current/stream/operators/index.html). ## Copyright Copyright (c) 2020 Rui Gonalves. See LICENSE for details.

近期下载者

相关文件


收藏者