├── .gitattributes ├── tests ├── test-module-path │ ├── testdir1 │ │ └── empty.pashm │ ├── somedir │ │ ├── dir2 │ │ │ └── .gitkeep │ │ └── __init__.pashm │ ├── is_main_test.pashm │ ├── bar.pashm │ ├── testdir2 │ │ ├── __init__.pashm │ │ └── core.pashm │ ├── testpyfile.py │ ├── testdir3 │ │ └── __init__.pashm │ ├── testliba.pashm │ ├── import-run-test.pashm │ ├── dir-and-file.pashm │ └── foo.pashmt ├── pit │ ├── other.html │ └── test.html ├── compiler │ └── app │ │ ├── other.pashm │ │ ├── thedir │ │ ├── other.pashm │ │ └── __init__.pashm │ │ ├── last.pashm │ │ ├── second.pashm │ │ └── app.pashm ├── stdlib │ ├── assert │ │ ├── 0.pashmt │ │ ├── 1.pashmt │ │ ├── 2.pashmt │ │ ├── 3.pashmt │ │ └── assert_true.pashmt │ ├── exit1.pashmt │ ├── example1.pashmt │ ├── exit0.pashmt │ ├── eval.pashmt │ ├── die-bug-001.pashmt │ ├── raise.pashmt │ ├── import.pashmt │ ├── eval-bug001.pashmt │ ├── die001.pashmt │ ├── example0.pashmt │ ├── py-load-module-001.pashmt │ ├── die002.pashmt │ ├── var_dump-001.pashmt │ ├── die003.pashmt │ ├── print.pashmt │ ├── gset.pashmt │ └── py-load-file-001.pashmt ├── sys │ └── 001.pashmt ├── eval │ ├── eval.pashmt │ ├── eval2.pashmt │ └── python.pashmt ├── module │ ├── import │ │ ├── bug001.pashmt │ │ ├── error_2.pashmt │ │ ├── error_3.pashmt │ │ ├── bug002.pashmt │ │ ├── module_not_found_error.pashmt │ │ ├── multi-import-2.pashmt │ │ ├── bug006.pashmt │ │ ├── 1.pashmt │ │ ├── bug003.pashmt │ │ ├── bug003-2.pashmt │ │ ├── bug004.pashmt │ │ ├── example_hash_module.pashmt │ │ ├── multi_import │ │ │ ├── 0.pashmt │ │ │ ├── 2.pashmt │ │ │ └── 1.pashmt │ │ ├── 002-import-once.pashmt │ │ ├── 0.pashmt │ │ └── bug005.pashmt │ └── path │ │ ├── error0.pashmt │ │ ├── 1.pashmt │ │ └── 0.pashmt ├── core │ ├── syntax006.pashmt │ ├── syntax0.pashmt │ ├── syntax003.pashmt │ ├── syntax004.pashmt │ ├── syntax005.pashmt │ ├── null.pashmt │ ├── runtime_error.pashmt │ ├── syntax1.pashmt │ ├── literals-error-in-names002.pashmt │ ├── literals-error-in-names003.pashmt │ ├── literals-error-in-names001.pashmt │ ├── is-main-variable.pashmt │ ├── shutdown-event-bug001.pashmt │ ├── multiline.pashmt │ ├── set-get-functions.pashmt │ ├── syntax-bug-multiline-001.pashmt │ ├── datatype-aliases.pashmt │ └── syntax-bug-007.pashmt ├── io │ ├── print.pashmt │ └── read │ │ ├── 0.pashmt │ │ ├── 5.pashmt │ │ ├── 3.pashmt │ │ ├── 4.pashmt │ │ └── 6.pashmt ├── examples │ ├── array.pashmt │ ├── get_password1.pashmt │ ├── get_password0.pashmt │ └── fib.pashmt ├── function │ ├── undefined_func.pashmt │ ├── bug001.pashmt │ ├── super-functions-002.pashmt │ ├── func_arg_variable.pashmt │ ├── return002.pashmt │ ├── func_multi_call.pashmt │ ├── func_error.pashmt │ ├── return001.pashmt │ ├── return003.pashmt │ ├── func_arg_variable2.pashmt │ ├── func_args.pashmt │ ├── func0.pashmt │ ├── arg-type-002.pashmt │ └── bug002.pashmt ├── section │ ├── error2.pashmt │ ├── error3.pashmt │ ├── 0.pashmt │ └── 1.pashmt ├── tryendtry │ ├── error2.pashmt │ ├── error3.pashmt │ ├── bug001.pashmt │ └── 0.pashmt ├── array │ ├── pop.pashmt │ └── append.pashmt ├── test-module │ ├── 1.pashmt │ ├── 2.pashmt │ ├── 3.pashmt │ └── 4.pashmt ├── classes │ ├── 004-syntax-error.pashmt │ ├── inheritance002.pashmt │ ├── super-functions-002.pashmt │ ├── method003.pashmt │ ├── 014-super-error.pashmt │ ├── method-bug-001.pashmt │ ├── 007.pashmt │ ├── 003-props.pashmt │ └── 001.pashmt ├── consts │ ├── 002.pashmt │ ├── 001.pashmt │ ├── bug003.pashmt │ └── bug004.pashmt ├── time │ └── 001.pashmt ├── if │ └── 003-without-endif.pashmt ├── cli_args │ └── argv.pashmt ├── variables │ ├── isset.pashmt │ ├── copy.pashmt │ ├── free0.pashmt │ └── gget001.pashmt ├── namespace │ ├── bug002.pashmt │ ├── ns-alias.pashmt │ ├── variable_in_ns.pashmt │ ├── namespace_variable_error.pashmt │ ├── bug001.pashmt │ └── 0.pashmt └── random │ └── 001.pashmt ├── doc ├── 07_files │ ├── README.md │ └── 00_working_with_files.md ├── 03_try_endtry │ ├── README.md │ └── 01_raising_errors.md ├── 04_os_command │ ├── README.md │ ├── 01_file_and_dir_variables.md │ └── 00_os_commands.md ├── 09_eval │ ├── README.md │ ├── 01_python_code.md │ ├── 00_eval.md │ └── 02_function_py_load_file.md ├── 01_if_and_loop │ └── README.md ├── 10_modules │ ├── 20_another_libraries.md │ ├── 19_running_modules_in_cli.md │ ├── README.md │ ├── 00_modules.md │ ├── 03_random.md │ ├── 17_python_standard_modules.md │ ├── 01_hash.md │ ├── 02_time.md │ └── 05_sys.md ├── 05_importing │ ├── README.md │ └── 02_return_value.md ├── 02_functions │ ├── README.md │ └── 02_super_functions.md ├── 06_namespaces │ ├── README.md │ ├── 04_namespace_magic_function.md │ ├── 02_subnamespace.md │ └── 03_importing_inside_namespace.md ├── 00_basics │ ├── README.md │ └── 03_constants.md ├── 11_advance │ ├── 02_var_dump.md │ ├── 03_perror.md │ ├── 08_function_die.md │ ├── 04_printf.md │ ├── README.md │ ├── 05_style_guide.md │ ├── 13_function_match.md │ ├── 00_pashmak_jit.md │ ├── 07_shutdown_event.md │ └── 12_cloning_objects.md ├── 12_web │ ├── README.md │ ├── 05_webserver_configuration.md │ ├── 01_get_and_post.md │ └── 02_env_vars.md ├── 08_class_and_oop │ ├── 02_general_attributes.md │ ├── README.md │ └── 05_complicated_declaration.md ├── README.md └── 13_dev_guide │ ├── README.md │ └── 00_structure.md ├── .gitignore ├── scripts └── clear-jit-cache.sh ├── win-configure.bat ├── .deepsource.toml ├── SECURITY.md ├── .github └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── src ├── helloworld │ └── __init__.pashm ├── serve │ └── __init__.pashm ├── sys │ └── __init__.pashm └── core │ └── version.py ├── examples ├── ask_name.pashm ├── will_be_include.pashm ├── handle_error.pashm ├── get_password.pashm ├── array.pashm ├── loop.pashm └── fib.pashm └── logo.svg /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto -------------------------------------------------------------------------------- /tests/test-module-path/testdir1/empty.pashm: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/test-module-path/somedir/dir2/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/pit/other.html: -------------------------------------------------------------------------------- 1 |

included {{ $htmldata }}

