Skip to content

Commit

Permalink
Merge pull request #823 from lmorg/develop
Browse files Browse the repository at this point in the history
v6.2
  • Loading branch information
lmorg authored Jul 19, 2024
2 parents b689411 + faa22c5 commit a18cb26
Show file tree
Hide file tree
Showing 169 changed files with 2,748 additions and 1,123 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ wasm_exec.js
/builtins/imports_build

# test working directories
/deleteme
/test/tmp
*.test
*.prof
Expand Down
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ There is a more detailed breakdown of known compatibility issues in the
> This is the recommended way to install Murex because you can then stay
> updated with future releases.
[![Packaging status](https://repology.org/badge/vertical-allrepos/murex.svg)](https://repology.org/project/murex/versions)
[![Packaging status](https://repology.org/badge/vertical-allrepos/murex.svg?exclude_unsupported=1)](https://repology.org/project/murex/versions)

### ArchLinux

Expand Down
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const Name = "murex"
const (
version = "%d.%d.%d"
Major = 6
Minor = 1
Revision = 8300
Minor = 2
Revision = 3000
)

// Copyright is the copyright owner string
Expand Down
11 changes: 11 additions & 0 deletions behavioural/export_crash.mx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file tests https://github.com/lmorg/murex/issues/824

function export.crashes {
export A_very_long_string_that_shouldnt_exist_lkjsafasdjoirfjoiwedjowqdiuqehdiwefj
}

test unit function export.crashes %{
StderrRegex: " variable '.*?' does not exist"
DataType: str
ExitNum: 1
}
1 change: 0 additions & 1 deletion builtins/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
// CLI functions:
_ "github.com/lmorg/murex/builtins/core/arraytools" // tools for working with arrays and maps
_ "github.com/lmorg/murex/builtins/core/autocomplete" // autocompleter cli tools
_ "github.com/lmorg/murex/builtins/core/cache" // management of Murex's cache
_ "github.com/lmorg/murex/builtins/core/config" // config cli tools
_ "github.com/lmorg/murex/builtins/core/datatools" // utilities for manipulating structured data
_ "github.com/lmorg/murex/builtins/core/element" // element function: [[ /element ]]
Expand Down
113 changes: 0 additions & 113 deletions builtins/core/cache/cache.go

This file was deleted.

26 changes: 0 additions & 26 deletions builtins/core/cache/cache_doc.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions builtins/core/cache/godoc.go

This file was deleted.

10 changes: 7 additions & 3 deletions builtins/core/datatools/alter_doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
Description: |-
`alter` a value within a structured data-type.
The path separater is defined by the first character in the path. For example
The path separator is defined by the first character in the path. For example
`/path/to/key`, `,path,to,key`, `|path|to|key` and `#path#to#key` are all valid
however you should remember to quote or escape any special characters (tokens)
used by the shell (such as pipe, `|`, and hash, `#`).
The *value* must always be supplied as JSON however
The **value** must always be supplied as JSON.
> When working with expressions, you may find the **Assign or Merge** operator
> more ergonomic ({{link "read more" "assign-or-merge"}})
Usage: |-
```
<stdin> -> alter [ -m | --merge | -s | --sum ] /path value -> <stdout>
Expand Down Expand Up @@ -148,4 +151,5 @@
- prepend
- runtime
- cast
- config
- config
- assign-or-merge
66 changes: 55 additions & 11 deletions builtins/core/expressions/expressions_doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,24 @@
Expressions: mathematical, string comparisons, logical operators
Description: |-
`expr` is the underlying builtin which handles all expression parsing and
evaluation in Murex. Though typically that would happen transparently without
you having to explicit call `expr`.
evaluation in Murex.
Idiomatic Murex would be to write expressions without explicitly calling the
underlying builtin:
```
# idiomatic expressions
1 + 2
# non-idiotmatic expressions
expr 1 + 2
```
Though you can invoke them via `expr` if needed, please bare in mind that
expressions have special parsing rules to make them more ergonomic. So if you
write an expression as a command (ie prefixed with `expr`) then it will be
parsed as a statement. This means more complex expressions might parse in
unexpected ways and thus fail. You can still raise a bug if that does happens.
For a full list of operators supported exclusively in expression, see the
last section in this document.
Expand All @@ -20,36 +36,40 @@
expr expression -> <stdout>
```
Examples: |-
**Expressions:**
### Basic Expressions
```
» 3 * (3 + 1)
12
```
**Statements with inlined expressions:**
### Statements with inlined expressions
Any parameter surrounded by parenthesis is first evaluated as an expression,
then as a string.
Any parameter surrounded by parenthesis is first evaluated as an {{link "expression" "expr-inlined"}},
then as a {{link "string" "brace-quote-func"}}".
```
» out (3 * 2)
6
```
**Expressions with inlined statements:**
### Functions
Functions can be inlined as a statement using `function(parameters...)` syntax.
Expressions also support running commands as {{link "C-style functions" "c-style-fun"}}, for example:
```
» 5 * out(5)
25
» datetime(--in {now} --out {unix}) / 60
28339115.783333335
» $file_contents = open(example_file.txt)
```
Please note that currently the only functions supported are ones who's names
are comprised entirely of alpha, numeric, underscore and/or exclamation marks.
{{ include "gen/includes/c-style-valid-fun.inc.md" }}
**JSON array:**
### Arrays
```
» %[apples oranges grapes]
Expand All @@ -59,6 +79,25 @@
"grapes"
]
```
({{link "read more" "create-array"}})
### Objects
Sometimes known as dictionaries or maps:
```
» %{ Age: { Tom: 20, Dick: 30, Sally: 40 } }
{
"Age": {
"Dick": 30,
"Sally": 40,
"Tom": 20
}
}
```
({{link "read more" "create-object"}})
Detail: |-
### Order of Operations
Expand Down Expand Up @@ -87,3 +126,8 @@
- null-coalescing
- create-array
- create-object
- open
- out
- strict-types
- expr-inlined
- assign-or-merge
12 changes: 12 additions & 0 deletions builtins/core/expressions/expressions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,15 @@ func TestExpressionsBuiltinStrings(t *testing.T) {

test.RunMurexTests(tests, t)
}

// https://github.com/lmorg/murex/issues/827
func TestExpressionsMultipleParams(t *testing.T) {
tests := []test.MurexTest{
{
Block: `expr 1 + 2`,
Stdout: `3`,
},
}

test.RunMurexTests(tests, t)
}
Loading

0 comments on commit a18cb26

Please sign in to comment.