├── diamond-functions(PY) ├── getting_functions.py ├── imported_modules.py ├── creating_functions.py ├── spill.py ├── python_run.py ├── show_erros.py ├── getting_variables.py ├── creating_variables.py └── compile_codes.py ├── .gitignore ├── diamons-functions(CPP) ├── creating_functions.cpp └── __init__.cpp ├── hiworld.diamond ├── .vscode └── settings.json ├── diamond.bat ├── diamond_execute.py ├── Schemacodes.diamond ├── LICENSE ├── diamond-functions(CS) └── __init__.cs ├── diamond-functions(js) └── __init__.js ├── diamond-functions(ASM) └── __init__.asm ├── diamond.sh ├── rundiamond.py └── README.md /diamond-functions(PY)/getting_functions.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | commit.bat 2 | *.pyc 3 | __pycache__/ -------------------------------------------------------------------------------- /diamons-functions(CPP)/creating_functions.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hiworld.diamond: -------------------------------------------------------------------------------- 1 | 2 | 3 | create_function my_function: 4 | spill "This is my function" 5 | 6 | spill "this was actually not there though" -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.quickSuggestions": { 3 | "other": true, 4 | "comments": true, 5 | "strings": false 6 | }, 7 | 8 | "python.analysis.extraPaths": ["./sources"] 9 | } -------------------------------------------------------------------------------- /diamond.bat: -------------------------------------------------------------------------------- 1 | 2 | @REM This is the batch processing file. 3 | @REM This contains contains various commands used for 4 | @REM repetitive tasks or to run the groups of scripts one after another. 5 | 6 | @echo off 7 | 8 | @REM To execute the main python file for the whole diamond-programing language 9 | 10 | python diamond-execute.py %* -------------------------------------------------------------------------------- /diamond-functions(PY)/imported_modules.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | # from .spill import * 4 | # from .creating_functions import * 5 | # from .creating_variables import * 6 | # from .show_erros import * 7 | # from .compile_codes import * 8 | # from .python_run import python_run 9 | # from .getting_variables import * 10 | # from .getting_functions import * 11 | 12 | # This were all first imported generally, but right now, fixed them into each file makingit more readable and accessible 13 | -------------------------------------------------------------------------------- /diamond_execute.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | from rundiamond import run_main 5 | 6 | filename = sys.argv[1] 7 | 8 | with open(filename, 'r') as f: 9 | data = f.read() 10 | 11 | variables = { 12 | 'test': 'Hello there', 13 | 'true': True, 14 | 'false': False 15 | } 16 | 17 | _functions = {} 18 | python_funcs_and_vars = locals() 19 | 20 | lines = data.split('\n') 21 | for i in range(len(lines)): 22 | run_main(lines[0], variables, 0, lines, _functions, python_funcs_and_vars) -------------------------------------------------------------------------------- /diamond-functions(PY)/creating_functions.py: -------------------------------------------------------------------------------- 1 | 2 | # syntax for creating functions 3 | 4 | 5 | from .show_erros import syntax_error 6 | 7 | from ..rundiamond import modulefunctions 8 | 9 | def create_function(function_name, current_lines): 10 | function_lines = [] 11 | 12 | if not function_name.endswith(':'): 13 | syntax_error() 14 | 15 | function_name = function_name[:len(function_name) - 1] 16 | 17 | for current_line in current_lines: 18 | if current_line.startswith(''): 19 | function_lines.append(current_line.replace('','')) 20 | 21 | modulefunctions[function_name] = function_lines -------------------------------------------------------------------------------- /Schemacodes.diamond: -------------------------------------------------------------------------------- 1 | # use this when fixing a comment in Diamond programming language 2 | 3 | # When you wanna log on the console 4 | spill "Do you love this?" 5 | 6 | # When you wanna create a variable in Diamond 7 | 8 | var_name diamond == "Testing!" 9 | 10 | # When you wanna print your variable name to the console 11 | 12 | spill diamond 13 | 14 | # Creating functions in diamond 15 | create_function my_function: 16 | spill diamond 17 | spill "Do you love this?" 18 | 19 | # Run your functions 20 | my_function 21 | 22 | # This is how you import other Diamond files 23 | 24 | import rateme 25 | 26 | # When you wanna use functions from other files in Diamond 27 | 28 | testing_func 29 | 30 | # You could also use python, Just in case to run the codes also 31 | 32 | python_run "print('Writing this is fun')" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | MIT License 3 | 4 | Copyright (c) 2022 John Oseni 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. -------------------------------------------------------------------------------- /diamond-functions(CS)/__init__.cs: -------------------------------------------------------------------------------- 1 | 2 | // MIT License 3 | 4 | // Copyright (c) 2022 John Oseni 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. -------------------------------------------------------------------------------- /diamond-functions(js)/__init__.js: -------------------------------------------------------------------------------- 1 | 2 | // MIT License 3 | 4 | // Copyright (c) 2022 John Oseni 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. -------------------------------------------------------------------------------- /diamond-functions(ASM)/__init__.asm: -------------------------------------------------------------------------------- 1 | 2 | // MIT License 3 | 4 | // Copyright (c) 2022 John Oseni 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | -------------------------------------------------------------------------------- /diamond-functions(PY)/spill.py: -------------------------------------------------------------------------------- 1 | 2 | # MIT License 3 | 4 | # Copyright (c) 2022 John Oseni 5 | 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | 24 | def spill(text): 25 | print(text) -------------------------------------------------------------------------------- /diamond.sh: -------------------------------------------------------------------------------- 1 | 2 | # MIT License 3 | 4 | # Copyright (c) 2022 John Oseni 5 | 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | 24 | 25 | # To install the media, this will be ran 26 | 27 | python3 diamond_execute.py $1 -------------------------------------------------------------------------------- /diamons-functions(CPP)/__init__.cpp: -------------------------------------------------------------------------------- 1 | 2 | // MIT License 3 | 4 | // Copyright (c) 2022 John Oseni 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | #include 25 | #include "creating_functions.cpp" -------------------------------------------------------------------------------- /diamond-functions(PY)/python_run.py: -------------------------------------------------------------------------------- 1 | 2 | # MIT License 3 | 4 | # Copyright (c) 2022 John Oseni 5 | 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | 24 | from . import getting_variables 25 | 26 | def python_run(string, variables, line, python_funcs_and_vars): 27 | # print("Pythin environment running ..") 28 | string = getting_variables(string, variables, line) 29 | exec(string, python_funcs_and_vars) -------------------------------------------------------------------------------- /diamond-functions(PY)/show_erros.py: -------------------------------------------------------------------------------- 1 | 2 | # MIT License 3 | 4 | # Copyright (c) 2022 John Oseni 5 | 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | 24 | import sys 25 | 26 | def function_not_recognized(function_name): 27 | print(f"'{function_name}'isn't recognized as a function.") 28 | sys.exit() 29 | 30 | def variable_not_found(variable_name): 31 | print(f'{variable_name} not Defined') 32 | sys.exit() 33 | 34 | def syntax_error(): 35 | print('Syntax Error') 36 | sys.exit() 37 | -------------------------------------------------------------------------------- /diamond-functions(PY)/getting_variables.py: -------------------------------------------------------------------------------- 1 | 2 | # MIT License 3 | 4 | # Copyright (c) 2022 John Oseni 5 | 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | 24 | from . import variable_not_found 25 | 26 | def getting_variable(var_name, variables, line): 27 | text = "" 28 | if "'" in var_name or '"' in var_name: 29 | # for t in line: 30 | # text += t + ' ' 31 | text = ' '.join(line) 32 | text = text.replace("'" if text[0] == "'" else '"', '') 33 | elif var_name in variables: 34 | text = variables.get(var_name) 35 | else: 36 | variable_not_found(var_name) 37 | 38 | return text -------------------------------------------------------------------------------- /diamond-functions(PY)/creating_variables.py: -------------------------------------------------------------------------------- 1 | 2 | # MIT License 3 | 4 | # Copyright (c) 2022 John Oseni 5 | 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | 24 | # creating variables in diamond-pl 25 | 26 | from . import variable_not_found 27 | 28 | def create_variable(var_name, var_value, variables): 29 | text = "" 30 | 31 | if "'" in var_value or '"' in var_value: 32 | var_value = var_value.split(' ') 33 | text = ' '.join(var_value) 34 | text = text.replace("'" if text[0] == "'" else '"', '') 35 | elif var_value in variables: 36 | text = variables.get(var_value) 37 | else: 38 | variable_not_found(var_value) 39 | 40 | variables[var_name] = text -------------------------------------------------------------------------------- /rundiamond.py: -------------------------------------------------------------------------------- 1 | 2 | # MIT License 3 | 4 | # Copyright (c) 2022 John Oseni 5 | 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | 24 | import functions as modulefunctions 25 | 26 | def run_function(index, python_funcs_and_vars, lines, line, _functions, variables): 27 | line = line.split(' ') 28 | 29 | func_name = line[0] 30 | del line[0] 31 | 32 | modulefunctions.execute_code( 33 | func_name, 34 | line, 35 | variables, 36 | index, 37 | lines, 38 | _functions, 39 | python_funcs_and_vars 40 | ) 41 | 42 | def run_main(line, variables, index, lines, _functions_dict, python_funcs_and_vars): 43 | run_function(line, variables, index, lines, _functions_dict, python_funcs_and_vars) 44 | del lines[index] 45 | -------------------------------------------------------------------------------- /diamond-functions(PY)/compile_codes.py: -------------------------------------------------------------------------------- 1 | 2 | # MIT License 3 | 4 | # Copyright (c) 2022 John Oseni 5 | 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | 24 | 25 | # Import from ther files and folder 26 | 27 | from . import * 28 | from .python_run import python_run 29 | from .creating_functions import create_function 30 | from .creating_variables import create_variable 31 | from ..rundiamond import run_main 32 | from ..rundiamond import run_function 33 | from .getting_variables import * 34 | from .show_erros import * 35 | from .getting_functions import * 36 | from .spill import * 37 | 38 | 39 | # Main codes 40 | 41 | def execute_code(func_name, line, variables, index, lines, functions, python_funcs_and_vars): 42 | if func_name == 'spill': 43 | text = getting_variable(line[0], variables, line) 44 | 45 | spill(text) 46 | elif func_name == 'create_variable': 47 | var_name = line[0] 48 | var_value = line[1] 49 | 50 | create_variable(var_name, var_value, variables) 51 | elif func_name == 'create_function': 52 | create_function(line[0], lines) 53 | elif func_name in functions: 54 | function_lines = functions[func_name] 55 | 56 | for i in range(len(functions[func_name])): 57 | run_function(function_lines[i], variables, i, lines, functions) 58 | elif func_name == 'import': 59 | module_name = line[0] 60 | if not module_name.endswith('.cobra'): 61 | module_name += '.cobra' 62 | elif module_name.endswith('.cobra'): 63 | pass 64 | else: 65 | syntax_error() 66 | 67 | with open(module_name, 'r') as f: 68 | module_code = f.read() 69 | 70 | module_code = module_code.split('\n') 71 | for i in range(len(module_code)): 72 | run_main(module_code[0], variables, 0, module_code, functions) 73 | elif func_name == 'python_run': 74 | query = line[0] 75 | python_run(query, variables, line, python_funcs_and_vars) 76 | elif func_name == '' or func_name.startswith('#'): 77 | pass 78 | else: 79 | function_not_recognized(func_name) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |

