This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn slice_of_slice<'pool, 'slice, 'ret>( | |
pool: &'pool [usize], | |
slice: &'slice [usize], | |
) -> &'ret [usize] | |
where | |
'pool: 'slice, // `pool` outlives `slice` | |
'slice: 'ret, // `slice` outlives the return value | |
{ | |
// Most of this is bullshit so that both `slice` and `pool` are used. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- # Welcome to Affix Grammar! | |
-- Affix Grammar is a tool which lets you write grammars, and randomly generates sentences based on those grammars. | |
-- You can use it to: | |
-- - generate stories (kinda like Mad Libs), | |
-- - test out context-free grammars, | |
-- - test your knowledge of the grammar of a human language you're learning! | |
-- Here's a simple grammar which generates "hello world" sentences from different languages. | |
-- | |
-- Click the `Generate` button a few times to see the sentences that are produced! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- # Affix Grammar Tutorial: Lesson 1 | |
-- Hi! Welcome to Affix Grammar! | |
-- ### What is it? | |
-- Affix Grammar lets you generate sentences, stories, textual patterns and more! It's kinda like Mad Libs. | |
-- Lets generate a simple sentence that has a few variations. An example of the kind of sentence we'll generate is: | |
-- > "Last Wednesday, Val went for a walk in the park after supper." | |
-- | |
-- First, we'll define a "rule" called `start`. This will be the entry point to our grammar. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- # Affix Grammar Tutorial: Lesson 2 | |
-- ### Joining Words Together | |
-- Check out this grammar 👇 | |
rule start = "These" "are" "a" "few" things + "!" | |
rule things = "words" | "sentence elements" | "lexemes" | |
-- When two sentence elements (like `"quoted text"` or `rule_names`) are placed next to each other, they are implicitly joined together and separated by a space (" "). So writing: | |
-- > `"Stop" "thief!"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- # Beginner Tutorial: Lesson 3 | |
-- ### Data Variants | |
-- A rule can be parameterized by what's called a "data variant." Let's define one to illustrate. | |
data Gender = nonbinary | feminine | neutral | |
-- An instance of `Gender` can be one of the three possibilities listed. | |
-- | |
-- *Aside: this isn't an exhaustive list of genders (that would probably be infinite), just some of the most common in English. See the exercise at the end!* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// A module for parsing whitespace. Takes into account comments too. | |
/// | |
/// # Module Outline | |
/// - mod space | |
/// - fn comment | |
/// - mod allowed | |
/// - fn here | |
/// - fn after | |
/// - fn before | |
/// - fn around |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- # Beginners Tutorial: Lesson 4 | |
-- ### Data Variant Aliases | |
-- In this lesson you'll learn how to display data variants in user-friendly ways. | |
-- Say you wanted to write a story about a character. | |
data Character = val | sam | penny | |
rule story = name.Character "went to the store." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- # Generating Center Embeddings | |
-- [This wikipedia article](https://en.wikipedia.org/wiki/Center_embedding) is about a kind of sentence that is REALLY hard to understand. Click the "Generate" button in the top right to generate sentences! | |
rule start = center_embedding | |
rule center_embedding = subject verb_phrase + "." | |
rule verb_phrase | |
= "slept" | |
| "killed" subject |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 Ways to Leave Your Lover | |
Paul Simon | |
-----------------------------------CHORDS--------------------------------------- | |
Cmaj7 = x35453 (close to barred C) | |
B7 = x24242 (barred) | |
D#dim = 23424x (kinda like barred B7, but add middle finger) | |
D/F# = 200232 (wrap thumb around onto lowest string @ fret #2) | |
G = 355433 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--OPTION 1 (CURRENT SYNTAX)---- | |
rule whatever1 = "something" | |
rule whatever2.Thing = | |
.thing1 -> "something 1" | |
.thing2 -> "something 2" | |
rule whatever3.Thing.Thing = | |
.thing1 { | |
.thing1 -> "something 1" |
OlderNewer