new stuff, vscode support, globals fixed, better test script
This commit is contained in:
parent
1bbaa98add
commit
ab44742443
|
|
@ -1,4 +1,6 @@
|
|||
Debug/
|
||||
x86/
|
||||
x64/
|
||||
Release/
|
||||
Build/
|
||||
bin/
|
||||
|
|
@ -9,9 +11,10 @@ log/
|
|||
lib/
|
||||
.vs/
|
||||
*.nocmt.*
|
||||
*.sqi
|
||||
*.tmp
|
||||
*.log
|
||||
*.depend
|
||||
*.stackdump
|
||||
*.layout
|
||||
*.user
|
||||
x86/
|
||||
x64/
|
||||
|
|
|
|||
|
|
@ -121,6 +121,9 @@ public class Runner : IDisposable
|
|||
Globals["cos"] = Obj.Create(new NativeFunction("cos",
|
||||
v => new Value(Math.Cos(v[0].GetDecimal())), "v"));
|
||||
|
||||
Globals["sqrt"] = Obj.Create(new NativeFunction("sqrt",
|
||||
v => new Value(Math.Sqrt(v[0].GetDecimal())), "v"));
|
||||
|
||||
Globals["exit"] = Obj.Create(new NativeFunction("exit", v => {
|
||||
Environment.Exit((int)(v.FirstOrDefault().Signed));
|
||||
return Value.Void;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Version>0.0.12.632</Version>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
|
|
|
|||
|
|
@ -103,9 +103,12 @@ public readonly struct Value :
|
|||
public bool IsFalsy => IsBool ? Bool == false : Unsigned == 0;
|
||||
|
||||
// another shortcut that will cost me greatly
|
||||
public String? AsString() => Ptr.As<String>();
|
||||
public string? GetString() => AsString()?.Value;
|
||||
// edit: yes, did cost me greatly, lol. pointer was pointing to random strings in string table
|
||||
// ending up with dozens of strings spat out using write(), accidentally, by giving write
|
||||
// an integer (table index offset) rather than a string literal. oops.
|
||||
public String? AsString() => IsString ? Ptr.As<String>() : null;
|
||||
public double GetDecimal() => IsDecimal ? Decimal : (double)Signed;
|
||||
public string? GetString() => AsString()?.Value;
|
||||
|
||||
public bool Is(T type, bool exact = true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) [2026] [David Neumaier, Qrakhen]
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"comments": {
|
||||
"lineComment": "#"
|
||||
},
|
||||
"brackets": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"]
|
||||
],
|
||||
"autoClosingPairs": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"],
|
||||
["\"", "\""],
|
||||
["'", "'"]
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "qamp",
|
||||
"displayName": "Q& Language Support by Qrakhen",
|
||||
"repository": "https://git.qrakhen.net/qrakhen/qamp-vscode.git",
|
||||
"publisher": "qrakhen",
|
||||
"version": "0.0.1",
|
||||
"engines": {
|
||||
"vscode": "^1.0.0"
|
||||
},
|
||||
"categories": [
|
||||
"Programming Languages"
|
||||
],
|
||||
"contributes": {
|
||||
"contributes": {
|
||||
"snippets": [{
|
||||
"language": "qamp",
|
||||
"path": "./snippets/qamp.code-snippets"
|
||||
}]
|
||||
},
|
||||
"languages": [{
|
||||
"id": "qamp",
|
||||
"aliases": ["Q&", "qamp"],
|
||||
"icon": { "dark": "cogwheel", "light": "cogwheel" },
|
||||
"extensions": [ ".qp", ".sq", ".qamp" ],
|
||||
"configuration": "./language-configuration.json"
|
||||
}],
|
||||
"grammars": [{
|
||||
"language": "qamp",
|
||||
"scopeName": "source.qamp",
|
||||
"path": "./syntaxes/qamp.tmLanguage.json"
|
||||
}]
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"Sine": {
|
||||
"prefix": "sin",
|
||||
"body": "sin(${1:number})",
|
||||
"description": "Calculates the sine of number, assuming radians."
|
||||
},
|
||||
"Cosine": {
|
||||
"prefix": "cos",
|
||||
"body": "cos(${1:number})",
|
||||
"description": "Calculates the cosine of number, assuming radians."
|
||||
},
|
||||
"Read": {
|
||||
"prefix": "read",
|
||||
"body": "read()",
|
||||
"description": "Reads a line from stdin."
|
||||
},
|
||||
"Write": {
|
||||
"prefix": "write",
|
||||
"body": "write(${1:string})",
|
||||
"description": "Writes string to stdout."
|
||||
},
|
||||
"Timestamp": {
|
||||
"prefix": "time",
|
||||
"body": "time()",
|
||||
"description": "Returns current timestamp in microseconds."
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
||||
"name": "qamp",
|
||||
"scopeName": "source.qamp",
|
||||
"patterns": [
|
||||
{ "include": "#comments" },
|
||||
{ "include": "#strings" },
|
||||
{ "include": "#keywords" },
|
||||
{ "include": "#operators" },
|
||||
{ "include": "#numbers" },
|
||||
{ "include": "#functions" },
|
||||
{ "include": "#globals" }
|
||||
],
|
||||
"repository": {
|
||||
"globals": {
|
||||
"patterns": [
|
||||
{
|
||||
"name": "support.function.qamp",
|
||||
"match": "\\b(sin|cos|read|write|fread|fwrite|time|ftime)\\b"
|
||||
},
|
||||
{
|
||||
"name": "support.string.qamp",
|
||||
"match": "\\b(SubString|IndexOf|Split|Length)\\b"
|
||||
}
|
||||
]
|
||||
},
|
||||
"comments": {
|
||||
"patterns": [
|
||||
{
|
||||
"name": "comment.line.double-slash.qamp",
|
||||
"match": "#.*$"
|
||||
}
|
||||
]
|
||||
},
|
||||
"strings": {
|
||||
"patterns": [
|
||||
{
|
||||
"name": "string.quoted.double.qamp",
|
||||
"begin": "\"",
|
||||
"end": "\"",
|
||||
"patterns": [{ "name": "constant.character.escape.qamp", "match": "\\\\." }]
|
||||
},
|
||||
{
|
||||
"name": "string.quoted.single.qamp",
|
||||
"begin": "'",
|
||||
"end": "'"
|
||||
}
|
||||
]
|
||||
},
|
||||
"keywords": {
|
||||
"patterns": [
|
||||
{
|
||||
"name": "keyword.control.qamp",
|
||||
"match": "\\b(if|else|for|while|var|do)\\b"
|
||||
},
|
||||
{
|
||||
"name": "storage.type.function.qamp",
|
||||
"match": "\\b(fq|funq)\\b"
|
||||
},
|
||||
{
|
||||
"name": "keyword.class.qamp",
|
||||
"match": "\\b(qlass|class|this|base)\\b"
|
||||
},
|
||||
{
|
||||
"name": "keyword.control.flow.return.qamp",
|
||||
"match": "<:|\\breturn\\b"
|
||||
},
|
||||
{
|
||||
"name": "support.function.print.qamp",
|
||||
"match": "\\bprint\\b|::"
|
||||
}
|
||||
]
|
||||
},
|
||||
"operators": {
|
||||
"patterns": [
|
||||
{
|
||||
"name": "keyword.operator.assignment.qamp",
|
||||
"match": "<~|=|<\\+|<&"
|
||||
},
|
||||
{
|
||||
"name": "keyword.operator.comparison.qamp",
|
||||
"match": "==|!=|<=|>=|<|>"
|
||||
},
|
||||
{
|
||||
"name": "keyword.operator.arithmetic.qamp",
|
||||
"match": "\\+|\\-|\\*|/"
|
||||
},
|
||||
{
|
||||
"name": "keyword.operator.binary.qamp",
|
||||
"match": "&|\\^|\\||~"
|
||||
}
|
||||
]
|
||||
},
|
||||
"numbers": {
|
||||
"patterns": [
|
||||
{
|
||||
"name": "constant.numeric.hex.qamp",
|
||||
"match": "\\b0x[0-9a-fA-F]+\\b"
|
||||
},
|
||||
{
|
||||
"name": "constant.numeric.decimal.qamp",
|
||||
"match": "\\b[0-9]+\\.[0-9]+\\b|\\.[0-9]+\\b|\\b[0-9]+\\b"
|
||||
}
|
||||
]
|
||||
},
|
||||
"functions": {
|
||||
"patterns": [
|
||||
{
|
||||
"match": "\\b(fq|funq|function)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
|
||||
"captures": {
|
||||
"1": { "name": "storage.type.function.qamp" },
|
||||
"2": { "name": "entity.name.function.qamp" }
|
||||
}
|
||||
},
|
||||
{
|
||||
"match": "([a-zA-Z_][a-zA-Z0-9_]*)\\(",
|
||||
"captures": {
|
||||
"1": { "name": "entity.name.function.qamp" }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
||||
"name": "Q&",
|
||||
"patterns": [
|
||||
{
|
||||
"name": "keyword.control.qamp",
|
||||
"match": "\\b(if|else|while|return|function|fq|funq|do|for|print)\\b"
|
||||
},
|
||||
{
|
||||
"name": "number.literal.qamp",
|
||||
"match": "\\b(\\d+?)\\b"
|
||||
},
|
||||
{
|
||||
"name": "string.quoted.double.qamp",
|
||||
"begin": "\"",
|
||||
"end": "\"",
|
||||
"patterns": [
|
||||
{
|
||||
"name": "constant.character.escape.qamp",
|
||||
"match": "\\\\."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "string.quoted.single.qamp",
|
||||
"begin": "'",
|
||||
"end": "'",
|
||||
"patterns": [
|
||||
{
|
||||
"name": "constant.character.escape.qamp",
|
||||
"match": "\\\\."
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"scopeName": "source.qamp"
|
||||
}
|
||||
|
|
@ -17,12 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Qrakhen.Qamp.Core.Tests", "
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Qrakhen.Qamp.Tests", "Qrakhen.Qamp.Tests\Qrakhen.Qamp.Tests.csproj", "{5440D742-6149-417A-B9C8-4DEF951221E9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Qrakhen.Qamp.Editor", "Qrakhen.Qamp.Editor\Qrakhen.Qamp.Editor.csproj", "{BE50AA8C-7D8F-4DDA-8102-92CFCE74DA96}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Qrakhen.Qamp.Memory", "Qrakhen.Qamp.Memory\Qrakhen.Qamp.Memory.csproj", "{A8876A55-8007-4D20-9637-2099F1B82DAE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Qrakhen.TilingFrames", "Qrakhen.TilingFrames\Qrakhen.TilingFrames.csproj", "{25C7B034-34AA-44A5-A428-37942B567AC2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -87,14 +83,6 @@ Global
|
|||
{5440D742-6149-417A-B9C8-4DEF951221E9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5440D742-6149-417A-B9C8-4DEF951221E9}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{5440D742-6149-417A-B9C8-4DEF951221E9}.Release|x64.Build.0 = Release|Any CPU
|
||||
{BE50AA8C-7D8F-4DDA-8102-92CFCE74DA96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BE50AA8C-7D8F-4DDA-8102-92CFCE74DA96}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BE50AA8C-7D8F-4DDA-8102-92CFCE74DA96}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{BE50AA8C-7D8F-4DDA-8102-92CFCE74DA96}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{BE50AA8C-7D8F-4DDA-8102-92CFCE74DA96}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BE50AA8C-7D8F-4DDA-8102-92CFCE74DA96}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BE50AA8C-7D8F-4DDA-8102-92CFCE74DA96}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{BE50AA8C-7D8F-4DDA-8102-92CFCE74DA96}.Release|x64.Build.0 = Release|Any CPU
|
||||
{A8876A55-8007-4D20-9637-2099F1B82DAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A8876A55-8007-4D20-9637-2099F1B82DAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A8876A55-8007-4D20-9637-2099F1B82DAE}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
|
|
@ -103,14 +91,6 @@ Global
|
|||
{A8876A55-8007-4D20-9637-2099F1B82DAE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A8876A55-8007-4D20-9637-2099F1B82DAE}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{A8876A55-8007-4D20-9637-2099F1B82DAE}.Release|x64.Build.0 = Release|Any CPU
|
||||
{25C7B034-34AA-44A5-A428-37942B567AC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{25C7B034-34AA-44A5-A428-37942B567AC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{25C7B034-34AA-44A5-A428-37942B567AC2}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{25C7B034-34AA-44A5-A428-37942B567AC2}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{25C7B034-34AA-44A5-A428-37942B567AC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{25C7B034-34AA-44A5-A428-37942B567AC2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{25C7B034-34AA-44A5-A428-37942B567AC2}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{25C7B034-34AA-44A5-A428-37942B567AC2}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
print("\nQ& Test script.");
|
||||
|
||||
var now = time();
|
||||
|
||||
*~ how <~ 'very cool';
|
||||
var _WHAT_ = "ABQ&%$#@!";
|
||||
|
||||
|
|
@ -11,15 +13,14 @@ var c <~ 8;
|
|||
:: _WHAT_.SubString(2, 2) + ' is ' + how;
|
||||
print(a * b * c * d);
|
||||
|
||||
if (a > d) {
|
||||
:: "compare operator is sane";
|
||||
} else {
|
||||
:: "sanity check failed";
|
||||
}
|
||||
if (a > d) { :: "compare operator is sane"; }
|
||||
else { :: "sanity check failed"; }
|
||||
|
||||
for (*~i<~1;i<=16;i++) {
|
||||
:: "[" + i + "]: " + i*i;
|
||||
}
|
||||
for (*~i<~1;i<=16;i++) { :: "[" + i + "]: " + i * i; }
|
||||
|
||||
# this part is spooky as fuck, write(b) prints out random variables :x
|
||||
# almost like its taking the slot index of the global register, huh...
|
||||
for (;b>0;) { ::b; b--; write(b); }
|
||||
|
||||
fq fib(n) { if (n<2) <: 1; <: fib(n-1) + fib(n-2); }
|
||||
|
||||
|
|
@ -29,4 +30,19 @@ for (*~i<~0;i<16;i++) {
|
|||
}
|
||||
:: fibs;
|
||||
|
||||
:: "if you can read this, Q& probably works. Wow."
|
||||
class Vector {
|
||||
Vector(x, y, z) {
|
||||
.~:x <~ x;
|
||||
this.y = y;
|
||||
this:z <~ z;
|
||||
}
|
||||
}
|
||||
|
||||
var delta = time() - now;
|
||||
:: "this took " + delta + " microseconds. which are ~" + (delta / 1000) + " milliseconds.";
|
||||
|
||||
var content = fread("./Build/.qpb");
|
||||
::typeof content;
|
||||
write(content);
|
||||
|
||||
:: "if you can read this, Q& probably works. Wow!";
|
||||
|
|
|
|||
Loading…
Reference in New Issue