Diamond Programming Language

3 |
4 | 5 | ## Requirements to run Diamond 6 | 7 | - All needed right now is nothing but the python programming langauge, and you could learn how to download and set it up [here](https://medium.com/co-learning-lounge/how-to-download-install-python-on-windows-2021-44a707994013) 8 | 9 | # Usage (Diamond PL) 10 | 11 | ### How to run 12 | 13 | #### Mac or Linux 14 | ```bash 15 | ./diamond.sh 16 | ``` 17 | 18 | What to write to run the codes: 19 | 20 | ```shell 21 | python execute.py 22 | ``` 23 | 24 | #### Windows 25 | ```batch 26 | diamond 27 | ``` 28 | 29 | You could check out my `Schemacodes.diamond` in folder DIR 30 | 31 | You can run it by running the following command in your terminal: 32 | ```shell 33 | python execute.py Schemacodes.diamond 34 | ``` 35 | or by using the above: [Windows](#windows), [Mac or Linux](#mac-or-linux). 36 | 37 | ### Syntax 38 | The basic syntax for a diamond programming language program is: `name of function any arguments to be passed in to the function`. 39 | For example, 40 | if you input `spill Hello, World!`, `spill` is the function in diamond 41 | and `Hello, World!` is the argument passed to it. To create a comment, use the # sign. 42 | For example: `# Of cause we know that this is a comment and it would be ignored by diamond PL`. 43 | 44 | ### Functions 45 | The current functions for diamond are: 46 | #### spill 47 | Task: Print this in the console 48 |
49 | Arguments will be like : 50 | - text: e.g (`hello world`) 51 | 52 | Sample: `spill Hello, World!` 53 | 54 | #### create_variables in Diamond 55 | Create a variable in diamond 56 | 57 |
58 | Arguments: 59 | - name: Variable name 60 | - value: Variable value. Could be a existing variable or string before 61 | 62 | Example: `create_variable dior "this is me"` 63 | 64 | #### create_function 65 | Description: Creates a function 66 |
67 | Arguments: 68 | - name: Name the function 69 | 70 | Example: 71 | ``` 72 | create_function my_world: 73 | spill "hello" 74 | ``` 75 | 76 | when you wanna execute a function?: 77 | ``` 78 | # Type the function's name down 79 | my_world 80 | ``` 81 | 82 | #### import a file in diamond 83 | Task: Import another file into your own file 84 |
85 | Arguments: 86 | - The filename: The name of the file you want to import could end with .diamonod or maybe not. 87 | 88 | Example: `import hiworld` 89 | 90 | In hiworld.diamond, there is a function called `my_function`. To run it, just type it in. 91 | ``` 92 | import hiworld 93 | my_function 94 | ``` 95 | The `import` function will always import everything in the file for now 96 | 97 | #### python_run 98 | Task: Runs a line of Python code in the diamond environment. 99 |
100 | Arguments: 101 | - query: The query that you want to run. 102 | 103 | Sample : `python_run "print('Hello World!')"` 104 | 105 | This makes it go in line with python programming language, because it was written in python 106 | 107 | For other samples check the folder `Schemacodes.diamond` file in the root DIR. 108 | 109 |
110 |

Author John Oseni

111 |
--------------------------------------------------------------------------------