Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions sudolang.sudo.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,31 @@ h = f |> g;
h(20); // 42
```

### Context operator `~>`

The context operator `~>` allows you to use the left-hand context to transform the input on the right. It's similar to `with` statements or binding contexts from functional programming languages. e.g.:

```SudoLang
PainPoint {
name
description
impact: 1..10 // how much this hurts when it happens
frequency: 1..10 // how often this happens
}

UserStory {
name
description
painPoint
// The following is equivalent to:
// priority = painPoint.impact * painPoint.frequency
priority = painPoint ~> impact * frequency
functionalRequirements
mockups
phases
}
```

### range (inclusive)

The range operator `..` can be used to create a range of numbers. e.g.:
Expand Down
2 changes: 1 addition & 1 deletion syntaxes/sudolang.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"patterns": [
{
"name": "keyword.operator.sudolang",
"match": "\\+|-|\\*|/|%|\\^|&&|\\|\\||!|<|>|<=|>=|==|!=|\\|>|=|\\+=|-=|\\*=|/=|\\bcap\\b|\\bcup\\b|\\bxor\\b"
"match": "\\+|-|\\*|/|%|\\^|&&|\\|\\||!|<|>|<=|>=|==|!=|~>|\\|>|=|\\+=|-=|\\*=|/=|\\bcap\\b|\\bcup\\b|\\bxor\\b"
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions syntaxes/syntax-test.sudo
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ access = if (age >= 18 && isMember) "granted" else "denied"
// Pipe operator for function composition
processedData = rawData |> normalize |> filter |> sort

// Context operator for accessing properties with implicit context
painPoint = { impact: 8, frequency: 5 }
priority = painPoint ~> impact * frequency // equivalent to painPoint.impact * painPoint.frequency


## Disallowed Keywords

Expand Down