-------------------------------------------------------------------------------- /tests/compiler/app/other.pashm: -------------------------------------------------------------------------------- 1 | println('i am other') 2 | -------------------------------------------------------------------------------- /tests/compiler/app/thedir/other.pashm: -------------------------------------------------------------------------------- 1 | println('the dir other') 2 | -------------------------------------------------------------------------------- /tests/test-module-path/is_main_test.pashm: -------------------------------------------------------------------------------- 1 | println $__ismain__ 2 | -------------------------------------------------------------------------------- /tests/test-module-path/bar.pashm: -------------------------------------------------------------------------------- 1 | $name = 'parsa' 2 | return $name 3 | -------------------------------------------------------------------------------- /tests/test-module-path/somedir/__init__.pashm: -------------------------------------------------------------------------------- 1 | println('I am a imported directory') -------------------------------------------------------------------------------- /tests/test-module-path/testdir2/__init__.pashm: -------------------------------------------------------------------------------- 1 | import $__dir__ + '/core.pashm' 2 | -------------------------------------------------------------------------------- /doc/07_files/README.md: -------------------------------------------------------------------------------- 1 | # Documentation > Files 2 | 3 | - [Files](00_working_with_files.md) 4 | -------------------------------------------------------------------------------- /tests/compiler/app/thedir/__init__.pashm: -------------------------------------------------------------------------------- 1 | println('the dir init') 2 | import $__dir__ + '/other.pashm' 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | /pashmak.spec 3 | /build 4 | /dist 5 | /venv 6 | /pylint.out 7 | __pashmam__ 8 | /.idea 9 | -------------------------------------------------------------------------------- /tests/test-module-path/testpyfile.py: -------------------------------------------------------------------------------- 1 | the_var = 'The value of python var' 2 | 3 | def the_func(): 4 | pass 5 | 6 | -------------------------------------------------------------------------------- /tests/test-module-path/testdir3/__init__.pashm: -------------------------------------------------------------------------------- 1 | func the_test_in_init() 2 | println('Hello! i am a test') 3 | endfunc 4 | -------------------------------------------------------------------------------- /scripts/clear-jit-cache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm $(find . -type d -name __pashmam__) -rf 3 | rm $(find . -type d -name __pycache__) -rf 4 | -------------------------------------------------------------------------------- /tests/test-module-path/testliba.pashm: -------------------------------------------------------------------------------- 1 | namespace testliba 2 | func run() 3 | println 'hello testliba' 4 | endfunc 5 | endns 6 | -------------------------------------------------------------------------------- /tests/test-module-path/import-run-test.pashm: -------------------------------------------------------------------------------- 1 | if $__ismain__ 2 | println('i am main') 3 | else 4 | println('i am NOT main') 5 | endif 6 | -------------------------------------------------------------------------------- /tests/test-module-path/testdir2/core.pashm: -------------------------------------------------------------------------------- 1 | namespace testdir2 2 | func run() 3 | println 'hello testdir2' 4 | endfunc 5 | endns 6 | -------------------------------------------------------------------------------- /win-configure.bat: -------------------------------------------------------------------------------- 1 | @python src\pashmak.py scripts\module-build.pashm 2 | @python src\pashmak.py scripts\update-headers.pashm 3 | @python tests\run.py 4 | -------------------------------------------------------------------------------- /doc/03_try_endtry/README.md: -------------------------------------------------------------------------------- 1 | # Documentation > Try endtry 2 | 3 | - [Try-endtry statement](00_try_and_endtry.md) 4 | - [Raising errors](01_raising_errors.md) 5 | -------------------------------------------------------------------------------- /doc/04_os_command/README.md: -------------------------------------------------------------------------------- 1 | # Documentation > OS Commands 2 | 3 | - [OS Commands](00_os_commands.md) 4 | - [$__file__ and $__dir__ variables](01_file_and_dir_variables.md) 5 | -------------------------------------------------------------------------------- /doc/09_eval/README.md: -------------------------------------------------------------------------------- 1 | # Documentation > Eval 2 | 3 | - [Eval](00_eval.md) 4 | - [Python code](01_python_code.md) 5 | - [Function `py_load_file`](02_function_py_load_file.md) 6 | -------------------------------------------------------------------------------- /.deepsource.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | 3 | test_patterns = ["tests/**"] 4 | 5 | [[analyzers]] 6 | name = "python" 7 | enabled = true 8 | 9 | [analyzers.meta] 10 | runtime_version = "3.x.x" 11 | -------------------------------------------------------------------------------- /doc/01_if_and_loop/README.md: -------------------------------------------------------------------------------- 1 | # Documentation > If and loop 2 | 3 | - [Sections](00_sections.md) 4 | - [If statement](01_if_statement.md) 5 | - [Loops](02_while_loop.md) 6 | - [Conditions](03_conditions.md) 7 | -------------------------------------------------------------------------------- /doc/10_modules/20_another_libraries.md: -------------------------------------------------------------------------------- 1 | # Another useful libraries written by others 2 | 3 | - The [polor-pashm](https://github.com/sami2020pro/polor-pashm) library by [sami2020pro](https://github.com/sami2020pro) 4 | -------------------------------------------------------------------------------- /tests/compiler/app/last.pashm: -------------------------------------------------------------------------------- 1 | println('hello i am last') 2 | 3 | import @os 4 | println($os.osname) 5 | 6 | import_once $__dir__ + '/second.pashm' 7 | 8 | println($__ismain__) 9 | 10 | something() 11 | -------------------------------------------------------------------------------- /doc/05_importing/README.md: -------------------------------------------------------------------------------- 1 | # Documentation > importing scripts 2 | 3 | - [Importing scripts](00_include_scripts.md) 4 | - [$__ismain__ variable](01_ismain_variable.md) 5 | - [Script return value](02_return_value.md) 6 | -------------------------------------------------------------------------------- /tests/test-module-path/dir-and-file.pashm: -------------------------------------------------------------------------------- 1 | println $__dir__, $__file__ 2 | 3 | func empty_func() 4 | endfunc 5 | 6 | func hello() 7 | println $__dir__, $__file__ 8 | endfunc 9 | 10 | println $__dir__, $__file__ 11 | -------------------------------------------------------------------------------- /doc/02_functions/README.md: -------------------------------------------------------------------------------- 1 | # Documentation > Functions 2 | 3 | - [Functions](00_functions.md) 4 | - [Functions as variables](01_put_functions_as_variable.md) 5 | - [Super functions](02_super_functions.md) 6 | - [Complicated declaration](03_complicated_function_declaration.md) 7 | -------------------------------------------------------------------------------- /doc/09_eval/01_python_code.md: -------------------------------------------------------------------------------- 1 | # run python code 2 | you can run python code like `eval` with `python` command: 3 | 4 | ```bash 5 | $code = 'print("hello world from python")' 6 | python($code) 7 | ``` 8 | 9 | output: 10 | 11 | ``` 12 | hello world from python 13 | ``` 14 | -------------------------------------------------------------------------------- /tests/compiler/app/second.pashm: -------------------------------------------------------------------------------- 1 | println('i am second') 2 | 3 | if not $__ismain__ 4 | println('Second: the True') 5 | else 6 | println('Second: the False') 7 | endif 8 | 9 | $z = 0 10 | while $z < 3 11 | println('y:' + str($z)) 12 | $z = $z + 1 13 | endwhile 14 | -------------------------------------------------------------------------------- /doc/06_namespaces/README.md: -------------------------------------------------------------------------------- 1 | # Documentation > Namespaces 2 | 3 | - [Namespaces](00_namespaces.md) 4 | - [Command use](01_command_use.md) 5 | - [Subnamespace](02_subnamespace.md) 6 | - [importing in namespace](03_importing_inside_namespace.md) 7 | - [function `__namespace__`](04_namespace_magic_function.md) 8 | -------------------------------------------------------------------------------- /doc/00_basics/README.md: -------------------------------------------------------------------------------- 1 | # Documentation > Basics 2 | 3 | - [Installation](00_installation.md) 4 | - [Basics](01_basics.md) 5 | - [Variables](02_variables.md) 6 | - [Constants](03_constants.md) 7 | - [Read input from user](04_read_input_from_user.md) 8 | - [Datatypes](05_datatypes.md) 9 | - [Arrays](06_arrays.md) 10 | -------------------------------------------------------------------------------- /doc/11_advance/02_var_dump.md: -------------------------------------------------------------------------------- 1 | # function `var_dump()` 2 | This function can get a object and dump that. 3 | 4 | for example: 5 | 6 | ```bash 7 | var_dump('hello') 8 | 9 | $other = 'the other value' 10 | var_dump($other) 11 | ``` 12 | 13 | output: 14 | 15 | ``` 16 | 'hello' 17 | 'the other value' 18 | ``` 19 | -------------------------------------------------------------------------------- /doc/12_web/README.md: -------------------------------------------------------------------------------- 1 | # Documentation > Web 2 | 3 | - [Introduction](00_introduction.md) 4 | - [GET and POST data](01_get_and_post.md) 5 | - [Environment Variables](02_env_vars.md) 6 | - [Cookies](03_cookies.md) 7 | - [Session system](04_session.md) 8 | - [Configuring other Webservers for Pashmak](05_webserver_configuration.md) 9 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Modhej-Script Security Policy 2 | 3 | if you detected a Bug or Vulnearability in the Modhej-Script project, you can reporting that with the following ways: 4 | 5 | - report by sending an email to ModhejScript@gmail.com 6 | - opening an [issue](https://github.com/mohsenmodhej/modhej-script/issues/new) on github 7 | 8 | Thank you for helping to this Project! 9 | -------------------------------------------------------------------------------- /doc/11_advance/03_perror.md: -------------------------------------------------------------------------------- 1 | # perror() 2 | There is diffrent between normal print(print on STDOUT) and error print(print on STDERR). the `print` and `println` functions print on stdout(normal output). but you can print on STDERR using `perror` function. this is even `print`. 3 | 4 | for example: 5 | 6 | ```bash 7 | perror('hello world. this is a error and is printed on STDERR') 8 | ``` 9 | -------------------------------------------------------------------------------- /doc/11_advance/08_function_die.md: -------------------------------------------------------------------------------- 1 | # Function `die()` 2 | This function prints something and exits program. 3 | 4 | For example: 5 | 6 | ```bash 7 | die("Good bye") 8 | ``` 9 | 10 | Also you can use this without argument: 11 | 12 | ```bash 13 | die() 14 | ``` 15 | 16 | By default, this function exits with `1` exit code. You can change exit code by passing second argument: 17 | 18 | ```bash 19 | die("good bye", 100) 20 | ``` 21 | -------------------------------------------------------------------------------- /doc/06_namespaces/04_namespace_magic_function.md: -------------------------------------------------------------------------------- 1 | # `__namespace__()` function 2 | There is function named `__namespace__`. this function returns the current namespace as string. 3 | 4 | Look at this example: 5 | 6 | ```bash 7 | namespace app 8 | namespace core 9 | println(__namespace__()) 10 | endns 11 | endns 12 | 13 | println(__namespace__()) 14 | ``` 15 | 16 | output: 17 | 18 | ``` 19 | app.core. 20 | 21 | ``` 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: If you have a idea about new feature, tell us 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Fillable** 11 | you are suggesting **New feature** or **Changing feature**? new/changing 12 | - [ ] did you read the Pashmak documentation? 13 | - [ ] are you sure this feature already not exists? 14 | 15 | **The title** 16 | Please describe your idea or feature request here... 17 | -------------------------------------------------------------------------------- /doc/08_class_and_oop/02_general_attributes.md: -------------------------------------------------------------------------------- 1 | # Classes general attributes 2 | classes has some general properties: 3 | 4 | - `__name__`: name of the class 5 | - `__parent__`: name of parent of class 6 | - `__props__`: all of object properties as Dictonary 7 | - `__methods__`: all of object methods as Dictonary 8 | - `__theclass__`: the object class type 9 | 10 | for example: 11 | 12 | ```bash 13 | class Person 14 | 15 | endclass 16 | 17 | $person = Person() 18 | 19 | println($person->__name__) # output: Person 20 | ``` 21 | -------------------------------------------------------------------------------- /doc/10_modules/19_running_modules_in_cli.md: -------------------------------------------------------------------------------- 1 | # Running modules in command line 2 | Some of modules maybe have a behavior like a application. You can run them directly from command line. 3 | 4 | for example: 5 | 6 | ```bash 7 | $ pashmak @helloworld 8 | ``` 9 | 10 | The `@helloworld` is a test module for this action. 11 | 12 | output: 13 | 14 | ``` 15 | Hello world! 16 | ``` 17 | 18 | Actually, running above command is like that to import `helloworld` with `import_run` command: 19 | 20 | ```bash 21 | import_run @helloworld 22 | ``` 23 | -------------------------------------------------------------------------------- /doc/11_advance/04_printf.md: -------------------------------------------------------------------------------- 1 | # function `printf()` 2 | This function prints on a specify FILE. 3 | 4 | By default, this works like normal `print` function. for example: 5 | 6 | ```bash 7 | printf('hello world\n') 8 | ``` 9 | 10 | output: 11 | 12 | ``` 13 | hello world 14 | ``` 15 | 16 | But you can pass a Second argument as file. for example: 17 | 18 | ```bash 19 | $file = open('/path/to/file.txt', 'a') # append mode 20 | 21 | printf('hello', $file) 22 | ``` 23 | 24 | Now, string `hello` is appended to content of the file. 25 | 26 | -------------------------------------------------------------------------------- /doc/08_class_and_oop/README.md: -------------------------------------------------------------------------------- 1 | # Documentation > Class and OOP 2 | 3 | - [Classes](00_classes.md) 4 | - [Inheritance](01_inheritance.md) 5 | - [General attributes](02_general_attributes.md) 6 | - [Magic methods](03_magic_methods.md) 7 | - [Super functions](04_class_super_functions.md) 8 | - [Complicated declaration](05_complicated_declaration.md) 9 | - [Static properties and methods](06_static_props_and_methods.md) 10 | - [Method `isinstanceof`](07_method_isinstanceof.md) 11 | - [Handling parent/self methods and properties](08_handle_parent_and_self_props.md) 12 | -------------------------------------------------------------------------------- /doc/12_web/05_webserver_configuration.md: -------------------------------------------------------------------------------- 1 | # WebServer Configuration 2 | You can run Pashmak in Apache or other webservers. 3 | 4 | For running Pashmak in the Traditional webservers, You only need to write a `.htaccess` file with the following contents: 5 | 6 | ```htaccess 7 | AddHandler cgi-script .pashm .pashm.html .pit 8 | Options +ExecCGI 9 | DirectoryIndex .pashm 10 | ``` 11 | 12 | And then, add the Shebang for your Pashmak scripts (`.pashm`, `.pashm.html`, `.pit`). 13 | And make them executable using `chmod +x filename.pashm` (If you are on UNIX systems). 14 | 15 | -------------------------------------------------------------------------------- /doc/README.md: -------------------------------------------------------------------------------- 1 | # Welcome to pashmak documentation 2 | 3 | --- 4 | 5 | ## Table of content 6 | 7 | - [basics and variables](00_basics) 8 | - [If and Loop](01_if_and_loop) 9 | - [functions](02_functions) 10 | - [try-endtry statement](03_try_endtry) 11 | - [os commands](04_os_commands) 12 | - [importing](05_importing) 13 | - [namespaces](06_namespaces) 14 | - [files](07_files) 15 | - [classes and OOP](08_class_and_oop) 16 | - [eval](09_eval) 17 | - [modules](10_modules) 18 | - [advance](11_advance) 19 | - [web development](12_web) 20 | - [developer guide](13_dev_guide) 21 | -------------------------------------------------------------------------------- /doc/06_namespaces/02_subnamespace.md: -------------------------------------------------------------------------------- 1 | # namespace in namespace (subnamespace) 2 | you can declare a namespace in a namespace 3 | 4 | look at this example: 5 | 6 | ```bash 7 | namespace App 8 | func hello() 9 | println('hello world') 10 | endfunc 11 | 12 | # declare namespace `Core` under `App` 13 | namespace Core 14 | func run() 15 | println('the core') 16 | endfunc 17 | endns 18 | endns 19 | 20 | # now we use it 21 | App.hello() 22 | 23 | App.Core.run() 24 | ``` 25 | 26 | output: 27 | 28 | ``` 29 | hello world 30 | the core 31 | ``` 32 | -------------------------------------------------------------------------------- /doc/04_os_command/01_file_and_dir_variables.md: -------------------------------------------------------------------------------- 1 | # `$__file__` and `$__dir__` variables 2 | `$__file__` and `$__dir__` variables are two variables contains self script filepath and dirpath. 3 | 4 | for example, if you run an script in `/home/parsa/myscript.pashm` with this content: 5 | 6 | ```bash 7 | println($__file__) 8 | println($__dir__) 9 | ``` 10 | 11 | output is: 12 | 13 | ``` 14 | /home/parsa/myscript.pashm 15 | /home/parsa 16 | ``` 17 | 18 | The `$__file__` variable contains filepath of current running script. 19 | 20 | The `$__dir__` variable contains dirpath of current running script. 21 | -------------------------------------------------------------------------------- /doc/11_advance/README.md: -------------------------------------------------------------------------------- 1 | # Documentation > Advance 2 | 3 | - [Jit](00_pashmak_jit.md) 4 | - [Advance Stdout handling](01_advance_stdout_handling.md) 5 | - [var_dump()](02_var_dump.md) 6 | - [perror()](03_perror.md) 7 | - [printf()](04_printf.md) 8 | - [Style guide](05_style_guide.md) 9 | - [Pit engine](06_pit.md) 10 | - [Shutdown event](07_shutdown_event.md) 11 | - [die()](08_function_die.md) 12 | - [Pashmiler compiler](09_compiler.md) 13 | - [Docstrings](10_docstring.md) 14 | - [Name Defines](11_name_defines.md) 15 | - [Cloning Objects](12_cloning_objects.md) 16 | - [match()](13_function_match.md) 17 | -------------------------------------------------------------------------------- /doc/09_eval/00_eval.md: -------------------------------------------------------------------------------- 1 | # Eval 2 | 3 | you can run Pashmak code from string. 4 | 5 | look at this example: 6 | 7 | ```bash 8 | eval('println("hello world from string")') 9 | ``` 10 | 11 | output: 12 | 13 | ``` 14 | hello world from string 15 | ``` 16 | 17 | this code is runed from a string. 18 | 19 | look at this example: 20 | 21 | ```bash 22 | print('enter some code: ') 23 | $code = read() 24 | 25 | eval($code) 26 | ``` 27 | 28 | output: 29 | 30 | ``` 31 | enter some code: mem 'hi\n'; print(^); 32 | hi 33 | ``` 34 | 35 | the above code gets a string from user and runs that as pashmak code. 36 | -------------------------------------------------------------------------------- /doc/10_modules/README.md: -------------------------------------------------------------------------------- 1 | # Documentation > Modules 2 | 3 | - [Modules](00_modules.md) 4 | - [Module hash](01_hash.md) 5 | - [Module time](02_time.md) 6 | - [Module random](03_random.md) 7 | - [Module test](04_test.md) 8 | - [Module sys](05_sys.md) 9 | - [Module os](06_os.md) 10 | - [Module web.server](07_web.server.md) 11 | - [Module math](08_math.md) 12 | - [Module string](09_string.md) 13 | - [Python standard modules](17_python_standard_modules.md) 14 | - [Module Path system](18_module_path.md) 15 | - [Running modules in cli](19_running_modules_in_cli.md) 16 | - [Another libraries](20_another_libraries.md) 17 | -------------------------------------------------------------------------------- /doc/03_try_endtry/01_raising_errors.md: -------------------------------------------------------------------------------- 1 | # raising errors 2 | Your self can raise errors in the program. 3 | 4 | for example: 5 | 6 | ```bash 7 | println('program started') 8 | 9 | raise(Error('MyError', 'this is my error')) 10 | 11 | println('this will not print') 12 | ``` 13 | 14 | output: 15 | 16 | ``` 17 | progrma started 18 | MyError: this is my error 19 | ``` 20 | 21 | The `raise` function can raise errors in program. 22 | 23 | You should pass a object from class `Error` as argument for this. 24 | 25 | To do this, you need to write `Error('TypeOfError', 'message of error')`. You will learn about classes in next sections. 26 | -------------------------------------------------------------------------------- /doc/05_importing/02_return_value.md: -------------------------------------------------------------------------------- 1 | # Script return value 2 | Scripts can return some values (like functions). 3 | 4 | For example, we have `foo.pashm`: 5 | 6 | ```bash 7 | # ... 8 | 9 | return 'hello world' 10 | ``` 11 | 12 | Now, if i import this file: 13 | 14 | ```bash 15 | $output = import('foo.pashm') 16 | 17 | println 'output: ' + $output 18 | ``` 19 | 20 | Output: 21 | 22 | ``` 23 | output: hello world 24 | ``` 25 | 26 | As you can see, function `import` (or `import_once`, `import_run`...) will return the returned value 27 | by command `return` in the script. By this feature, we can return values by scripts like functions. 28 | -------------------------------------------------------------------------------- /tests/compiler/app/app.pashm: -------------------------------------------------------------------------------- 1 | $i = 324456 2 | println('hello') 3 | 4 | println($__ismain__) 5 | 6 | func something() 7 | println('The something func') 8 | endfunc 9 | 10 | import $__dir__ + '/second.pashm', $__dir__ + '/last.pashm' 11 | 12 | if True 13 | println('the True') 14 | else 15 | println('the False') 16 | endif 17 | 18 | $z = 0 19 | while $z < 3 20 | println('z:' + str($z)) 21 | $z = $z + 1 22 | endwhile 23 | 24 | println($__ismain__) 25 | 26 | import $__dir__ + '/thedir' 27 | 28 | $i = 0 29 | while $i < 3 30 | import $__dir__ + '/other.pashm' 31 | $i = $i + 1 32 | endwhile 33 | 34 | println('end') 35 | -------------------------------------------------------------------------------- /doc/11_advance/05_style_guide.md: -------------------------------------------------------------------------------- 1 | # Pashmak Style Guide 2 | Naming variables, functions, classes... Is a important thing in style of you codes. 3 | 4 | We suggest **snake_case** naming style for Functions, Methods and Variables. And **PascalCase** naming style for Classes. For namespaces, we suggest both of them 5 | 6 | for example: 7 | 8 | ```bash 9 | namespace SomeNamespace 10 | class SomeThing 11 | func some_method 12 | # ... 13 | endfunc 14 | endclass 15 | 16 | func some_function 17 | # ... 18 | endfunc 19 | 20 | namespace other_namespace 21 | # ... 22 | endns 23 | endns 24 | ``` 25 | -------------------------------------------------------------------------------- /doc/10_modules/00_modules.md: -------------------------------------------------------------------------------- 1 | # Internal Modules 2 | pashmak has some internal libraries to use. that modules are helpful for you. 3 | 4 | ## how to import module 5 | you can import modules with `import` function. 6 | 7 | look at this example: 8 | 9 | ```bash 10 | import '@hash' 11 | import "@module_name" 12 | import "@module1", '@module2' 13 | 14 | # also you can import modules without quotes 15 | import @sys 16 | import @hash, @mymodule 17 | 18 | # also you can import modules like scripts under the namespaces 19 | namespace Foo 20 | import '@hash' 21 | endns 22 | 23 | # ... 24 | ``` 25 | 26 | you have to give name of module with a `@` before that to the include command. 27 | -------------------------------------------------------------------------------- /doc/11_advance/13_function_match.md: -------------------------------------------------------------------------------- 1 | # Function `match()` 2 | This function is a helper to make this syntax easier: 3 | 4 | ```bash 5 | $result = null 6 | 7 | if $value == 'A' 8 | $result = 'The A' 9 | elif $value == 'B' 10 | $result = 'The B' 11 | else 12 | $result = 'Other' 13 | endif 14 | ``` 15 | 16 | The above syntax is long. You can use `match()`: 17 | 18 | ```bash 19 | $result = match($value, [ 20 | ['A', 'The A'], 21 | ['B', 'The B'], 22 | ]) 23 | ``` 24 | 25 | Also you can use `default` argument for set the `else`: 26 | 27 | ```bash 28 | $result = match($value, [ 29 | ['A', 'The A'], 30 | ['B', 'The B'], 31 | ], default='Other') 32 | ``` 33 | 34 | -------------------------------------------------------------------------------- /doc/13_dev_guide/README.md: -------------------------------------------------------------------------------- 1 | # A Guide for Pashmak Core developers 2 | If you want to undrestand structure of Pashmak interpreter Source code, This Section is helpful. 3 | 4 | #### NOTE: this guide will not help you to FULL understand structure of pashmak core, You should also read the source code for full understand 5 | 6 | - [Structure of source code](00_structure.md) 7 | - [Builtin Modules](01_modules.md) 8 | - [Interpreter Core Structure](02_interpreter.md) 9 | - [Lexer and Parser API](03_lexer_parser.md) 10 | - [Eval and Variables](04_eval_var.md) 11 | - [Class and Function](05_class_function.md) 12 | - [Jit Compiler](06_jit.md) 13 | - [Release Process](07_release_process.md) 14 | 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: If you detected a bug in the Pashmak, you can report it to help us 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Description** 11 | Please describe the bug in here... 12 | 13 | **Code** 14 | ``` 15 | # if any code related to the bug, write that here 16 | ``` 17 | 18 | **The error message** 19 | If an error message is releated to the code, write it here... 20 | 21 | **Platform** 22 | - OS: e.g. GNU/Linux Ubuntu 18.04 23 | - Python version: e.g. 3.9 24 | - Pashmak version: e.g. 0.1 25 | 26 | (also you can run `pashmak --info` and write output here) 27 | 28 | **Additional context** 29 | If there is any more thing, write here 30 | -------------------------------------------------------------------------------- /doc/09_eval/02_function_py_load_file.md: -------------------------------------------------------------------------------- 1 | # `py_load_file` 2 | The `py_load_file` is a function to load python scripts as object in pashmak. 3 | 4 | for example, we have `myscript.py`: 5 | 6 | ```python 7 | def somefunc(): 8 | print("hello world") 9 | 10 | the_var = 'the value' 11 | 12 | ``` 13 | 14 | and our pashmak script: 15 | 16 | ```bash 17 | $pyobj = py_load_file('/path/to/myscript.py') 18 | 19 | println($pyobj->the_var) 20 | $pyobj->somefunc() 21 | ``` 22 | 23 | output: 24 | 25 | ``` 26 | the value 27 | hello world 28 | ``` 29 | 30 | also if your python script imports another python module, you should add path of that module to `PYTHONPATH` env var. for example: 31 | 32 | ```bash 33 | PYTHONPATH=/path/to/pypath pashmak myapp.pashm 34 | ``` 35 | 36 | -------------------------------------------------------------------------------- /doc/02_functions/02_super_functions.md: -------------------------------------------------------------------------------- 1 | # Function super functions 2 | there is some **Super functions** to handle functions at runtime. 3 | 4 | ## Checking function exists 5 | You can check a function exists with `func.exists` function: 6 | 7 | ```bash 8 | if func.exists('some_func') 9 | some_func() 10 | endif 11 | ``` 12 | 13 | ## Geting list of all of functions 14 | You can get list of all of functions with `func.list` function: 15 | 16 | ```bash 17 | $funcs = func.list() 18 | 19 | println($funcs) 20 | ``` 21 | 22 | output: 23 | 24 | ``` 25 | ['a', 'b', '...'] 26 | ``` 27 | 28 | The output is a list. 29 | 30 | ## Deleting a function 31 | You can delete a function at runtime with `func.delete` function: 32 | 33 | ```bash 34 | func.delete('some_func') 35 | ``` 36 | -------------------------------------------------------------------------------- /doc/11_advance/00_pashmak_jit.md: -------------------------------------------------------------------------------- 1 | # The Pashmak Jit Compiler 2 | The **Jit** or **Just in time** compiler, is a system to cache the code and compress that to speed up the interpreter. 3 | 4 | this system, compresses the content of scripts and saves them to `__pashmam__` directory. then, when file is runed again, jit system loads compressed content from that cache. 5 | 6 | you can see `__pashmam__` directory alongside your scripts. this directory contains cached codes. 7 | 8 | Also, make sure to add `__pashmam__` file to your **gitignore**. 9 | 10 | To disable the jit, you can use `PASHMAK_DISABLE_JIT` environment variable with value `1` while running the pashmak interpreter. 11 | for example: 12 | 13 | ```bash 14 | $ PASHMAK_DISABLE_JIT=1 pashmak somefile.pashm 15 | ``` 16 | -------------------------------------------------------------------------------- /doc/12_web/01_get_and_post.md: -------------------------------------------------------------------------------- 1 | # GET and POST data 2 | You can access to the GET and POSt data using `$web.get` and `$web.post` variables. they are dictionary. 3 | 4 | For example, if you open `/app.pashm?foo=bar&name=parsa`, and print content of `$web.get`: 5 | 6 | ```bash 7 | import @web 8 | web.init() 9 | web.end_headers() 10 | 11 | var_dump($web.get) 12 | ``` 13 | 14 | You will see: 15 | 16 | ```json 17 | { 18 | "foo": "bar", 19 | "name": "parsa" 20 | } 21 | ``` 22 | 23 | Means you can access the keys like this: 24 | 25 | ```bash 26 | # ... 27 | 28 | println $web.get['name'] 29 | ``` 30 | 31 | Also the `$web.post` is even like `$web.get`: 32 | 33 | ```bash 34 | # ... 35 | 36 | println $web.post['some_key'] 37 | ``` 38 | 39 | (If the request method is not POST, `$web.post` is a empty dictionary by default). 40 | -------------------------------------------------------------------------------- /doc/10_modules/03_random.md: -------------------------------------------------------------------------------- 1 | # random module 2 | this module makes random numbers 3 | 4 | ### random.randint 5 | 6 | ```bash 7 | import @random 8 | 9 | # generates a random int between 1 and 10 10 | println(random.randint(1, 10)) 11 | ``` 12 | 13 | ### random.seed 14 | Initialize the random number generator 15 | 16 | ```bash 17 | import @random 18 | random.seed(1000) 19 | ``` 20 | 21 | ### random.getstate 22 | Returns the current internal state of the random number generator 23 | 24 | ```bash 25 | import @random 26 | print(random.getstate()) 27 | ``` 28 | 29 | ### random.random 30 | 31 | ```bash 32 | import @random 33 | 34 | # generates a random float less that 1 35 | $rand = random.random() 36 | println($rand) 37 | ``` 38 | 39 | ### random.choice 40 | This function gets a list and returns a random item from that list: 41 | 42 | ```bash 43 | import @random 44 | println random.choice([1, 2, 3]) 45 | ``` 46 | -------------------------------------------------------------------------------- /doc/06_namespaces/03_importing_inside_namespace.md: -------------------------------------------------------------------------------- 1 | # importing inside namespaces 2 | you can import an script inside an namespace. 3 | 4 | for example, we have `foo.pashm` and `bar.pashm` scripts. 5 | 6 | #### `foo.pashm`: 7 | 8 | ```bash 9 | namespace foo 10 | func hello 11 | println('hello world') 12 | endfunc 13 | endns 14 | 15 | func bye 16 | println('good bye') 17 | endfunc 18 | ``` 19 | 20 | #### `bar.pashm`: 21 | 22 | ```bash 23 | import('foo.pashm') 24 | 25 | namespace App 26 | import('foo.pashm') 27 | endns 28 | 29 | foo.hello() # output: hello world 30 | bye() # output: good bye 31 | 32 | App.foo.hello() # output: hello world 33 | App.bye() # output: good bye 34 | ``` 35 | 36 | in above example, we imported `foo.pashm` inside an namespace and content of `foo.pashm` is loaded under that namespace. for example, `foo.hello` function is loaded under `App` namespace, so finally will be set as `App.foo.hello`. 37 | -------------------------------------------------------------------------------- /doc/13_dev_guide/00_structure.md: -------------------------------------------------------------------------------- 1 | # Structure of Pashmak Project source code 2 | 3 | Structure of Pashmak project directories: 4 | 5 | - `src/`: The Main Source Code 6 | - `tests/`: Tests folder ([You can learn testing system of Pashmak Here](/CONTRIBUTING.md)) 7 | - `doc/`: Documentation 8 | 9 | In the `src/` folder, We have some subdirectories. **Core Interpreter** is in `src/core/`. Other folders are builtin modules(you learn in next). 10 | 11 | Also there is a file named `src/pashmak.py`. This file is Pashmak interpreter main command line entry point. 12 | 13 | Also there is other folders: 14 | 15 | - `scripts/`: Project Automation scripts 16 | - `examples/`: Only some examples for Pashmak 17 | 18 | In the `doc/` Folder, Structure of documentation is this: 19 | 20 | ``` 21 | doc/ 22 | 00_first_part/ 23 | README.md: index 24 | 00_a.md 25 | 01_b.md 26 | ... 27 | 01_second_part/ 28 | ... 29 | ``` 30 | -------------------------------------------------------------------------------- /tests/pit/test.html: -------------------------------------------------------------------------------- 1 | { 2 | $name = 'parsa' 3 | 4 | import @sys # only test that import works 5 | 6 | func hello() 7 | return 'hello world' 8 | endfunc 9 | } 10 | 11 | 12 | 13 | 14 | Document 15 | 16 | 17 | hello {{ $name }} 18 | something: {= 'hi' } 19 | {{ hello() }} 20 | {= 'hello \{\}' } 21 | { print('the \{\}') } 22 | 23 | { if False } 24 |
Hello!
25 | { endif } 26 | 27 | { if 10 > 5 } 28 |
test!
29 | { endif } 30 | 31 | { $i = 0; while $i < 10 } 32 |
{{ $i }}
33 | { $i = $i + 1; endwhile } 34 | { pit.include($__htmldir__ + '/other.html') } 35 | { pit.include($__htmldir__ + '/other.html', \{'foo': 'bar'\}) } 36 | 37 | -------------------------------------------------------------------------------- /doc/11_advance/07_shutdown_event.md: -------------------------------------------------------------------------------- 1 | # Shutdown event 2 | Shutdown event is a system to set some functions to be runed in end of program. 3 | 4 | For example: 5 | 6 | ```bash 7 | # this function will be runed in the end of program 8 | func the_end 9 | println('The end') 10 | endfunc 11 | 12 | # register this function to shutdown event 13 | register_shutdown(the_end) 14 | 15 | println('hello') 16 | println('world') 17 | ``` 18 | 19 | output: 20 | 21 | ``` 22 | hello 23 | world 24 | the end 25 | ``` 26 | 27 | In the above example, we used `register_shutdown` function to set function `the_end` as shutdown event. this function will be runed in the end of program. 28 | 29 | Also you can set more than 1 function: 30 | 31 | ```bash 32 | func end1 33 | println('first end') 34 | endfunc 35 | 36 | func end2 37 | println('second end') 38 | endfunc 39 | 40 | register_shutdown(end1) 41 | register_shutdown(end2) 42 | ``` 43 | 44 | output: 45 | 46 | ``` 47 | first end 48 | second end 49 | ``` 50 | -------------------------------------------------------------------------------- /doc/10_modules/17_python_standard_modules.md: -------------------------------------------------------------------------------- 1 | # Python standard modules 2 | you can use this python standard modules in pashmak directly in your code: 3 | 4 | - `os` 5 | - `sys` 6 | - `time` 7 | - `hashlib` 8 | - `random` 9 | - `datetime` 10 | - `json` 11 | - `http` 12 | - `base64` 13 | - `socket` 14 | - `socketserver` 15 | - `math` 16 | - `pprint` 17 | - `subprocess` 18 | - `sqlite3` 19 | - `urllib` 20 | - `platform` 21 | - `mimetypes` 22 | - `re` 23 | - `pickle` 24 | 25 | for example: 26 | 27 | ```bash 28 | println(os.getuid()) 29 | println(random.random()) 30 | println('hash is ' + hashlib.sha256('hello'.encode()).hexdigest()) 31 | $cwd = os.getcwd() 32 | $time = time.time() - 100 33 | # ... 34 | ``` 35 | 36 | this is very useful! 37 | 38 | Also you can use `py_load_module` function. 39 | if you want to import a module that not imported by default, you can use this function. 40 | 41 | Example: 42 | 43 | ```bash 44 | $module = py_load_module('module_name') 45 | $module->func_1() 46 | # ... 47 | ``` 48 | 49 | -------------------------------------------------------------------------------- /src/helloworld/__init__.pashm: -------------------------------------------------------------------------------- 1 | # 2 | # __init__.pashm 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | if $__ismain__ 24 | println('Hello world!') 25 | endif 26 | -------------------------------------------------------------------------------- /src/serve/__init__.pashm: -------------------------------------------------------------------------------- 1 | # 2 | # __init__.pashm 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | if $__ismain__ 24 | import_run @web.server 25 | endfunc 26 | 27 | -------------------------------------------------------------------------------- /doc/11_advance/12_cloning_objects.md: -------------------------------------------------------------------------------- 1 | # Cloning objects 2 | If you put a object into other variables, that will be pointer to original variable. 3 | 4 | Look at this example: 5 | 6 | ```bash 7 | $a = {'foo': 'bar'} # a dictionary 8 | $b = $a 9 | 10 | println($a['foo']) # `bar` 11 | println($b['foo']) # `bar` 12 | 13 | # we change `$b`: 14 | $b['foo'] = 'new' 15 | 16 | println($b['foo']) # `new` 17 | 18 | println($a['foo']) # `new`! 19 | ``` 20 | 21 | In the above example, why after changing `$b`, also `$a` was changed? Because we put `$a` into `$b`. now, `$b` points to real `$a`.(means it is not a copy). 22 | 23 | But how to clone objects? We should use `clone` function: 24 | 25 | 26 | ```bash 27 | $a = {'foo': 'bar'} # a dictionary 28 | 29 | # using clone function 30 | $b = clone($a) 31 | 32 | println($a['foo']) # `bar` 33 | println($b['foo']) # `bar` 34 | 35 | # we change `$b`: 36 | $b['foo'] = 'new' 37 | 38 | println($b['foo']) # `new` 39 | 40 | println($a['foo']) # `bar` (the old value) 41 | ``` 42 | 43 | -------------------------------------------------------------------------------- /examples/ask_name.pashm: -------------------------------------------------------------------------------- 1 | # 2 | # ask_name.pashm 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | print('what is your name? ') 24 | $name = read() 25 | println('hello ' + $name) 26 | -------------------------------------------------------------------------------- /doc/10_modules/01_hash.md: -------------------------------------------------------------------------------- 1 | # hash module 2 | with hash module, you can calculate hash sum of values: 3 | 4 | ```bash 5 | import @hash 6 | 7 | hash.sha256("hello") # also you can use hash.md5 and... 8 | println(^) # output: 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 9 | # OR 10 | println(hash.sha256("hello")) 11 | ``` 12 | 13 | ### how it works? 14 | first, we call `hash.sha256` and pass `hello` string as argument (or put it in mem) to calculate sha256 hash. then, this function calculates hash sum of mem value and puts that into the mem. now you can access sum of that from mem. 15 | 16 | ### another hash algos 17 | - hash.blake2b(string) 18 | - hash.blake2s(string) 19 | - hash.md5(string) 20 | - hash.sha1(string) 21 | - hash.sha224(string) 22 | - hash.sha256(string) 23 | - hash.sha384(string) 24 | - hash.sha3_224(string) 25 | - hash.sha3_256(string) 26 | - hash.sha3_384(string) 27 | - hash.sha3_512(string) 28 | - hash.sha512(string) 29 | - hash.shake_128(string, length) 30 | - hash.shake_256(string, length) 31 | -------------------------------------------------------------------------------- /tests/stdlib/assert/0.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 0.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | assert function raises error when value is False 25 | --file-- 26 | assert 2 == 3 27 | --with-error-- 28 | 'AssertError' -------------------------------------------------------------------------------- /tests/sys/001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # sys.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | sys module works 25 | 26 | --file-- 27 | import @sys 28 | 29 | println(sys.path.list()) 30 | 31 | sys.path.add('/tmp') 32 | -------------------------------------------------------------------------------- /tests/eval/eval.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # eval.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | eval command working 25 | 26 | --file-- 27 | eval 'print "hello from eval"' 28 | 29 | --output-- 30 | 'hello from eval' 31 | -------------------------------------------------------------------------------- /tests/module/import/bug001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # bug001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | import command with () and @module without quotes 25 | 26 | --file-- 27 | import (@sys,@test, @hash ,@time) 28 | -------------------------------------------------------------------------------- /tests/stdlib/assert/1.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 1.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | assert function raises error when value is False (2) 25 | --file-- 26 | assert 1 > 10 27 | --with-error-- 28 | 'AssertError' -------------------------------------------------------------------------------- /tests/stdlib/assert/2.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 2.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | assert function raises error when value is False (3) 25 | --file-- 26 | assert False 27 | --with-error-- 28 | 'AssertError' -------------------------------------------------------------------------------- /tests/core/syntax006.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # syntax006.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | endtry without opened block raises error 25 | 26 | --file-- 27 | endtry 28 | 29 | --with-error-- 30 | "SyntaxError" 31 | -------------------------------------------------------------------------------- /tests/io/print.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # print.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | print functions working 25 | 26 | --file-- 27 | println 'hello' 28 | print 'hello' 29 | 30 | --output-- 31 | 'hello\nhello' 32 | -------------------------------------------------------------------------------- /tests/stdlib/exit1.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # exit1.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | stdlib exit function exits with default exit code 25 | 26 | --file-- 27 | 28 | exit 29 | 30 | --exit-code-- 31 | 32 | 0 33 | -------------------------------------------------------------------------------- /tests/core/syntax0.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # syntax0.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | syntax space handling working 25 | --file-- 26 | 27 | print 'hello world' 28 | 29 | --output-- 30 | 31 | "hello world" 32 | -------------------------------------------------------------------------------- /tests/core/syntax003.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # syntax003.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | endfunc without opened block raises error 25 | 26 | --file-- 27 | endfunc 28 | 29 | --with-error-- 30 | "SyntaxError" 31 | -------------------------------------------------------------------------------- /tests/core/syntax004.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # syntax004.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | endclass without opened block raises error 25 | 26 | --file-- 27 | endclass 28 | 29 | --with-error-- 30 | "SyntaxError" 31 | -------------------------------------------------------------------------------- /tests/io/read/0.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 0.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | read command working without argument 25 | 26 | --file-- 27 | read 28 | 29 | --stdin-- 30 | ['test'] 31 | 32 | --mem-- 33 | 'test' 34 | -------------------------------------------------------------------------------- /tests/io/read/5.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 5.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | read command can read value on mem 25 | 26 | --file-- 27 | read 28 | 29 | --stdin-- 30 | ['pashmak'] 31 | 32 | --mem-- 33 | 'pashmak' 34 | -------------------------------------------------------------------------------- /tests/stdlib/example1.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # example1.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | Example test for stdlib (2) 25 | 26 | --file-- 27 | 28 | print 'hello ' + $name 29 | 30 | --with-error-- 31 | 'VariableError' -------------------------------------------------------------------------------- /tests/stdlib/exit0.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # exit0.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | stdlib exit function exits with specify exit code 25 | 26 | --file-- 27 | 28 | exit 5 29 | 30 | --exit-code-- 31 | 32 | 5 33 | -------------------------------------------------------------------------------- /tests/examples/array.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # array.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | Test array example 25 | --file-- 26 | import 'examples/array.pashm' 27 | 28 | --output-- 29 | 30 | 'parsa\npashmak\nsomething\n' 31 | -------------------------------------------------------------------------------- /doc/08_class_and_oop/05_complicated_declaration.md: -------------------------------------------------------------------------------- 1 | # Complicated class declaration 2 | You can declare class-in-class (like functions). 3 | 4 | Look at this example: 5 | 6 | ```bash 7 | class Foo 8 | $name = 'the foo' 9 | 10 | class Bar 11 | $name = 'the bar' 12 | endclass 13 | endclass 14 | 15 | println(Foo()->name) 16 | println(Bar()->name) 17 | ``` 18 | 19 | output: 20 | 21 | ``` 22 | the foo 23 | the bar 24 | ``` 25 | 26 | Also look at this example: 27 | 28 | ```bash 29 | class First 30 | $name = 'first' 31 | class Second 32 | $name = 'second' 33 | 34 | class Last 35 | $name = 'last' 36 | endclass 37 | 38 | class Person 39 | $name = 'person' 40 | endclass 41 | endclass 42 | 43 | $the_second = Second() 44 | endclass 45 | 46 | println(First()->name) 47 | println(Second()->name) 48 | println(Last()->name) 49 | println(Person()->name) 50 | 51 | println(First()->the_second->name) 52 | ``` 53 | 54 | output: 55 | 56 | ``` 57 | first 58 | second 59 | last 60 | person 61 | second 62 | ``` 63 | -------------------------------------------------------------------------------- /tests/core/syntax005.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # syntax005.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | endnamespace without opened block raises error 25 | 26 | --file-- 27 | endnamespace 28 | 29 | --with-error-- 30 | "SyntaxError" 31 | -------------------------------------------------------------------------------- /tests/function/undefined_func.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # undefined_func.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | program raises error while calling undefined function 25 | --file-- 26 | undefined_func 27 | --with-error-- 28 | 'NameError' -------------------------------------------------------------------------------- /tests/section/error2.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # error2.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | section system raises error while trying to goto not founded section 25 | --file-- 26 | goto not_found 27 | --with-error-- 28 | 'SectionError' -------------------------------------------------------------------------------- /tests/stdlib/assert/3.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 3.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | assert function raises error when value is False (4) 25 | --file-- 26 | $age = 18 27 | assert $age > 30 28 | --with-error-- 29 | 'AssertError' -------------------------------------------------------------------------------- /tests/stdlib/eval.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # eval.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | stdlib eval function working 25 | --file-- 26 | 27 | eval "print 'output from eval'" 28 | 29 | --output-- 30 | 31 | 'output from eval' 32 | -------------------------------------------------------------------------------- /tests/tryendtry/error2.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # error2.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | try command raises syntax error correctly 25 | 26 | --file-- 27 | try; gfdhghgfhf; endtry 28 | 29 | --with-error-- 30 | 'ArgumentError' -------------------------------------------------------------------------------- /tests/array/pop.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # pop.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | $array->pop() works 25 | --file-- 26 | $names = ['pashmak', 'parsa'] 27 | $names->pop(1) 28 | println($names) 29 | --output-- 30 | "['pashmak']\n" 31 | -------------------------------------------------------------------------------- /tests/module/import/error_2.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # error_2.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | import command raises error when variable not found 25 | --file-- 26 | import $not_found 27 | --with-error-- 28 | 'VariableError' 29 | -------------------------------------------------------------------------------- /tests/section/error3.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # error3.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | section system raises error while trying to gotoif not founded section 25 | --file-- 26 | gotoif not_found 27 | --with-error-- 28 | 'SectionError' -------------------------------------------------------------------------------- /examples/will_be_include.pashm: -------------------------------------------------------------------------------- 1 | # 2 | # will_be_include.pashm 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | println('i am included') 24 | 25 | $included_var = 'included value' 26 | 27 | func testfunc() 28 | println('i am included func') 29 | endfunc 30 | -------------------------------------------------------------------------------- /tests/module/import/error_3.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # error_3.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | import command raises error when argument syntax is not valid 25 | --file-- 26 | import hhghgjghj 27 | --with-error-- 28 | 'NameError' 29 | -------------------------------------------------------------------------------- /tests/stdlib/die-bug-001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # die-bug-001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | die() message can be non string 25 | 26 | --file-- 27 | 28 | die([ 29 | 'a', 'b' 30 | ]) 31 | 32 | --output--' 33 | "['a', 'b']" 34 | -------------------------------------------------------------------------------- /tests/stdlib/raise.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # raise.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | stdlib raise function raises error 25 | 26 | --file-- 27 | 28 | raise(Error('SomeError', 'this is error')) 29 | 30 | --with-error-- 31 | 'SomeError' -------------------------------------------------------------------------------- /tests/core/null.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # null.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | keyword `null` working correct 25 | 26 | --file-- 27 | 28 | println(null == None) 29 | println(null is None) 30 | 31 | --output-- 32 | """True 33 | True 34 | """ -------------------------------------------------------------------------------- /tests/module/import/bug002.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # bug002.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | parser parses import_once command like import command 25 | 26 | --file-- 27 | 28 | import_once @hash, @time 29 | import_once(@random ,@stdlib) 30 | -------------------------------------------------------------------------------- /tests/stdlib/import.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # import.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | stdlib import function working 25 | 26 | --file-- 27 | 28 | import "examples/will_be_include.pashm" 29 | 30 | --output-- 31 | 32 | 'i am included\n' 33 | -------------------------------------------------------------------------------- /tests/tryendtry/error3.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # error3.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | try command raises error when argment section is not found 25 | --file-- 26 | try somesection; gfdhghgfhf; endtry 27 | --with-error-- 28 | 'SectionError' -------------------------------------------------------------------------------- /tests/io/read/3.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 3.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | read command can read data and put it in a variable 25 | --file-- 26 | $input = read(); print $input 27 | --stdin-- 28 | ['pashmak'] 29 | --output-- 30 | 'pashmak' 31 | -------------------------------------------------------------------------------- /tests/core/runtime_error.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # runtime_error.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | runtime error is raising when there is syntax error 25 | 26 | --file-- 27 | 28 | mem 'hello world; print ^ 29 | 30 | --with-error-- 31 | 'SyntaxError' -------------------------------------------------------------------------------- /tests/core/syntax1.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # syntax1.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | syntax comments working 25 | 26 | --file-- 27 | 28 | # some comment 29 | print 'hello world' # another comment 30 | 31 | --output-- 32 | 33 | "hello world" 34 | -------------------------------------------------------------------------------- /tests/function/bug001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # bug001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | using empty () while declaring function bug 25 | 26 | --file-- 27 | func hi() 28 | println 'hello' 29 | endfunc 30 | 31 | hi() 32 | 33 | --output-- 34 | "hello\n" -------------------------------------------------------------------------------- /tests/stdlib/eval-bug001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # eval-bug001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | eval command frame bug is fixed 25 | 26 | --file-- 27 | $name = 'parsa' 28 | eval 'println "hello " + $name' 29 | 30 | --output-- 31 | 'hello parsa\n' 32 | -------------------------------------------------------------------------------- /tests/test-module/1.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 1.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | test module assertTrue function raises error when value is False 25 | --file-- 26 | import '@test' 27 | test.assertTrue 3 == 7 28 | --with-error-- 29 | 'AssertError' 30 | -------------------------------------------------------------------------------- /tests/test-module/2.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 2.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | test module assertFalse function raises error when value is True 25 | --file-- 26 | import '@test' 27 | test.assertFalse 2 == 2 28 | --with-error-- 29 | 'AssertError' 30 | -------------------------------------------------------------------------------- /src/sys/__init__.pashm: -------------------------------------------------------------------------------- 1 | # 2 | # sys.pashm 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | import @sys.path 24 | 25 | namespace sys 26 | $pashmakinfo = {"version": version.version, "pythoninfo": sys.version.replace("\\n", "")} 27 | $pashmakexe = sys.argv[0] 28 | endns 29 | -------------------------------------------------------------------------------- /tests/test-module/3.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 3.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | test module assertEquals function raises error when condition is False 25 | --file-- 26 | import '@test' 27 | test.assertEquals 2, 8 28 | --with-error-- 29 | 'AssertError' 30 | -------------------------------------------------------------------------------- /tests/module/import/module_not_found_error.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # module_not_found_error.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | include command raises error when module not found 25 | --file-- 26 | import '@notfound233445' 27 | --with-error-- 28 | 'ModuleError' 29 | -------------------------------------------------------------------------------- /tests/module/import/multi-import-2.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # multi-import-2.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | multi import syntax works 25 | --file-- 26 | import @sys,@time ,@test, @hash 27 | import @sys,@time,@test,@hash 28 | import @sys,@time ,@test, @hash 29 | -------------------------------------------------------------------------------- /tests/test-module/4.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 4.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | test module assertNotEquals function raises error when condition is True 25 | --file-- 26 | import '@test' 27 | test.assertNotEquals 2, 2 28 | --with-error-- 29 | 'AssertError' 30 | -------------------------------------------------------------------------------- /tests/module/import/bug006.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # bug006.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | import command () syntax bug is fixed 25 | 26 | --file-- 27 | 28 | func hello() 29 | return '@os' 30 | endfunc 31 | 32 | import hello() 33 | import(hello()) 34 | 35 | -------------------------------------------------------------------------------- /tests/classes/004-syntax-error.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 004-syntax-error.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | class raises error when body codes has syntax error 25 | --file-- 26 | class Foo 27 | $name 28 | gdfghfjh 29 | endclass 30 | --with-error-- 31 | 'NameError' -------------------------------------------------------------------------------- /tests/consts/002.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 002.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | consts working with namespaces 25 | --file-- 26 | namespace app 27 | $&thevar = 'hello world' 28 | endns 29 | 30 | $app.&thevar = 'new value' 31 | 32 | --with-error-- 33 | 'ConstError' -------------------------------------------------------------------------------- /tests/core/literals-error-in-names002.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # literals-error-in-names002.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | class name cannot have literal chars 25 | 26 | --file-- 27 | class Pe[rs)o*n 28 | 29 | endclass 30 | 31 | --with-error-- 32 | "SyntaxError" 33 | -------------------------------------------------------------------------------- /tests/core/literals-error-in-names003.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # literals-error-in-names003.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | function name cannot have literal chars 25 | 26 | --file-- 27 | func myf.u{nc 28 | 29 | endfunc 30 | 31 | --with-error-- 32 | "SyntaxError" 33 | -------------------------------------------------------------------------------- /tests/module/import/1.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 1.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | import command is working with variable as argument 25 | 26 | --file-- 27 | $path = 'examples/will_be_include.pashm' 28 | import $path; 29 | 30 | --output-- 31 | 'i am included\n' 32 | -------------------------------------------------------------------------------- /tests/stdlib/die001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # die001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | function die() works (1) 25 | 26 | --file-- 27 | 28 | println('A') 29 | 30 | die() 31 | 32 | println('B') 33 | 34 | --output-- 35 | """A 36 | """ 37 | 38 | --exit-code-- 39 | 1 40 | -------------------------------------------------------------------------------- /tests/time/001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # time.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | ime module is working 25 | --file-- 26 | import '@time' 27 | time.time 28 | time.sleep 0.01 29 | time.ctime 30 | time.gmtime 31 | time.localtime 32 | # ONLY NEEDS TO BE RUNED WITHOUT ERROR 33 | -------------------------------------------------------------------------------- /logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 9 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /tests/array/append.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # append.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | $array->append() works 25 | 26 | --file-- 27 | $names = ['pashmak', 'parsa'] 28 | $names->append('newname') 29 | println($names) 30 | --output-- 31 | "['pashmak', 'parsa', 'newname']\n" 32 | -------------------------------------------------------------------------------- /tests/core/literals-error-in-names001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # literals-error-in-names001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | namespace name cannot have literal chars 25 | 26 | --file-- 27 | namespace Hel.%h{lo 28 | 29 | endns 30 | 31 | --with-error-- 32 | "SyntaxError" 33 | -------------------------------------------------------------------------------- /tests/if/003-without-endif.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 003-without-endif.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | program will not be crashed when if block is not close 25 | 26 | --file-- 27 | if True 28 | print 'yes' 29 | else 30 | print 'no' 31 | 32 | --output-- 33 | 'yes' -------------------------------------------------------------------------------- /tests/module/import/bug003.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # bug003.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | directory import bug is fixed 25 | 26 | --file-- 27 | 28 | import $__dir__ + '/tests/test-module-path/somedir' 29 | 30 | --output-- 31 | """I am a imported directory 32 | """ 33 | -------------------------------------------------------------------------------- /tests/module/path/error0.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # error0.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | module path system without any path working 25 | --pyinit-- 26 | import os 27 | os.environ['PASHMAKINFO'] = '' 28 | --file-- 29 | import '@testdir1' 30 | --with-error-- 31 | 'ModuleError' -------------------------------------------------------------------------------- /src/core/version.py: -------------------------------------------------------------------------------- 1 | # 2 | # version.py 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | """ Version of pashmak """ 24 | 25 | # pashmak version 26 | # while you are releasing new version, 27 | # you should bump it 28 | # also this will put version into $sys.pashmakinfo['version'] 29 | version = 'v0.7.3' 30 | -------------------------------------------------------------------------------- /tests/cli_args/argv.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # argv.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | The $argv variable has correct value 25 | 26 | --file-- 27 | print($argv[0]) 28 | print($argv[1]) 29 | print($argc) 30 | 31 | --cliargs-- 32 | ['hi', 'bye'] 33 | 34 | --output-- 35 | 'hibye2' 36 | -------------------------------------------------------------------------------- /tests/test-module-path/foo.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # foo.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | script returned value will be returned by import() 25 | 26 | --file-- 27 | 28 | println import_once($__dir__ + '/tests/test-module-path/bar.pashm') 29 | 30 | --output-- 31 | "parsa\n" 32 | -------------------------------------------------------------------------------- /doc/12_web/02_env_vars.md: -------------------------------------------------------------------------------- 1 | # Environment variables in web 2 | There is some environment variables in web system that will be passed to your script. 3 | 4 | This envvars contain some informations. 5 | 6 | | Name | Description | Example value | 7 | |------|-------------|---------------| 8 | | `REQUEST_URI` | The requested uri | `/foo/bar` | 9 | | `REQUEST_METHOD` | The http request method | `GET` or `POST` | 10 | | `REMOTE_ADDR` | The remote(client) address(ip) | `1.2.3.4` | 11 | | `REMOTE_PORT` | The remote port | `5674` | 12 | | `SERVER_ADDR` | Address of the server | `127.0.0.1` | 13 | | `SERVER_PORT` | The server port | `80` or `8000` | 14 | | `SERVER_PROTOCOL` | The server protocol | `HTTP/1.0` | 15 | | `DOCUMENT_ROOT` | The root of directory that web server serves that | `/var/www/html` | 16 | | `SCRIPT_FILENAME` | Real path of the current running Pashmak script | `/var/www/html/app.pashm` | 17 | | `SCRIPT_NAME` | Script name (not full path) | `/app.pashm` | 18 | | `QUERY_STRING` | Part of URL after `?` (The get data raw query string. use `$web.get`) | `foo=bar&hi=bye` | 19 | | `POST_RAW_DATA` | The raw post data (use `$web.post`) | `foo=bar&hi=bye` | 20 | -------------------------------------------------------------------------------- /tests/classes/inheritance002.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # inheritance002.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | undefined class error will be raised when parent class not found 25 | 26 | --file-- 27 | 28 | class Test < Undefined 29 | endclass 30 | 31 | --with-error-- 32 | "ClassError" 33 | -------------------------------------------------------------------------------- /tests/module/import/bug003-2.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # bug003-2.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | directory without `__init__.pashm` cannot be imported 25 | 26 | --file-- 27 | 28 | import $__dir__ + '/tests/test-module-path/somedir/dir2' 29 | 30 | --with-error-- 31 | "FileError" 32 | -------------------------------------------------------------------------------- /tests/variables/isset.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # isset.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | isset command is working 25 | 26 | --file-- 27 | 28 | println(isset('name')) 29 | 30 | $name = 'parsa' 31 | 32 | println(isset('name')) 33 | 34 | --output-- 35 | """False 36 | True 37 | """ 38 | -------------------------------------------------------------------------------- /examples/handle_error.pashm: -------------------------------------------------------------------------------- 1 | # 2 | # handle_error.pashm 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | try handle_error 24 | println('A') 25 | fghgfhg 26 | println('B') 27 | endtry 28 | 29 | goto after_handle_error; section handle_error 30 | println('the error!') 31 | section after_handle_error 32 | -------------------------------------------------------------------------------- /tests/classes/super-functions-002.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # super-functions-002.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | func.delete function raises error when function not found 25 | 26 | --file-- 27 | 28 | func.delete('test_not_found_function') 29 | 30 | --with-error-- 31 | "FunctionNotFound" -------------------------------------------------------------------------------- /tests/function/super-functions-002.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # super-functions-002.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | func.delete function raises error when function not found 25 | 26 | --file-- 27 | 28 | func.delete('test_not_found_function') 29 | 30 | --with-error-- 31 | "FunctionNotFound" -------------------------------------------------------------------------------- /tests/stdlib/example0.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # example0.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | Example test for stdlib for printing 25 | 26 | --file-- 27 | 28 | $name = 'parsa' 29 | print 'hello ' + $name 30 | print str(2*2) + ' is sum' 31 | 32 | --output-- 33 | 34 | 'hello parsa4 is sum' 35 | -------------------------------------------------------------------------------- /doc/00_basics/03_constants.md: -------------------------------------------------------------------------------- 1 | # Constants 2 | Constants (consts) are even like variables, but one thing is different in constants, **Constant value cannot be changed**. 3 | 4 | for example: 5 | 6 | ```bash 7 | # declare the const 8 | $&name = 'the value' 9 | 10 | println($&name) 11 | ``` 12 | 13 | output: 14 | 15 | ``` 16 | the value 17 | ``` 18 | 19 | To declare consts, you only need to put a `&` in the name of variable(location of that is not important). 20 | 21 | ```bash 22 | $&const1 = 123 23 | $&const2 = 'fsgdf' 24 | # ... 25 | ``` 26 | 27 | When we try to change value of the const, we will get error: 28 | 29 | ```bash 30 | $&name = 'the name' 31 | 32 | $&name = 'new value' 33 | ``` 34 | 35 | output: 36 | 37 | ``` 38 | ConstError: "$&name" is const and cannot be changed... 39 | ``` 40 | 41 | also you can **declare** a constant, but set value of that later. 42 | 43 | for example: 44 | 45 | ```bash 46 | $&name # only declare constant, default value is `None` 47 | 48 | # set value 49 | $&name = 'parsa' 50 | 51 | println($&name) 52 | ``` 53 | 54 | output: 55 | 56 | ``` 57 | parsa 58 | ``` 59 | 60 | But in the second time, error will be raised. 61 | -------------------------------------------------------------------------------- /doc/07_files/00_working_with_files.md: -------------------------------------------------------------------------------- 1 | # Working with files 2 | working with files in Pashmak is so easy. 3 | 4 | we have 4 main operations on files: Open, Read, Write, Close 5 | 6 | look at this example for reading content of a file: 7 | 8 | ```bash 9 | $my_file = open('/path/to/some/file.txt', 'r') 10 | println($my_file->read()) 11 | $my_file->close() 12 | ``` 13 | 14 | In above example, we opened our file, read content and then we closed that. 15 | 16 | the `$file->read()`, the `read` method reads content of file and returns that. 17 | 18 | you can put that in a variable: 19 | 20 | ```bash 21 | $content = $file->read() 22 | ``` 23 | 24 | to write content of a file, we can use `write` method: 25 | 26 | ```bash 27 | $my_file = open('/path/to/some/file.txt', 'w') 28 | $my_file->write('new content') 29 | $my_file->close() 30 | ``` 31 | 32 | The second argument for opening file is type of opening. `r` means Read and `w` means write. 33 | 34 | Also you can use `fopen` function instead of `open`. this is not different, just is an alias. 35 | 36 | The file objects in Pashmak are handled by python you can use all of python file features in Pashmak like python. 37 | -------------------------------------------------------------------------------- /doc/10_modules/02_time.md: -------------------------------------------------------------------------------- 1 | # time module 2 | with this module, you can work with time. 3 | 4 | ### time.time 5 | this function gives you current UNIX timestamp: 6 | 7 | ```bash 8 | import @time 9 | 10 | println(time.time()) # output is some thing like this: `1600416438.687201` 11 | ``` 12 | 13 | when you call this function, this function puts the unix timestamp into mem and you can access and use that. 14 | 15 | ### time.sleep 16 | this function sleeps for secounds: 17 | 18 | ```bash 19 | import @time 20 | 21 | time.sleep(2) # sleeps for 2 secounds 22 | # mem 2.4; time.sleep; # sleepss for 2.4 secounds 23 | ``` 24 | 25 | when you run this script, program waits for 2 secounds and then will continued 26 | 27 | with this function, you can wait for secounds. 28 | 29 | you have to put a int or float into mem or pass as argument and next call `time.sleep` function, then program will sleep for value of `mem` as secounds 30 | 31 | ### Another time functions 32 | - time.ctime 33 | - time.gmtime 34 | - time.localtime 35 | 36 | ### cli usage 37 | You can use this module in command line to see current UNIX timestamp: 38 | 39 | ```bash 40 | $ pashmak @time 41 | ``` 42 | -------------------------------------------------------------------------------- /tests/classes/method003.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # method003.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | system raises error when trying to call a method on non-class object 25 | 26 | --file-- 27 | 28 | $p = 'some string' 29 | 30 | mem $p->somemethod() 31 | 32 | --with-error-- 33 | 'AttributeError' 34 | -------------------------------------------------------------------------------- /tests/function/func_arg_variable.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # func_arg_variable.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | functions argument variable is working 25 | 26 | --file-- 27 | func say_hi($name) 28 | println $name 29 | endfunc 30 | 31 | say_hi 'parsa' 32 | 33 | --output-- 34 | 'parsa\n' 35 | -------------------------------------------------------------------------------- /tests/function/return002.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # return002.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | return command exits program when is used in main program frame 25 | 26 | --file-- 27 | print 'first' 28 | return 100 29 | print 'last' 30 | 31 | --output-- 32 | 'first' 33 | 34 | --exit-code-- 35 | 100 -------------------------------------------------------------------------------- /tests/module/import/bug004.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # bug004.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | module variable conflicting bug is fixed 25 | 26 | --file-- 27 | 28 | func hello() 29 | import @sys 30 | println($sys.pashmakinfo['version']) 31 | endfunc 32 | 33 | hello() 34 | hello() 35 | -------------------------------------------------------------------------------- /tests/stdlib/py-load-module-001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # py-load-module-001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | function py_load_module() works 25 | 26 | --file-- 27 | 28 | $uuid = py_load_module('uuid') 29 | 30 | println $uuid->UUID 31 | 32 | --output-- 33 | "\n" 34 | 35 | -------------------------------------------------------------------------------- /tests/consts/001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | consts working correct 25 | 26 | --file-- 27 | $&name = 'hello world' 28 | 29 | println $&name 30 | 31 | $&name = 'new value' 32 | 33 | --output-- 34 | """hello world 35 | """ 36 | 37 | --with-error-- 38 | 'ConstError' -------------------------------------------------------------------------------- /tests/module/import/example_hash_module.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # example_hash_module.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | modules can be imported 25 | --file-- 26 | import @hash 27 | hash.sha256 'hello'; print ^ 28 | --output-- 29 | '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824' 30 | -------------------------------------------------------------------------------- /tests/stdlib/die002.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # die002.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | function die() works (2) 25 | 26 | --file-- 27 | 28 | println('A') 29 | 30 | die("Good bye\n") 31 | 32 | println('B') 33 | 34 | --output-- 35 | """A 36 | Good bye 37 | """ 38 | 39 | --exit-code-- 40 | 1 41 | -------------------------------------------------------------------------------- /tests/stdlib/var_dump-001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # var_dump-001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | function var_dump() works correct 25 | 26 | --file-- 27 | 28 | $name = 'pashmak' 29 | 30 | var_dump($name) 31 | 32 | var_dump('other value') 33 | 34 | --output-- 35 | "'pashmak'\n'other value'\n" 36 | -------------------------------------------------------------------------------- /tests/classes/014-super-error.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 014-super-error.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | super() raises error when parent not exists 25 | 26 | --file-- 27 | 28 | class Test 29 | endclass 30 | 31 | $a = Test() 32 | 33 | $a->super('Something') 34 | 35 | --with-error-- 36 | "SuperError" -------------------------------------------------------------------------------- /tests/classes/method-bug-001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # method-bug-001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | method not found error bug is fixed 25 | 26 | --file-- 27 | 28 | class Hello 29 | endclass 30 | 31 | $a = Hello() 32 | 33 | mem $a->ffghfgjghjh() 34 | 35 | --with-error-- 36 | "AttributeError" 37 | -------------------------------------------------------------------------------- /tests/eval/eval2.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # eval2.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | eval function do not creates new frame and runs on current frame 25 | 26 | --file-- 27 | $name = 'hi' 28 | println $name 29 | eval "$name = 'the new'" 30 | println $name 31 | 32 | --output-- 33 | """hi 34 | the new 35 | """ -------------------------------------------------------------------------------- /tests/examples/get_password1.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # get_password1.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | Test get password example with valid password 25 | 26 | --file-- 27 | import 'examples/get_password.pashm' 28 | 29 | --stdin-- 30 | ['123'] 31 | 32 | --output-- 33 | 'enter the password: WELCOME!\n' 34 | -------------------------------------------------------------------------------- /tests/namespace/bug002.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # bug002.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | $__dir__, $__file__ and $__ismain__ variables bug in namespace is fixed 25 | 26 | --file-- 27 | 28 | func hi() 29 | endfunc 30 | 31 | hi() 32 | 33 | ns app 34 | hi() 35 | 36 | endns 37 | 38 | --vars-- 39 | {} 40 | -------------------------------------------------------------------------------- /tests/section/0.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 0.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | section system is working as If structure 25 | --file-- 26 | println 'before start' 27 | goto 10 28 | println 'it will not show' 29 | section 10 30 | println 'this is end' 31 | --output-- 32 | 'before start\nthis is end\n' 33 | -------------------------------------------------------------------------------- /tests/stdlib/die003.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # die003.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | function die() works (2) 25 | 26 | --file-- 27 | 28 | println('A') 29 | 30 | die("Good bye\n", 11) 31 | 32 | println('B') 33 | 34 | --output-- 35 | """A 36 | Good bye 37 | """ 38 | 39 | --exit-code-- 40 | 11 41 | -------------------------------------------------------------------------------- /tests/stdlib/print.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # print.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | stdlib print/println/printl functions working 25 | --file-- 26 | 27 | print "hello world" 28 | println 'hello world' 29 | printl 'hello world' 30 | 31 | --output-- 32 | 33 | "hello worldhello world\nhello world\n" 34 | -------------------------------------------------------------------------------- /tests/consts/bug003.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # bug003.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | bug ignoring const error is fixed 25 | --file-- 26 | $&a = 'the var' 27 | 28 | println $&a 29 | 30 | $&a = 'new value' 31 | 32 | println $&a 33 | 34 | --output-- 35 | """the var 36 | """ 37 | --with-error-- 38 | 'ConstError' -------------------------------------------------------------------------------- /tests/eval/python.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # python.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | python exec system is working 25 | 26 | --file-- 27 | python("self.all_vars()['myvar'] = 'the value'") 28 | println($myvar) 29 | python("self.mem = 'the mem'") 30 | 31 | --output-- 32 | 'the value\n' 33 | --mem-- 34 | 'the mem' -------------------------------------------------------------------------------- /tests/function/func_multi_call.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # func_multi_call.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | functions can be called more than 1 time 25 | --file-- 26 | func myfunc() 27 | println 'func runed' 28 | endfunc 29 | 30 | myfunc 31 | myfunc() 32 | 33 | --output-- 34 | 'func runed\nfunc runed\n' 35 | -------------------------------------------------------------------------------- /tests/module/path/1.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 1.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | modules are loaded in module path system (2) 25 | --skip-- 26 | --file-- 27 | import @sys 28 | sys.path.add($__dir__ + '/tests/test-module-path') 29 | import @testdir2 30 | testdir2.run() 31 | --output-- 32 | 'hello testdir2\n' 33 | -------------------------------------------------------------------------------- /tests/consts/bug004.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # bug004.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | tests const can be declared but get value later 25 | 26 | --file-- 27 | 28 | $&name 29 | 30 | println $&name 31 | 32 | $&name = 'hello world' 33 | 34 | println $&name 35 | 36 | --output-- 37 | """None 38 | hello world 39 | """ -------------------------------------------------------------------------------- /tests/namespace/ns-alias.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # ns-alias.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | alias ns for namespace works 25 | 26 | --file-- 27 | 28 | ns app 29 | func hi() 30 | println 'hello world' 31 | endfunc 32 | endns 33 | 34 | app.hi() 35 | 36 | --output-- 37 | "hello world\n" 38 | 39 | -------------------------------------------------------------------------------- /tests/stdlib/gset.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # gset.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | stdlib gset function working 25 | 26 | --file-- 27 | $name = 'parsa' 28 | func myfunc() 29 | println $name 30 | gset 'name', 'pashmak' 31 | endfunc 32 | myfunc() 33 | println $name 34 | 35 | --output-- 36 | 'parsa\npashmak\n' 37 | -------------------------------------------------------------------------------- /tests/classes/007.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 007.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | constant property can be changed 25 | 26 | --file-- 27 | 28 | class Person 29 | $name 30 | endclass 31 | 32 | $&p = Person() 33 | 34 | $&p->name = 'hello world' 35 | 36 | println($&p->name) 37 | 38 | --output-- 39 | 'hello world\n' -------------------------------------------------------------------------------- /tests/function/func_error.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # func_error.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | function system raises error when function argument syntax is not valid 25 | 26 | --file-- 27 | 28 | func myfunc() 29 | print ^ 30 | endfunc 31 | 32 | myfunc hello world 33 | 34 | --with-error-- 35 | 'SyntaxError' 36 | -------------------------------------------------------------------------------- /tests/namespace/variable_in_ns.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # variable_in_ns.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | variables in namespaces working 25 | --file-- 26 | namespace App 27 | $name = 'parsa' 28 | print $name 29 | print $App.name 30 | endns 31 | print $App.name 32 | 33 | --output-- 34 | 'parsaparsaparsa' 35 | -------------------------------------------------------------------------------- /tests/stdlib/assert/assert_true.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # assert_true.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | assert function is ok when values are True 25 | --file-- 26 | assert True 27 | assert 2 == 2 28 | assert 100 > 50 29 | $age = 30 30 | assert $age > 18 31 | println 'success' 32 | 33 | --output-- 34 | 'success\n' 35 | -------------------------------------------------------------------------------- /tests/tryendtry/bug001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # bug001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | try endtry variable error bug is fixed 25 | 26 | --file-- 27 | 28 | try error 29 | mem $not 30 | endtry 31 | goto after_error; section error 32 | println('error') 33 | section after_error 34 | 35 | --output-- 36 | "error\n" 37 | -------------------------------------------------------------------------------- /tests/variables/copy.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # copy.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | copy command is working 25 | --file-- 26 | $name; $family; $age 27 | $name = 'parsa' 28 | $family = $name 29 | println($name) 30 | println($family) 31 | println($age) 32 | 33 | --output-- 34 | """parsa 35 | parsa 36 | None 37 | """ 38 | -------------------------------------------------------------------------------- /tests/io/read/4.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 4.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | read command can read more that one argument 25 | 26 | --file-- 27 | $input = read() 28 | print($input) 29 | 30 | $input_1 = read() 31 | print($input_1) 32 | 33 | --stdin-- 34 | ['pashmak', 'parsa'] 35 | 36 | --output-- 37 | 'pashmakparsa' 38 | -------------------------------------------------------------------------------- /tests/core/is-main-variable.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # is-main-variable.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | $__ismain__ variable has valid value 25 | 26 | --file-- 27 | println $__ismain__ 28 | import 'tests/test-module-path/is_main_test.pashm' 29 | println $__ismain__ 30 | 31 | --output-- 32 | """True 33 | False 34 | True 35 | """ -------------------------------------------------------------------------------- /tests/core/shutdown-event-bug001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # shutdown-event-bug001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | shutdown events will be called while using exit() 25 | 26 | --file-- 27 | 28 | func bye() 29 | println 'bye' 30 | endfunc 31 | 32 | register_shutdown(bye) 33 | 34 | exit() 35 | 36 | --output-- 37 | "bye\n" 38 | -------------------------------------------------------------------------------- /tests/module/import/multi_import/0.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 0.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | multiple import is working 25 | --file-- 26 | import '@hash', 'examples/will_be_include.pashm' 27 | hash.sha256 'hello'; print ^ 28 | --output-- 29 | 'i am included\n2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824' 30 | -------------------------------------------------------------------------------- /tests/random/001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # random.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | random module is working 25 | --file-- 26 | import "@random" 27 | random.randint(5,10) 28 | $rand = ^ 29 | assert($rand >= 5 and $rand <= 10) 30 | $r2 = random.random() 31 | assert($r2 < 1) 32 | random.seed(1000) 33 | println(random.getstate()) 34 | -------------------------------------------------------------------------------- /tests/variables/free0.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # free0.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | free function is working 25 | --file-- 26 | 27 | $name = 'parsa' 28 | 29 | println(isset('name')) 30 | 31 | free('name') 32 | 33 | println(isset('name')) 34 | 35 | free('not_found') 36 | 37 | --output-- 38 | """True 39 | False 40 | """ 41 | -------------------------------------------------------------------------------- /tests/examples/get_password0.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # get_password0.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | Test get password example with invalid password 25 | 26 | --file-- 27 | import 'examples/get_password.pashm' 28 | 29 | --stdin-- 30 | ['the-invalid-password'] 31 | 32 | --output-- 33 | 'enter the password: invalid password\n' 34 | -------------------------------------------------------------------------------- /tests/function/return001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # return001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | return command working correct 25 | --file-- 26 | func hello() 27 | println 'hello' 28 | return 'good bye' 29 | println 'world' 30 | endfunc 31 | 32 | hello 33 | print ^ 34 | 35 | --output-- 36 | """hello 37 | good bye""" 38 | -------------------------------------------------------------------------------- /tests/core/multiline.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # multiline.pashmt 3 | # 4 | # 5 | The Pashmak Project 6 | # Copyright 2020-2021 parsa shahmaleki 7 | # 8 | # This file is part of Pashmak. 9 | # 10 | # Pashmak is free software: you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation, either version 3 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # Pashmak is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with Pashmak. If not, see . 22 | ######################################################################### 23 | 24 | --test-- 25 | multiline syntax works 26 | 27 | --file-- 28 | 29 | println('hello\ 30 | world') 31 | 32 | println(\ 33 | 'this is a test\n\ 34 | new line'\ 35 | ) 36 | 37 | --output-- 38 | """hello world 39 | this is a test 40 | new line 41 | """ 42 | -------------------------------------------------------------------------------- /tests/function/return003.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # return003.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | 24 | --test-- 25 | return command works when have not argument 26 | --file-- 27 | func hello() 28 | print 'first' 29 | return 30 | print 'last' 31 | endfunc 32 | 33 | $r = hello() 34 | 35 | println $r 36 | 37 | --output-- 38 | 'firstNone\n' 39 | -------------------------------------------------------------------------------- /tests/io/read/6.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 6.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | read command can read multiple values in one command 25 | 26 | --file-- 27 | $var = read() 28 | $v2 = read() 29 | 30 | println($var) 31 | println($v2) 32 | 33 | --stdin-- 34 | ['pashmak', 'hello'] 35 | 36 | --output-- 37 | """pashmak 38 | hello 39 | """ 40 | -------------------------------------------------------------------------------- /tests/function/func_arg_variable2.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # func_arg_variable2.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | functions argument variable is working with parentheses 25 | 26 | --file-- 27 | func say_hi ($name) 28 | println $name 29 | endfunc 30 | say_hi 'parsa' 31 | say_hi('parsa') 32 | 33 | --output-- 34 | 35 | 'parsa\nparsa\n' 36 | -------------------------------------------------------------------------------- /tests/module/import/multi_import/2.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 2.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | multi import is working with brackets 25 | --file-- 26 | import('@hash', 'examples/will_be_include.pashm') 27 | hash.sha256 'hello'; print ^ 28 | --output-- 29 | 'i am included\n2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824' 30 | -------------------------------------------------------------------------------- /tests/module/path/0.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 0.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | modules are loaded in module path system 25 | --pyinit-- 26 | 27 | import os 28 | os.environ['PASHMAKPATH'] = os.getcwd() + '/tests/test-module-path' 29 | 30 | --file-- 31 | import '@testliba' 32 | testliba.run 33 | 34 | --output-- 35 | 'hello testliba\n' 36 | -------------------------------------------------------------------------------- /tests/namespace/namespace_variable_error.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # namespace_variable_error.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | namespace variable is declared inside namespace and is not accessible from outside 25 | --file-- 26 | namespace App 27 | $name = 'parsa' 28 | endns 29 | print $name 30 | 31 | --with-error-- 32 | 'VariableError' 33 | -------------------------------------------------------------------------------- /tests/core/set-get-functions.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # set-get-functions.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | `set()` and `get()` functions working correctly 25 | 26 | --file-- 27 | 28 | $name = 'parsa' 29 | 30 | println(get('name')) 31 | 32 | set('name', 'pashmak') 33 | 34 | println($name) 35 | 36 | --output-- 37 | """parsa 38 | pashmak 39 | """ -------------------------------------------------------------------------------- /tests/core/syntax-bug-multiline-001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # syntax-bug-multiline-001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | bug whitespace in multiline is fixed 25 | 26 | --file-- 27 | 28 | func hello(string $name) 29 | println 'hello ' + $name 30 | endfunc 31 | 32 | hello( 33 | 'parsa' 34 | 35 | ) 36 | 37 | --output-- 38 | "hello parsa\n" 39 | -------------------------------------------------------------------------------- /tests/module/import/multi_import/1.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 1.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | multiple import is working with parentheses 25 | --file-- 26 | import ('@hash', 'examples/will_be_include.pashm') 27 | hash.sha256 'hello'; print ^ 28 | --output-- 29 | 'i am included\n2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824' 30 | -------------------------------------------------------------------------------- /tests/section/1.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 1.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | section system is working as Loop structure 25 | --file-- 26 | println 'before start' 27 | $i = 0 28 | section 10 29 | print str($i) 30 | $i = $i + 1 31 | mem $i < 10; gotoif 10 32 | println 'after start' 33 | --output-- 34 | '''before start 35 | 0123456789after start 36 | ''' -------------------------------------------------------------------------------- /tests/stdlib/py-load-file-001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # py-load-file-001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | py_load_file function is working 25 | --file-- 26 | 27 | $pyobj = py_load_file($__dir__ + '/tests/test-module-path/testpyfile.py') 28 | print($pyobj->the_var) 29 | $pyobj->the_func() 30 | 31 | --output-- 32 | "The value of python var" 33 | 34 | -------------------------------------------------------------------------------- /examples/get_password.pashm: -------------------------------------------------------------------------------- 1 | # 2 | # get_password.pashm 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | # valid password 24 | $password = '123' 25 | 26 | # ask password from user 27 | print('enter the password: ') 28 | $input = read() 29 | 30 | # check password 31 | if $input == $password 32 | println('WELCOME!') 33 | else 34 | println('invalid password') 35 | endif 36 | -------------------------------------------------------------------------------- /tests/variables/gget001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # gget001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | function gget() is working 25 | 26 | --file-- 27 | 28 | func hello() 29 | $name = 'new' 30 | println($name) 31 | println(gget('name')) 32 | endfunc 33 | 34 | $name = 'pashmak' 35 | 36 | hello() 37 | 38 | --output-- 39 | """new 40 | pashmak 41 | """ -------------------------------------------------------------------------------- /examples/array.pashm: -------------------------------------------------------------------------------- 1 | # 2 | # array.pashm 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | # We have a array from names. we in here print them one by one 24 | 25 | # declare $names array 26 | $names = ['parsa', 'pashmak', 'something'] 27 | 28 | # set a counter for loop 29 | $i = 0 30 | 31 | while $i < len($names) 32 | println($names[$i]) 33 | $i = $i + 1 34 | endwhile 35 | -------------------------------------------------------------------------------- /tests/function/func_args.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # func_args.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | functions argument will be set correctly 25 | --file-- 26 | func myfunc() 27 | print ^ 28 | endfunc 29 | myfunc("hello world") 30 | myfunc(2*3) 31 | 32 | $var = 'test' 33 | 34 | myfunc 'this is ' + $var 35 | 36 | --output-- 37 | 'hello world6this is test' 38 | -------------------------------------------------------------------------------- /examples/loop.pashm: -------------------------------------------------------------------------------- 1 | # 2 | # loop.pashm 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | # This is a simple loop printing numbers from 1 to 99 24 | 25 | func myfunc(int $n) 26 | println('starting...') 27 | 28 | $i = 1 29 | while $i < $n 30 | println($i) 31 | $i = $i + 1 32 | endwhile 33 | 34 | println('finished') 35 | endfunc 36 | 37 | myfunc(100) 38 | -------------------------------------------------------------------------------- /tests/namespace/bug001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # bug001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | namespace function bug is fixed 25 | 26 | --file-- 27 | 28 | namespace App 29 | func foo() 30 | println 'the foo' 31 | endfunc 32 | 33 | func bar() 34 | foo() 35 | endfunc 36 | endns 37 | 38 | App.bar() 39 | 40 | --output-- 41 | "the foo\n" -------------------------------------------------------------------------------- /tests/examples/fib.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # fib.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | Test fibonacci printing example 25 | 26 | --file-- 27 | import 'examples/fib.pashm' 28 | 29 | --output-- 30 | 31 | '''1 32 | 1 33 | 2 34 | 3 35 | 5 36 | 8 37 | 13 38 | 21 39 | 34 40 | 55 41 | 89 42 | 144 43 | 233 44 | 377 45 | 610 46 | 987 47 | 1597 48 | 2584 49 | 4181 50 | 6765 51 | ''' 52 | -------------------------------------------------------------------------------- /tests/function/func0.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # func0.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | functions working 25 | 26 | --file-- 27 | println 'starting' 28 | 29 | func myfunc() 30 | println 'func runed' 31 | println 'func finished' 32 | endfunc 33 | 34 | myfunc 35 | 36 | println 'finished' 37 | 38 | --output-- 39 | 'starting\nfunc runed\nfunc finished\nfinished\n' 40 | -------------------------------------------------------------------------------- /tests/classes/003-props.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 003-props.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | class properties can be declared 25 | --file-- 26 | class Car 27 | $name 28 | $price = 100 29 | endclass 30 | 31 | print(self.classes['Car'].__props__) 32 | 33 | --output-- 34 | "{'__parent__': 'Object', '__name__': 'Car', '__docstring__': '', 'name': None, 'price': 100}" 35 | -------------------------------------------------------------------------------- /tests/tryendtry/0.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 0.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | try endtry is working when code has not any error 25 | --file-- 26 | $name = 'pashmak' 27 | 28 | try 10 29 | # a code without error 30 | print 'hello ' + $name 31 | endtry 32 | 33 | goto 20 34 | 35 | section 10 36 | 37 | print 'the Error!' 38 | 39 | section 20 40 | --output-- 41 | 'hello pashmak' -------------------------------------------------------------------------------- /doc/04_os_command/00_os_commands.md: -------------------------------------------------------------------------------- 1 | # OS Commands 2 | 3 | here is some commands about OS. 4 | 5 | ### cwd 6 | get current working directory. 7 | 8 | ```bash 9 | cwd() 10 | println(^) 11 | ``` 12 | 13 | output: 14 | 15 | ``` 16 | /tmp 17 | ``` 18 | 19 | or: 20 | 21 | ```bash 22 | $cwd = cwd() 23 | println('The current working directory is ' + $cwd) 24 | ``` 25 | 26 | or: 27 | 28 | ```bash 29 | println(cwd()) 30 | ``` 31 | 32 | this command puts current working directory path into the mem. 33 | 34 | ### system 35 | you can run shell commands by this command: 36 | 37 | ```bash 38 | system('ls /tmp') 39 | ``` 40 | 41 | also after run `system` function, exit code will put in `mem`: 42 | 43 | ```bash 44 | system('ls /') 45 | println(^) # output: 0 46 | ``` 47 | 48 | or: 49 | 50 | ```bash 51 | println(system('ls /')) 52 | ``` 53 | 54 | ### exit 55 | this command exits program 56 | 57 | look at this example: 58 | 59 | ```bash 60 | println('first print') 61 | 62 | exit() 63 | 64 | println('last print') # this will not print 65 | ``` 66 | 67 | output: 68 | 69 | ``` 70 | first print 71 | ``` 72 | 73 | #### exit with exit code: 74 | 75 | ```bash 76 | println('hello world') 77 | exit(1) 78 | ``` 79 | 80 | exit code of program will be `1` 81 | -------------------------------------------------------------------------------- /doc/10_modules/05_sys.md: -------------------------------------------------------------------------------- 1 | # sys module 2 | this module has some functions to manage pashmak internal envrinonment. 3 | 4 | ### sys.path module 5 | this module is for manage module paths. you can add new module paths and load modules from everywhere at runtime with this module. 6 | 7 | to know about this module, go to next section [Module path system](#module-path-system). 8 | 9 | ### `$sys.pashmakinfo`, access to pashmakinfo 10 | 11 | if you want to access to pashmak interpreter info, `sys` module has a variable named `pashmakinfo`: 12 | 13 | ```bash 14 | import @sys 15 | 16 | println($sys.pashmakinfo) 17 | ``` 18 | 19 | output is something like this: 20 | 21 | ``` 22 | {'version': 'vx.y.z', 'pythoninfo': 'x.y.z (default, Jul x y, a:b:c) [GCC x.y.x]'} 23 | ``` 24 | 25 | this variable is a dictonary. 26 | for example, to access pashmak version: 27 | 28 | ```bash 29 | import @sys 30 | 31 | println($sys.pashmakinfo['version']) 32 | ``` 33 | 34 | output: 35 | 36 | ``` 37 | v1.x.y 38 | ``` 39 | 40 | and `$sys.pashmakinfo['pythoninfo']` shows info of python. 41 | 42 | ### `$sys.pashmakexe`: The pashmak's interpreter exe filename 43 | This variable contains pashmak's interpreter filename. 44 | 45 | ```bash 46 | println($sys.pashmakexe) 47 | ``` 48 | -------------------------------------------------------------------------------- /tests/core/datatype-aliases.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # datatype-aliases.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | datatypes aliases are ok 25 | 26 | --file-- 27 | 28 | println(string(12)) 29 | println(null) 30 | println(true) 31 | println(false) 32 | println(integer('30')) 33 | println(array()) 34 | 35 | --output-- 36 | """12 37 | None 38 | True 39 | False 40 | 30 41 | [] 42 | """ 43 | 44 | -------------------------------------------------------------------------------- /tests/core/syntax-bug-007.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # syntax-bug-007.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | class property setting syntax bug is fixed 25 | 26 | --file-- 27 | 28 | define('NAME', 'hello') 29 | 30 | class Person 31 | $NAME = 'parsa' 32 | endclass 33 | 34 | $a = Person() 35 | 36 | $a->NAME = 'new' 37 | 38 | println $a->NAME 39 | 40 | --output-- 41 | """new 42 | """ 43 | -------------------------------------------------------------------------------- /tests/function/arg-type-002.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # arg-type-002.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | typed arguments with `|` works 25 | 26 | --file-- 27 | 28 | func hello(int|string $a) 29 | println($a) 30 | endfunc 31 | 32 | hello(10) 33 | hello('hello') 34 | hello(True) 35 | 36 | --output-- 37 | """10 38 | hello 39 | """ 40 | 41 | --with-error-- 42 | "InvalidArgument" 43 | -------------------------------------------------------------------------------- /tests/module/import/002-import-once.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 002-import-once.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | import_once function works and only imports a file one time 25 | 26 | --file-- 27 | import_once 'examples/will_be_include.pashm' 28 | import_once 'examples/will_be_include.pashm' 29 | 30 | testfunc 31 | 32 | --output-- 33 | """i am included 34 | i am included func 35 | """ -------------------------------------------------------------------------------- /tests/function/bug002.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # bug002.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | function argument null value bug while type is defined is fixed 25 | 26 | --file-- 27 | 28 | func hello(string $name, string $family=null, int $age = 100) 29 | println $name, $family, $age 30 | endfunc 31 | 32 | hello('parsa') 33 | 34 | --output-- 35 | """('parsa', None, 100) 36 | """ 37 | 38 | -------------------------------------------------------------------------------- /tests/module/import/0.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 0.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | import command is working 25 | 26 | --file-- 27 | println 'before include' 28 | import 'examples/will_be_include.pashm' 29 | println 'after include' 30 | testfunc 31 | println($included_var) 32 | 33 | --output-- 34 | 'before include\ni am included\nafter include\ni am included func\nincluded value\n' 35 | -------------------------------------------------------------------------------- /examples/fib.pashm: -------------------------------------------------------------------------------- 1 | # 2 | # fib.pashm 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | # Printing the fibonacci pattern 24 | 25 | func fib(int $n=1000) 26 | $a = 1 27 | $b = 1 28 | 29 | while $a < $n 30 | println($a) 31 | 32 | $tmp_a = $a 33 | $tmp_b = $b 34 | 35 | $a = $tmp_b 36 | 37 | $b = $tmp_a + $tmp_b 38 | endwhile 39 | endfunc 40 | 41 | fib(10000) 42 | -------------------------------------------------------------------------------- /tests/classes/001.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 001.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | class can be declared 25 | --file-- 26 | class Person 27 | endclass 28 | println(list(self.classes.keys())) 29 | println(self.classes['Person'].__props__) 30 | --output-- 31 | """["""+self.default_classes_list_str+""", 'Person'] 32 | {'__parent__': 'Object', '__name__': 'Person', '__docstring__': ''} 33 | """ 34 | -------------------------------------------------------------------------------- /tests/namespace/0.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # 0.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | namespaces can be declared and called 25 | --file-- 26 | namespace MySpace 27 | func dosomething() 28 | println 'hello world' 29 | endfunc 30 | MySpace.dosomething 31 | dosomething 32 | endnamespace 33 | MySpace.dosomething 34 | --output-- 35 | 'hello world\nhello world\nhello world\n' 36 | -------------------------------------------------------------------------------- /tests/module/import/bug005.pashmt: -------------------------------------------------------------------------------- 1 | # 2 | # bug005.pashmt 3 | # 4 | # The Pashmak Project 5 | # Copyright 2020-2021 parsa shahmaleki 6 | # 7 | # This file is part of Pashmak. 8 | # 9 | # Pashmak is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # Pashmak is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with Pashmak. If not, see . 21 | ######################################################################### 22 | 23 | --test-- 24 | import frame conflicting bug is fixed 25 | 26 | --file-- 27 | 28 | func hello() 29 | import_once $__dir__ + '/examples/will_be_include.pashm' 30 | endfunc 31 | 32 | import $__dir__ + '/examples/will_be_include.pashm' 33 | hello() 34 | hello() 35 | 36 | --output-- 37 | """i am included 38 | """ 39 | --------------------------------------------------------------------------------