Merge branch 'Umur-develop' into Umur-reducer-dev

This commit is contained in:
Umur Ozkul 2022-04-23 15:19:38 +02:00
commit 8a9d02168e
2 changed files with 66 additions and 7 deletions

View File

@ -8,7 +8,7 @@ Squiggle is currently pre-alpha.
# Quick links # Quick links
- [Roadmap to the alpha](https://github.com/QURIresearch/squiggle/projects/2) - [Roadmap to the alpha](https://github.com/orgs/quantified-uncertainty/projects/1)
- The team presently communicates via the **EA Forecasting and Epistemics** slack (channels `#squiggle` and `#squiggle-ops`), you can track down an invite by reaching out to Ozzie Gooen - The team presently communicates via the **EA Forecasting and Epistemics** slack (channels `#squiggle` and `#squiggle-ops`), you can track down an invite by reaching out to Ozzie Gooen
- [Squiggle documentation](https://www.squiggle-language.com/docs/Language) - [Squiggle documentation](https://www.squiggle-language.com/docs/Language)
- [Rescript documentation](https://rescript-lang.org/docs/manual/latest/introduction) - [Rescript documentation](https://rescript-lang.org/docs/manual/latest/introduction)
@ -16,14 +16,13 @@ Squiggle is currently pre-alpha.
# Bug reports # Bug reports
Anyone (with a github account) can file an issue at any time. Please allow Quinn, Sam, and Ozzie to triage, but otherwise just follow the suggestions in the issue templates. Anyone (with a github account) can file an issue at any time. Please allow Quinn, Sam, and Ozzie to triage, but otherwise just follow the suggestions in the issue templates.
# Project structure # Project structure
Squiggle is a **monorepo** with four **packages**. Squiggle is a **monorepo** with three **packages**.
- **components** is where we improve reactive interfacing with Squiggle - **components** is where we improve reactive interfacing with Squiggle
- **playground** is the site `playground.squiggle-language.com`
- **squiggle-lang** is where the magic happens: probability distributions, the interpreter, etc. - **squiggle-lang** is where the magic happens: probability distributions, the interpreter, etc.
- **website** is the site `squiggle-language.com` - **website** is the site `squiggle-language.com`
@ -41,13 +40,17 @@ We aspire for `ci.yaml` and `README.md`s to be in one-to-one correspondence.
## If you're on NixOS ## If you're on NixOS
You'll need to run a command like this in order to get `yarn build` to run, especially in `packages/squiggle-lang`. You can't run `yarn` outside of a FHS shell. Additionally, you need to `patchelf` some things. A script does everything for you.
```sh ```sh
patchelf --set-interpreter $(patchelf --print-interpreter $(which mkdir)) ./node_modules/gentype/gentype.exe ./nixos.sh
``` ```
See [here](https://github.com/NixOS/nixpkgs/issues/107375) Reasons for this are comments in the script. Then, you should be able to do all the package-level `yarn run` commands/scripts.
# Try not to push directly to develop
If you absolutely must, please prefix your commit message with `hotfix: `.
# Pull request protocol # Pull request protocol

View File

@ -0,0 +1,56 @@
---
title: Grammar
author:
- Quinn Dougherty
---
Formal grammar specification, reference material for parser implementation.
_In all likelihood the reference will have to be debugged as we see what tests pass and don't pass during implementation_.
## Lexical descriptions of constants and identifiers
```
<number> ::= [-]? [0-9]+ (.[0-9]+)? | [-]? [0-9]+ (.[0-9]+)? [e] [-]? [0-9]+
<symbol> ::= [a-zA-Z]+ [a-zA-Z0-9]?
<bool> ::= true | false
```
## Expressions
The following gives no typing information. You can obey the grammar and still write nonsensical code.
Think of javascript's list unpacking notation to read our variable-argument function `mixture`.
```
<expr> ::= <term> + <expr> | <term> - <expr> | <expr> .+ <expr> | <expr> .- <expr> | <term>
<term> ::= <power> * <term> | <power> / <term> | <power> .* <term> | <power ./ <term> | <power>
<power> ::= <factor> ^ <power> | <factor> .^ <power> | <factor>
<factor> ::= <number> | <bool> | <symbol> | ( <expr> ) | <array> | <record> | <record>.<symbol> | <symbol> => <expr> | <symbol>(<symbol>) | <symbol>(<symbol>, <symbol>) | ...
```
## Data structures
```
<array> ::= [] | [<expr>] | [<expr>, <expr>] | ...
<record> ::= {} | {<symbol>: <expr>} | {<symbol>: <expr>, <symbol>: <expr>} | ...
```
## Statements
```
<statement> ::= <assign> | <assignFunction>
<assign> ::= <symbol> = <expr>
<assignFunction> ::= <symbol>(<symbol>) = <expr> | <symbol>(<symbol>, <symbol>) = <expr> | ...
```
## A squiggle file
To be valid and raise no errors as of current (apr22) interpreter,
```
<delim> ::= ; | \n
<code> ::= <expr> | <statement> <delim> <expr> | <statement> <delim> <statement> <delim> <expr> | ...
```
This isn't strictly speaking true; the interpreter allows expressions outside of the final line.