Interpreted Embedded Domain Specific a Weakly Typed an Extensible at runtime Modular Scripting Programming Language -- #SobaScript.
Licensed under the MIT License
Copyright (c) 2014-2019 Denis Kuzmin < x-3F@outlook.com > GitHub/3F
[ ☕ Donate ]
SobaScript contributors: https://github.com/3F/SobaScript/graphs/contributors
#["
#SobaScript in action
"]
#[var v = 1.2.3]
#[$(log = "$(TMP)/v.txt")]
#[($(Configuration) ~= Deb || true)
{
#[var tBase = $([System.DateTime]::Parse('2019/08/01').ToBinary())]
#[var tNow = $([System.DateTime]::UtcNow.Ticks)]
#[var revBuild = #[$(
[System.TimeSpan]::FromTicks('$(
[MSBuild]::Subtract(
$(tNow),
$(tBase))
)')
.TotalMinutes
.ToString('0')
)]]
#[var v = $(v).$([MSBuild]::Modulo($(revBuild), $([System.Math]::Pow(2, 14))))]
}]
#[var v = $([System.String]::Format("v{0}\r\n\t", $(v)))]
#[try
{
#[File write("#[var log]"):> Example #[var v] Generated by a vsSBE]
#[IO scall("notepad", "#[var log]")]
}
catch(err, msg)
{
$(err) - Type of Exception
$(msg) - Error Message
}]
Can be closely integrated with E-MSBuild:
#[$(
[System.Math]::Exp('$(
[MSBuild]::Multiply(
$([System.Math]::Log(10)),
4
))'
)
)]
Or even be loyal to your any preferences on the fly 🔧.
evaluation region (container) | escaping |
---|---|
#[ … ] |
##[ … ] |
Although SobaScript is a weakly typed, internally it operates with the following types by default* (means you can still extend something through new component):
type | description |
---|---|
integer | Signed 32-bit integer |
string | Both types: From "double quotes" & From 'single quotes'. |
char | |
float | Signed floating-point number with single-precision. The f postfix for clarify: 1.25f, -1.25f |
double | Signed floating-point number with double-precision. The optional d postfix for clarify: 1.25d or simply 1.25, -1.25 |
enum | |
const | |
object | |
bool | |
mixed | Unspecified mixed data |
expression | An composite definition like a conditional expression ~ `(((1 < 2) && true) |
The object type is a type for work with complex mixed data.
Value can be from all available scalar types + complex, like this:
{}
{"str", true}
{"str", {1, 'y', {-12.457f}}, true}
...
Allowed forms:
true | false |
---|---|
1 | 0 |
True | False |
TRUE | FALSE |
true | false |
This is unspecified or mixed type of data. To consider data 'as is'. As for string arguments may contain other inner containers that will be evaluated before.
It's safe only for pair symbols of container. For unpaired you need either place your data inside string argument or use special marker <#data> … </#data>
IPM pm = new PM(raw)
Where raw it's your raw data 'as is'. After, you can work with parsed data via pm instance.
For example, how about this:
#[Func hash.SHA1("test")]
here's complete minimal logic:
IPM pm = new PM(data); // pointed to - ILevel lvlHash
// hash.SHA1("data")
if(pm.FinalEmptyIs(LevelType.Method, "SHA1"))
{
lvlHash.Is("hash.SHA1(string data)", ArgumentType.StringDouble);
return ((string)lvlHash.Args[0].data).SHA1Hash();
}
That's all. Now you can calculate hash value from user scripts with allowed syntax above.
It can be a more flexible, just use other available way: SNode.IPM
SobaScript - https://github.com/3F/SobaScript
Uses the following third-party projects:
#SobaScript 『 蕎麦, enjoy your meal 』
`, aka SBE-Scripts aka vssbe scripts