From 497e249ab87828dc30090a1a7bc668402fe3cae7 Mon Sep 17 00:00:00 2001 From: William Bell Date: Thu, 22 Sep 2022 17:34:01 +0100 Subject: [PATCH] init --- .DS_Store | Bin 0 -> 6148 bytes .gitignore | 1 + Cargo.lock | 7 +++++ Cargo.toml | 8 ++++++ spec | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 3 +++ 6 files changed, 93 insertions(+) create mode 100644 .DS_Store create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 spec create mode 100644 src/main.rs diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..220c1c2cdfc67b69cd7b97f6d1a94f5743e0a976 GIT binary patch literal 6148 zcmeHKF=_)r43uIQhBPiy?iccd#W*kU2SRK}bNIj}sjter@-)v#Dq;>-CXE?^cJ{Oy zEjPvKWM;nkI=q^#&1?lH+7Fkx@ti)hr-~4rHTJ{DI1bp_VwQX(K<>iMcC!89{Ffi0 z@7?J*jK@zTv8qf8NC7Dz1*Cu!xLbj0sjKI^E2)4KkOGgU0KX3nPV9wKVthKV#0UUf zA{>T&%o4!H0I(NMiHN{FslcRqjToME#9QU{!YMK7=5aIX)XiQKipTAUw@5ediCU$A z6u4HPhV(W2{~P?q{C`c-lN68w52b)Fx4Z2IuT;Ht_HyjC4gL;i&M%yXeNeDOI|fEO h#sk~&OC)7p;~wX|a7qk1;z0-MXMnoMq`-eGZ~@d}7g7KK literal 0 HcmV?d00001 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..a9e2011 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "argon" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..fb194ed --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "argon" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/spec b/spec new file mode 100644 index 0000000..317b38d --- /dev/null +++ b/spec @@ -0,0 +1,74 @@ +ARGON 3 beta 1.0 +------------------------------------------------------------------------------------------------------------ + +This is the specification on how to create an Argon interpreter. +This specification should be used as a guildline, and is subject to change for later versions. +Later updates for Argon 3 should be backwards compatable (where possible) with code designed for older versions +of the interpreter. +The Argon 3 interpreter is not intentionally designed to understand code written for Argon 1 and/or 2, but may +follow some design patterns found in those interpreters. + +Argon 3 is a programming language primarily designed for maths computation, it is designed to use techniques and +rules set in maths. It's designed to be easy for mathematicians to write and understand algorithms in. +(e.g. f(x) = x^2 to set a function) + + +reused variables, and infomation for use in understanding the pseudo REGEX: +NAME = [a-zA-Z][a-zA-Z0-9]* +spaces used in the pseudo REGEX should be taken as 1 or many spaces. + +------------------------------------------------------------------------------------------------------------ + 1 set variable +------------------------------------------------------------------------------------------------------------ +(var/const or nothing) {NAME} = {ANY} + +var and const variables will set variables. if a const is already set in that stack, it will throw an error. +at the end of a opperation (e.g. if, while, or function) drop the variable stack. + +having no verb at the start suggests the program would like to edit a variables from a different stack. +if there is no variable found in the other stacks, then it sets one in the current stack as a var. + +setting variables returns the value, which can be used. + +example: + if (x = 10) > 5 [ + log(x, 'is bigger than 5') + ] + + +------------------------------------------------------------------------------------------------------------ + 2 functions +------------------------------------------------------------------------------------------------------------ +(var/const or nothing) {NAME}({PARAMS}) = {CODE} + +the starting verb follows the rules set by (REF 1). + +function can be called by using its name followed by brackets with the params. + +example: + const f(x) = x^2 + 2*x + 1 + + log('f(10) =', f(10)) +output: + f(10) = 121 + +if the function does not return, then the value given is unknown/null + + +------------------------------------------------------------------------------------------------------------ + 3 wrap +------------------------------------------------------------------------------------------------------------ +[{CODE}] + +a wrap is used to wrap code in square brackets. its used to create a memory stack, so variables set from +inside the wraps stack are deleted once the wrap is finished. + +example: + var name = unknown + [ + name = input('name: ') + var age = input('age: ') + log('you are', age, 'years old!') + ] + log('hello', name) + log('we do not know your age anymore because it got deleted when the wrap finished.') diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}