From aeaef2b1821fa084a69ba95d974970660dd75272 Mon Sep 17 00:00:00 2001 From: iiPython Date: Fri, 7 Apr 2023 14:52:51 -0500 Subject: [PATCH 1/4] [core] x3.0.0 --- xpp/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xpp/__init__.py b/xpp/__init__.py index a982897..19aeb08 100644 --- a/xpp/__init__.py +++ b/xpp/__init__.py @@ -1,6 +1,6 @@ # Copyright 2022-2023 iiPython -__version__ = "3.0b2" +__version__ = "3.0.0" from .extra.config import config # noqa from .core.sections import load_sections # noqa From 404fa8e6aaa3240a3499d5ae07686c19f5038e9d Mon Sep 17 00:00:00 2001 From: iiPython Date: Fri, 7 Apr 2023 15:08:01 -0500 Subject: [PATCH 2/4] [cli] Add xpp -s --- xpp/__main__.py | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/xpp/__main__.py b/xpp/__main__.py index 9b517cf..1d70bc2 100644 --- a/xpp/__main__.py +++ b/xpp/__main__.py @@ -3,6 +3,7 @@ # Modules import os import sys +import json from . import ( __version__, load_sections, config, Interpreter @@ -19,8 +20,10 @@ def __init__(self) -> None: {"args": ["-h", "--help"], "fn": self.show_help, "desc": "Displays the help menu"}, {"args": ["-hl", "--helplong"], "fn": self.show_help_long, "desc": "Displays a more detailed help menu"}, {"args": ["-v", "--ver", "--version"], "fn": self.show_version, "desc": "Prints the x++ version"}, - {"args": ["-i", "--installation"], "fn": self.show_install_path, "desc": "Prints the installation path"} + {"args": ["-i", "--installation"], "fn": self.show_install_path, "desc": "Prints the installation path"}, + {"args": ["-s", "--show"], "fn": self.show_module, "desc": "Provides information about an installed x++ module"} ] + self.install_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../")) self.usage = f"""x++ (x{__version__}) Interpreter (c) 2021-23 iiPython; (c) 2022-23 Dm123321_31mD "DmmD" Gaming @@ -35,16 +38,16 @@ def __init__(self) -> None: for flag in self.flags: self.vals[flag["name"]] = any([a in self.argv for a in flag["args"]]) - # Handle options - for opt in self.options: - if any([a in self.argv for a in opt["args"]]): - opt["fn"]() - # Load filepath self.filepath = None if self.argv: self.filepath = ([a for a in self.argv if a[0] != "-"] or [None])[-1] + # Handle options + for opt in self.options: + if any([a in self.argv for a in opt["args"]]): + opt["fn"]() + def show_help(self) -> None: return sys.exit(self.usage) @@ -64,7 +67,30 @@ def show_version(self) -> None: return sys.exit(__version__) def show_install_path(self) -> None: - return sys.exit(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))) + return sys.exit(self.install_path) + + def show_module(self) -> None: + module_path = os.path.join(self.install_path, "pkgs", self.filepath.replace(".", os.sep)) + if not os.path.isdir(module_path): + return exit("no such module: " + self.filepath) + + # Load .xconfig + xconfig = os.path.join(module_path, ".xconfig") + if not os.path.isfile(xconfig) and "." in self.filepath: + xconfig = os.path.join(self.install_path, "pkgs", self.filepath.split(".")[-1], ".xconfig") + + metadata = {} + if os.path.isfile(xconfig): + with open(xconfig, "r") as fh: + metadata = json.loads(fh.read()) + + # Print out information + exit(f"""Name: {self.filepath} +Version: {metadata.get('version', 'N/A')} +Summary: {metadata.get('summary', 'N/A')} +Author: {metadata.get('author', 'N/A')} +License: {metadata.get('license', 'N/A')} +Location: {module_path}""") # Initialization cli = CLI() From 8ae44f83e269133889bda7c85755c47a1e32160d Mon Sep 17 00:00:00 2001 From: iiPython Date: Sun, 9 Apr 2023 23:02:36 -0500 Subject: [PATCH 3/4] [docs] Finally update everything in documents/ --- md/documents/comments.md | 4 +- md/documents/comparators.md | 52 +++++----------- md/documents/configurations.md | 45 +++----------- md/documents/dataTypes.md | 107 ++++++++++++++++++--------------- md/documents/packages.md | 4 +- md/documents/sections.md | 37 ++---------- md/documents/variables.md | 35 +++-------- 7 files changed, 99 insertions(+), 185 deletions(-) diff --git a/md/documents/comments.md b/md/documents/comments.md index de157e8..dc3f158 100644 --- a/md/documents/comments.md +++ b/md/documents/comments.md @@ -30,11 +30,11 @@ A comment always starts with two colons `::` and can be placed at the end of any ```xt :: This is a comment -out 5 :: This is a comment +prt 5 :: This is an inline comment ``` --- -Last Updated: February 6th, 2022 by Dm123321_31mD +Last Updated: April 9th, 2023 by iiPython [↑ Go To Top](#x--documents--comments) \ No newline at end of file diff --git a/md/documents/comparators.md b/md/documents/comparators.md index 2e55e5b..144373e 100644 --- a/md/documents/comparators.md +++ b/md/documents/comparators.md @@ -75,16 +75,16 @@ Or: "hello" in "hello world" ``` -An expression cannot be used on its own, as it is not considered as an operator and thus not a valid statement. It is always accompanied by operators that take an expression as an argument. A classic example of this is the `cmp` operator: +An expression cannot be used on its own, as it is not considered as an operator and thus not a valid statement. It is always accompanied by operators that take an expression as an argument. A classic example of this is the `if` operator: ```xt -cmp 5 == 5 "out \"true\"" +if (5 == 5) "prt 'true'" ``` -Any operator that uses an expression creates a branch, with `true` being the first branch and `false` is the second. For example, the `cmp` operator creates a branch based on whether or not the expression is true: +Any operator that uses an expression creates a branch, with `true` being the first branch and the second acts as an `else`. For example, the `if` operator creates a branch based on whether or not the expression is true: ```xt -cmp 5 == 10 "out \"same\"" "out \"different\"" +if (5 == 10) "prt 'same'" "prt 'different'" ``` ## Documentation @@ -105,7 +105,7 @@ Checks if the two variables or values are equal to each other. Example: ```xt -cmp 5 == 5 "out \"true\"" +if (5 == 5) "prt 'true'" ``` --- @@ -126,7 +126,7 @@ Checks if the two variables or values are different from each other. Example: ```xt -cmp 5 != 10 "out \"true\"" +if (5 != 10) "prt 'true'" ``` --- @@ -147,7 +147,7 @@ Checks if the source is less than the target. Example: ```xt -cmp 5 < 10 "out \"true\"" +if (5 < 10) "prt 'true'" ``` --- @@ -168,7 +168,7 @@ Checks if the source is less than or equal to the target. Example: ```xt -cmp 5 <= 10 "out \"true\"" +if (5 <= 10) "prt 'true'" ``` --- @@ -189,7 +189,7 @@ Checks if the source is greater than the target. Example: ```xt -cmp 10 > 5 "out \"true\"" +if (10 > 5) "prt 'true'" ``` --- @@ -210,7 +210,7 @@ Checks if the source is greater than or equal to the target. Example: ```xt -cmp 10 >= 5 "out \"true\"" +if (10 >= 5) "prt 'true'" ``` --- @@ -231,7 +231,7 @@ Checks if the source is in the target. Example: ```xt -cmp "ello" in "Hello, world!" "out \"true\"" +if ("ello" in "Hello, world!") "prt 'true'" ``` --- @@ -239,7 +239,7 @@ cmp "ello" in "Hello, world!" "out \"true\"" ### Not In ```xt - xin + not in ``` Checks if the source is not in the target. @@ -252,7 +252,7 @@ Checks if the source is not in the target. Example: ```xt -cmp "bye" xin "Hello, world!" "out \"true\"" +if ("bye" not in "Hello, world!") "prt 'true'" ``` --- @@ -273,33 +273,11 @@ Checks if the source is a type of the target. Example: ```xt -cmp 5 is "int" "out \"true\"" +if (5 is "int") "prt 'true'" ``` --- -### From - -```xt - from -``` - -Checks if the source is an instance of the target. - -| Parameter | Type | Description | -| :-: | :-: | :-: | -| Source | Any | The variable or value that is being compared against | -| Target | Any | The variable or value being compared to | - -Example: - -```xt -evl "setvar('int', int)" -cmp 5 from int "out \"true\"" -``` - ---- - -Last Updated: February 6th, 2022 by Dm123321_31mD +Last Updated: April 9th, 2023 by iiPython [↑ Go To Top](#x--documents--comparators) \ No newline at end of file diff --git a/md/documents/configurations.md b/md/documents/configurations.md index b22da5a..1018c88 100644 --- a/md/documents/configurations.md +++ b/md/documents/configurations.md @@ -29,34 +29,19 @@ - [Main](#main) -### Q - -- [Quiet](#quiet) - ## About The configuration file defines what the project would do on execution. It is always placed in the `.xtconfig` file and should be written as if it is within a `*.json` file. If one is not found in the project, the default configuration is used internally instead: -```xtconfig +```xconfig { - "main": "main.xt", - "quiet": false + "main": "main.xpp" } ``` -If an essential field is missing, it is replaced with a default value internally instead: - -```xtconfig -{ - "main": "main.xt" -} -``` - -> Because the `quiet` field is missing, its default value, `false`, is used instead. - The configuration file can also contain non-essential information, such as the author, version, or description of your project: -```xtconfig +```xconfig { "author": "my-name", "contributors": [ @@ -69,11 +54,13 @@ The configuration file can also contain non-essential information, such as the a } ``` +> This is part of the official .xconfig specification. In fact, `xpp --show ` will use this spec. + ## Documentation ### Main -```xtconfig +```xconfig { "main": } @@ -83,26 +70,10 @@ Defines the path of the main entry file. | Parameter | Type | Default | Description | | :-: | :-: | :-: | :-: | -| Path | String\ | "main.xt" | Main entry file path relative to the current working directory | - ---- - -### Quiet - -```xtconfig -{ - "quiet":