├── .github
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── .gitignore
├── .project
├── .pydevproject
├── CODE_OF_CONDUCT.md
├── IDEs
├── Eclipse
│ ├── Eclipse 2019-03
│ │ ├── .project
│ │ └── .pydevproject
│ ├── Eclipse 2019-06
│ │ ├── .project
│ │ └── .pydevproject
│ ├── Eclipse-2019-09
│ │ ├── .project
│ │ └── .pydevproject
│ ├── Eclipse-2020-03
│ │ ├── .project
│ │ └── .pydevproject
│ ├── Eclipse-2020-06
│ │ ├── .project
│ │ └── .pydevproject
│ └── ReadMe.md
└── Visual Studio Code
│ └── ReadMe.md
├── LICENSE
├── Language-specifications
├── ReadMe.md
├── typee_specs_LL1-v10-EBNF.grm
├── typee_specs_LL1-v10.grm
├── typee_specs_LL1-v2.grm
├── typee_specs_LL1-v3.grm
├── typee_specs_LL1-v5.grm
├── typee_specs_LL1-v6.grm
├── typee_specs_LL1-v7.grm
├── typee_specs_LL1-v8-EBNF.grm
├── typee_specs_LL1-v8.grm
├── typee_specs_LL1-v9-1-EBNF.grm
├── typee_specs_LL1-v9-1.grm
├── typee_specs_LL1-v9-2-EBNF.grm
├── typee_specs_LL1-v9-2.grm
├── typee_specs_LL1-v9-3-EBNF.grm
├── typee_specs_LL1-v9-EBNF.grm
├── typee_specs_LL1-v9.grm
├── typee_specs_LL1.grm
└── typee_specs_LL1_v9-3.grm
├── Notepad++XML-configs
├── desktop.ini
├── grammars.xml
├── readme.md
└── typee.xml
├── Pictures
├── 1-install-new-software.png
├── 2-install-add.png
├── 3-add.png
├── 4-pydev-install.png
├── 5-perspectives.png
├── 6-PyDev-perspective.png
└── 7-final-perspectives.png
├── README.md
├── _Global_Documentation
├── Back-End_documentation
│ └── readme.md
├── Commons-Utils_documentation
│ └── readme.md
├── Front-End_documentation
│ ├── readme.md
│ ├── typee_front_end_parser_documentation.md
│ └── typee_front_end_scanner_sw_documentation.md
├── Picts
│ ├── back-end.png
│ ├── front-end-elaborator.png
│ ├── front-end-parser.png
│ ├── front-end-scanner.png
│ ├── front-end.png
│ ├── optimizer.png
│ ├── three-phase-compiler.png
│ ├── two-phase-compiler.png
│ ├── typee-design-all-figures.pptx
│ ├── typee-design.png
│ └── us7346897B2-fig-3.jpg
├── Typee_Software_HTML_Documentation
│ ├── .gitattributes
│ ├── PyYadc
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── doc
│ │ │ ├── .gitattributes
│ │ │ └── pyYadc_doc.html
│ │ └── src
│ │ │ ├── __init__.py
│ │ │ ├── css_code.py
│ │ │ ├── directory.py
│ │ │ ├── html_class.py
│ │ │ ├── html_function.py
│ │ │ ├── html_generator.py
│ │ │ ├── html_module.py
│ │ │ ├── html_package.py
│ │ │ ├── module_parser.py
│ │ │ ├── pyYadc.py
│ │ │ └── utils.py
│ ├── README.md
│ ├── __init__.py
│ └── typee_automated_documentation_script.py
├── __main_index.md
├── programming-languages-translation-State-of-the-Art.md
└── typee_software_design.md
├── _config.yml
├── development-framework.md
└── src
├── BackEnd
└── __init__.py
├── Commons
├── IntermediateCode
│ └── __init__.py
├── __init__.py
└── access.py
├── FrontEnd
├── Elaborator
│ ├── __init__.py
│ ├── fe_elaborator.py
│ ├── fe_symbols_elaborator.py
│ └── fe_types_elaborator.py
├── Errors
│ ├── __init__.py
│ └── fe_syntax_errors.py
├── IntermediateCode
│ ├── __init__.py
│ ├── fe_icblock.py
│ ├── fe_icleaf.py
│ ├── fe_icnode.py
│ ├── fe_icode_token_node.py
│ ├── fe_icode_tokens.py
│ ├── fe_ictree.py
│ └── fe_tokenized_icode.py
├── Parser
│ ├── __init__.py
│ └── fe_parser.py
├── Scanner
│ ├── __init__.py
│ └── fe_scanner.py
└── __init__.py
├── IntermediateCode
├── __init__.py
└── ic_ast.py
├── Libs
├── Files
│ ├── base_file.ty
│ ├── f_types.ty
│ ├── r_file.ty
│ ├── ro_file.ty
│ ├── rw_file.ty
│ ├── w_file.ty
│ └── wo_file.ty
├── Random
│ ├── Bases
│ │ ├── base_lcg.ty
│ │ ├── base_lfib64.ty
│ │ ├── base_mrg.ty
│ │ ├── base_rand_state.ty
│ │ └── base_random.ty
│ ├── rand116.ty
│ ├── rand1340.ty
│ ├── rand1457.ty
│ ├── rand287.ty
│ ├── rand32.ty
│ ├── rand49507.ty
│ ├── rand63.ty
│ ├── rand668.ty
│ └── rand78.ty
├── SysTime
│ ├── perfmeter.ty
│ └── systime.ty
├── Thread
│ ├── base_thread.ty
│ ├── daemon_thread.ty
│ ├── thread_barrier.ty
│ ├── thread_condition.ty
│ ├── thread_event.ty
│ ├── thread_exceptions.ty
│ ├── thread_guarded_block.ty
│ ├── thread_guarded_var.ty
│ ├── thread_latch.ty
│ ├── thread_mutex.ty
│ ├── thread_semaphore.ty
│ ├── thread_timer.ty
│ ├── thread_watchdog.ty
│ └── utils
│ │ └── utils.ty
└── types.ty
├── Optimizer
└── __init__.py
├── Tests
├── BackEnd
│ └── __init__.py
├── Documentation-README
│ └── scanner_tokenization_tests.md
├── FrontEnd
│ ├── IntermediateCode
│ │ ├── __init__.py
│ │ └── script_ic_tree.py
│ ├── Parser_Rules
│ │ └── __init__.py
│ ├── Scanner_Tokens
│ │ ├── Data
│ │ │ ├── __init__.py
│ │ │ ├── tokenization_compound_solution.py
│ │ │ ├── tokenization_compound_tokens.ty
│ │ │ ├── tokenization_names_and_nums_solution.py
│ │ │ ├── tokenization_names_and_nums_tokens.ty
│ │ │ ├── tokenization_simple_solution.py
│ │ │ └── tokenization_simple_tokens.ty
│ │ ├── __init__.py
│ │ ├── readme.md
│ │ ├── script_scanner_test.py
│ │ ├── test_compound_tokens.py
│ │ ├── test_names_and_nums_tokens.py
│ │ ├── test_simple_tokens.py
│ │ └── tokens_test_base.py
│ └── __init__.py
├── Libs
│ └── __init__.py
├── Optimizer
│ └── __init__.py
├── Utils
│ ├── __init__.py
│ ├── script_ut_tree.py
│ └── test_ut_trees.py
└── __init__.py
├── TypeeInterpreter
├── Commons
│ └── __init__.py
├── FEInterface
│ └── __init__.py
├── Utils
│ └── __init__.py
└── __init__.py
├── Utils
├── Trees
│ ├── __init__.py
│ ├── ut_tree.py
│ ├── ut_tree_leaf.py
│ ├── ut_tree_node.py
│ └── ut_tree_node_base.py
├── __init__.py
├── archive
│ └── ut_tree.py
├── ut_decorators.py
└── ut_serialized_enum.py
├── __init__.py
└── local_tools
├── __init__.py
├── copyright_years_modif.py
├── script_copyright_automated_modification.py
├── template_class.py
├── template_main.py
├── tool_generate_feicode_token_node_module.py
└── tool_generate_html_grammar.py
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve Typee environment
4 |
5 | ---
6 |
7 | **Describe the bug**
8 |
9 | [_A clear and concise description of what the bug is._]
10 | [_May deal with translator internal error,
11 | erroneous translated syntax or unexpected behavior
12 | when running translated code._]
13 |
14 |
15 | **To Reproduce**
16 |
17 | Steps to reproduce the behavior:
18 |
19 | [_Ex._
20 | 1. _Directory Tree: Xxx/Yyy/Zzz/_
21 | 2. _Translated Typee module: mmm.ty_
22 | 3. _Command line as typed for translation: typee -opt1 -opt2 ..._
23 | 4. ...
24 | 5. ...
25 | 6. ... _any other valuable information to reproduce the error_]
26 |
27 |
28 | **Expected behavior**
29 |
30 | [_A clear and concise description of what you expected to happen._]
31 |
32 |
33 | **Screenshots**
34 |
35 | [_If applicable, add screenshots to help explain your problem._]
36 |
37 |
38 | **Desktop (please complete the following information):**
39 |
40 | - OS: [_e.g. iOS, MacOS X, Win32, Win64, Linux/Ubuntu, Linux/Fedora, ..._]
41 | - Version [_e.g. 8_]
42 | - Translator: [_e.g. C++17, C#, Java 8.1, Java for Android 9, Python 3.8, ..._]
43 |
44 |
45 | **Additional context**
46 |
47 | [_Add any other context about the problem here._]
48 | [_For instance, you may copy here Typee code and finally erroneous translated code._]
49 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea to enhance Typee project
4 |
5 | ---
6 |
7 | **Is your feature request related to a problem? Please describe.**
8 |
9 | [_A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]_]
10 |
11 |
12 | **Describe the solution you'd like**
13 |
14 | [_A clear and concise description of what you want to happen._]
15 |
16 |
17 | **Describe alternatives you've considered**
18 |
19 | [_A clear and concise description of any alternative solutions or features you've considered._]
20 |
21 |
22 | **Additional context**
23 |
24 | [_Add any other context or screenshots about the feature request here._]
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gitignore
2 | .metadata
3 | /.project
4 | /.pydevproject
5 | .settings
6 | _config.yml
7 | *.pyc
8 | __pycache__
9 | * - Copie.grm
10 | *-new.grm
11 | * - Copy.grm
12 | UML*
13 | *.prefs
14 | tmp_data
15 | src/Utils/desktop.ini
16 | *.epf
17 | Scripts
18 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Typee
4 |
5 |
6 |
7 |
8 | org.python.pydev.PyDevBuilder
9 |
10 |
11 |
12 |
13 |
14 | org.python.pydev.pythonNature
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.pydevproject:
--------------------------------------------------------------------------------
1 |
2 |
3 | Python 3.8
4 | python interpreter
5 |
6 | /${PROJECT_DIR_NAME}
7 |
8 |
9 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at schmouk@typee.ovh. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/IDEs/Eclipse/Eclipse 2019-03/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Typee
4 |
5 |
6 |
7 |
8 | org.python.pydev.PyDevBuilder
9 |
10 |
11 |
12 |
13 |
14 | org.python.pydev.pythonNature
15 |
16 |
17 |
--------------------------------------------------------------------------------
/IDEs/Eclipse/Eclipse 2019-03/.pydevproject:
--------------------------------------------------------------------------------
1 |
2 |
3 | Default
4 | python interpreter
5 |
6 | /${PROJECT_DIR_NAME}/src
7 | /${PROJECT_DIR_NAME}
8 |
9 |
10 |
--------------------------------------------------------------------------------
/IDEs/Eclipse/Eclipse 2019-06/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Typee
4 |
5 |
6 |
7 |
8 | org.python.pydev.PyDevBuilder
9 |
10 |
11 |
12 |
13 |
14 | org.python.pydev.pythonNature
15 |
16 |
17 |
--------------------------------------------------------------------------------
/IDEs/Eclipse/Eclipse 2019-06/.pydevproject:
--------------------------------------------------------------------------------
1 |
2 |
3 | Default
4 | python interpreter
5 |
6 | /${PROJECT_DIR_NAME}/src
7 | /${PROJECT_DIR_NAME}
8 |
9 |
10 |
--------------------------------------------------------------------------------
/IDEs/Eclipse/Eclipse-2019-09/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Typee
4 |
5 |
6 |
7 |
8 | org.python.pydev.PyDevBuilder
9 |
10 |
11 |
12 |
13 |
14 | org.python.pydev.pythonNature
15 |
16 |
17 |
--------------------------------------------------------------------------------
/IDEs/Eclipse/Eclipse-2019-09/.pydevproject:
--------------------------------------------------------------------------------
1 |
2 |
3 | Default
4 | python interpreter
5 |
6 | /${PROJECT_DIR_NAME}/src
7 | /${PROJECT_DIR_NAME}
8 |
9 |
10 |
--------------------------------------------------------------------------------
/IDEs/Eclipse/Eclipse-2020-03/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Typee
4 |
5 |
6 |
7 |
8 | org.python.pydev.PyDevBuilder
9 |
10 |
11 |
12 |
13 |
14 | org.python.pydev.pythonNature
15 |
16 |
17 |
--------------------------------------------------------------------------------
/IDEs/Eclipse/Eclipse-2020-03/.pydevproject:
--------------------------------------------------------------------------------
1 |
2 |
3 | python 3.8
4 | python interpreter
5 |
6 | /${PROJECT_DIR_NAME}/src
7 | /${PROJECT_DIR_NAME}
8 |
9 |
10 |
--------------------------------------------------------------------------------
/IDEs/Eclipse/Eclipse-2020-06/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Typee
4 |
5 |
6 |
7 |
8 | org.python.pydev.PyDevBuilder
9 |
10 |
11 |
12 |
13 |
14 | org.python.pydev.pythonNature
15 |
16 |
17 |
--------------------------------------------------------------------------------
/IDEs/Eclipse/Eclipse-2020-06/.pydevproject:
--------------------------------------------------------------------------------
1 |
2 |
3 | python 3.8
4 | python interpreter
5 |
6 | /${PROJECT_DIR_NAME}/src
7 | /${PROJECT_DIR_NAME}
8 |
9 |
10 |
--------------------------------------------------------------------------------
/IDEs/Eclipse/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Using eclipse IDE as your framework for Typee
2 |
3 | The subdirectories here contain each files
4 | - `.project` and
5 | - `.Pydevproject`.
6 |
7 | To be able to use eclipse as your framework to work on **Typee**,
8 | just copy those two files into the main directory of your local
9 | clone of **Typee** Github repository, copy files from:
10 |
11 |
12 | - `Eclipse 2019-03` or
13 | - `Eclipse 2019-06` or
14 | - `Eclipse 2019-09` or
15 | - `Eclipse 2020-03` or
16 | - `Eclipse 2020-06`
17 |
18 | according to the version of Eclipse you use.
19 | Caution: these versions of Eclipse are each related to a specific Python version. For isntance, `Eclipse 2020-06` is bound to Python 3.8`. You may wish to not use these files to configure your own environment
20 |
21 | Enjoy!
22 |
--------------------------------------------------------------------------------
/IDEs/Visual Studio Code/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Using Visual Studio Code IDE as your framework for Typee
2 |
3 | VSCode allows for the installing of extensions. Here are the few
4 | ones we have installed with our VSC framework:
5 |
6 | - Anaconda Extension Pack (1.0.1 by the date of this publication)
7 | - Code Runner (0.9.11 by the date of this publication)
8 | - Python (2019.6.24221 by the date of this publication)
9 | - Python Extension Pack (1.6.0 by the date of this publication)
10 | - Python for VSCode (0.2.3 by the date of this publication)
11 | - Visual Studio IntelliCode (1.1.8 by the date of this publication)
12 |
13 | You are free to install any other ones, but these are the ones
14 | we are currently using. Furthermore, it might be that some of these
15 | extensions are redundant... Well, we have not yet checked.
16 |
17 | Nevertheless, Enjoy!
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018-2021 Philippe Schmouker, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Notepad++XML-configs/desktop.ini:
--------------------------------------------------------------------------------
1 | [ViewState]
2 | Mode=
3 | Vid=
4 | FolderType=Generic
5 |
--------------------------------------------------------------------------------
/Notepad++XML-configs/grammars.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 00## 01 02 03/* 04*/
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | * +
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | ::= | -
28 | EPS EPSILON
29 |
30 |
31 |
32 |
33 |
34 |
35 | 00[ 01\ 02] 03( 04\ 05) 06" 07\ 08" 09' 10\ 11' 12< 13\ 14> 15{ 16\ 17} 18$ 19 20; 21 22 23
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/Notepad++XML-configs/readme.md:
--------------------------------------------------------------------------------
1 | # Notepad++ recommendations
2 |
3 | The directory `Typee/Notepad++XML-configs` contains three `.xml` files:
4 | - desktop.ini
5 | - grammars.xml
6 | - typhon.xml
7 |
8 | The first file contains configuration for the display of this repository.
9 |
10 | The two last files contain descriptions of language and syntax coloring specification
11 | for:
12 | - `.grm` files, i.e. files contining grammars specification of programming
13 | languages, and
14 | - `.ty` and `.typee` modules containing Typee code.
15 |
16 | Windows users who would like to use Notepad++ for its syntax coloring
17 | capabilities are encouraged to put those three `.xml` files directly at the
18 | root directory of their Notepad++ installation. Any `.grm`, `.ty` or
19 | `.typee` file will then be automatically coloured.
20 |
21 | Notably, the .grm specification file of **Typee** (see directory `Specs`) will
22 | open and will be coloured in Notepad++.
23 |
24 | Any **Typee** module you would program will also automatically get syntax
25 | colorisation as long as it is suffixed with either `.ty`or `.typee` (which are
26 | the recommended suffixes for **Typee** modules).
--------------------------------------------------------------------------------
/Pictures/1-install-new-software.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/Pictures/1-install-new-software.png
--------------------------------------------------------------------------------
/Pictures/2-install-add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/Pictures/2-install-add.png
--------------------------------------------------------------------------------
/Pictures/3-add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/Pictures/3-add.png
--------------------------------------------------------------------------------
/Pictures/4-pydev-install.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/Pictures/4-pydev-install.png
--------------------------------------------------------------------------------
/Pictures/5-perspectives.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/Pictures/5-perspectives.png
--------------------------------------------------------------------------------
/Pictures/6-PyDev-perspective.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/Pictures/6-PyDev-perspective.png
--------------------------------------------------------------------------------
/Pictures/7-final-perspectives.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/Pictures/7-final-perspectives.png
--------------------------------------------------------------------------------
/_Global_Documentation/Back-End_documentation/readme.md:
--------------------------------------------------------------------------------
1 | This directory, in _Global_Documentation, relates with the documentation of
2 | the **Back-End** of translator **Typee**.
3 |
4 | It contains all related documentation in an MarkDown form.
5 |
--------------------------------------------------------------------------------
/_Global_Documentation/Commons-Utils_documentation/readme.md:
--------------------------------------------------------------------------------
1 | This directory, in _Global_Documentation, relates with the documentation of
2 | the **Commons** and the **Utils** of translator **Typee**.
3 |
4 | **Commons** is a source code directory which contains all _Python_ modules
5 | that are commonly used by all of the other parts of **Typee** software.
6 |
7 | **Utils** contains all _Python_ modules that define utilities that are used
8 | by **Typee** software and which could also be used by external software as
9 | long as they respect the MIT License those modules are delivered with.
10 |
11 | It contains all related documentation in an MarkDown form.
12 |
--------------------------------------------------------------------------------
/_Global_Documentation/Front-End_documentation/readme.md:
--------------------------------------------------------------------------------
1 | This directory, in _Global_Documentation, relates with the documentation of
2 | the **Front-End** of translator **Typee**.
3 |
4 | It contains all related documentation in an MarkDown form.
5 |
--------------------------------------------------------------------------------
/_Global_Documentation/Picts/back-end.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/_Global_Documentation/Picts/back-end.png
--------------------------------------------------------------------------------
/_Global_Documentation/Picts/front-end-elaborator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/_Global_Documentation/Picts/front-end-elaborator.png
--------------------------------------------------------------------------------
/_Global_Documentation/Picts/front-end-parser.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/_Global_Documentation/Picts/front-end-parser.png
--------------------------------------------------------------------------------
/_Global_Documentation/Picts/front-end-scanner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/_Global_Documentation/Picts/front-end-scanner.png
--------------------------------------------------------------------------------
/_Global_Documentation/Picts/front-end.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/_Global_Documentation/Picts/front-end.png
--------------------------------------------------------------------------------
/_Global_Documentation/Picts/optimizer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/_Global_Documentation/Picts/optimizer.png
--------------------------------------------------------------------------------
/_Global_Documentation/Picts/three-phase-compiler.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/_Global_Documentation/Picts/three-phase-compiler.png
--------------------------------------------------------------------------------
/_Global_Documentation/Picts/two-phase-compiler.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/_Global_Documentation/Picts/two-phase-compiler.png
--------------------------------------------------------------------------------
/_Global_Documentation/Picts/typee-design-all-figures.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/_Global_Documentation/Picts/typee-design-all-figures.pptx
--------------------------------------------------------------------------------
/_Global_Documentation/Picts/typee-design.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/_Global_Documentation/Picts/typee-design.png
--------------------------------------------------------------------------------
/_Global_Documentation/Picts/us7346897B2-fig-3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/_Global_Documentation/Picts/us7346897B2-fig-3.jpg
--------------------------------------------------------------------------------
/_Global_Documentation/Typee_Software_HTML_Documentation/.gitattributes:
--------------------------------------------------------------------------------
1 | *.html linguist-documentation
2 |
--------------------------------------------------------------------------------
/_Global_Documentation/Typee_Software_HTML_Documentation/PyYadc/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016-2021 Philippe Schmouker
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/_Global_Documentation/Typee_Software_HTML_Documentation/PyYadc/README.md:
--------------------------------------------------------------------------------
1 | # pyYadc
2 | pyYadc stands for "Python - Yet Another Documentation Compiler".
3 |
4 | This is an automated generator of HTML documentation. It provides automatic
5 | formatting of documentation for Python packages. Any available docstring is
6 | extracted and put as is near the documented items, i.e.:
7 | - modules (as contained in the package);
8 | - classes (as defined in each module);
9 | - functions (as defined in each module and in each class).
10 |
11 | User is advised that when generating documentation for Python 2 syntax, a
12 | Python 2.x interpreter has to be used while when generating documentation for
13 | Python 3 syntax, a Python 3.x interpreter should be used.
14 |
15 |
16 | ## Installation
17 | From this repository, download directory `scr/` onto your machine. It might be suitable to rename it 'pyYadc' then on your local machine. Every needed stuff is contained in this `src/` directory. Have a look at section __Usage__ below to see how to play with pyYadc.
18 |
19 | You may also download the content of two other directories:
20 | - `doc/` contains the HTML documentation of this software
21 | - `eclipse-photon-metadata/` contains an empty directory and two `.project...` files that you can download. They will be useful for the ones who use Eclipse framework in its version Photon (June 2018). Just put them as is in your local 'pyYadc' directory. You will then be able to easily import PyYadc as a project in Eclipse Photon.
22 |
23 | ### Important Notice
24 | The GitHub pages for pyYadc, available at https://schmouk.github.io/pyYadc/, propose two buttons 'zip' and 'tar' to download compressed versions of the whole repository. Do not hesitate to go there for your downloadings of pyYadc.
25 |
26 |
27 | ## Usage:
28 | The working directory is the directory that contains the Python package to be
29 | documented. Command is then:
30 |
31 | $ python /pyYadc.py
32 |
33 | No options are available with current version 1.0.
34 |
35 | Please notice that the HTML documentation of PyYadc has been generated by pyYadc itself.
36 |
37 | Copyright (c) 2016-2021 Philippe Schmouker, pyYadc project, https://github.com/schmouk/PyYadc
38 | (and https://schmouk.github.io/pyYadc/)
39 |
--------------------------------------------------------------------------------
/_Global_Documentation/Typee_Software_HTML_Documentation/PyYadc/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/_Global_Documentation/Typee_Software_HTML_Documentation/PyYadc/__init__.py
--------------------------------------------------------------------------------
/_Global_Documentation/Typee_Software_HTML_Documentation/PyYadc/doc/.gitattributes:
--------------------------------------------------------------------------------
1 | *.html linguist-documentation
2 |
--------------------------------------------------------------------------------
/_Global_Documentation/Typee_Software_HTML_Documentation/PyYadc/src/__init__.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 | """
4 | pyYadc stands for "Python - Yet Another Documentation Compiler".
5 |
6 | This is an automated generator of HTML documentation. It provides automatic
7 | formatting of documentation for Python packages. Any available docstring is
8 | extracted and put as is near the documented items, i.e.:
9 | - modules (as contained in the package);
10 | - classes (as defined in each module);
11 | - functions (as defined in each module and in each
12 | class).
13 |
14 | User is advised that when generating documentation for Python 2 syntax, a
15 | Python 2.x interpreter has to be used while when generating documentation for
16 | Python 3 syntax, a Python 3.x interpreter should be used.
17 |
18 | Usage:
19 | The working directory is the directory which contains the Python package to be
20 | documented. Command is then:
21 | $ python <path_to_pyYadc_dir>/pyYadc.py <package_name>
22 |
23 | No options are currently available with this version 1.0.
24 |
25 |
26 | Copyright (c) 2016-2021 Philippe Schmouker, PyYadc project, https://github.com/schmouk/PyYadc
27 |
28 | Permission is hereby granted, free of charge, to any person obtaining a copy
29 | of this software and associated documentation files (the "Software"), to deal
30 | in the Software without restriction, including without limitation the rights
31 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
32 | copies of the Software, and to permit persons to whom the Software is
33 | furnished to do so, subject to the following conditions:
34 |
35 | The above copyright notice and this permission notice shall be included in all
36 | copies or substantial portions of the Software.
37 |
38 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
39 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
40 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
41 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
42 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
43 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
44 | SOFTWARE.
45 | """
46 |
47 |
48 | from PyYadc.src.directory import DirectoryDescr, DirectoryTree
49 | from PyYadc.src.html_class import HtmlClass
50 | from PyYadc.src.html_function import HtmlFunction
51 | from PyYadc.src.html_generator import HtmlGenerator
52 | from PyYadc.src.html_module import HtmlModule
53 | from PyYadc.src.html_package import HtmlPackage
54 | from PyYadc.src.module_parser import ModuleParser
55 | from PyYadc.src.utils import Utils
--------------------------------------------------------------------------------
/_Global_Documentation/Typee_Software_HTML_Documentation/PyYadc/src/pyYadc.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 | """
4 | Copyright (c) 2016-2021 Philippe Schmouker, PyYadc project, https://github.com/schmouk/PyYadc
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | """
24 |
25 |
26 | #=============================================================================
27 | import os.path
28 | import sys
29 |
30 | from PyYadc.src.html_generator import HtmlGenerator
31 |
32 |
33 | #=============================================================================
34 | if __name__ == '__main__':
35 |
36 | try:
37 | root_dirpath = sys.argv[1]
38 | except:
39 | root_dirpath = '.'
40 |
41 | print( "Generating documentation for html_package '{}'".format(root_dirpath) )
42 | HtmlGenerator( root_dirpath, os.path.basename(root_dirpath) )
43 |
44 | print( '\n-- done!' )
45 |
46 |
47 | #===== end of module pyYadc.py =====#
48 |
--------------------------------------------------------------------------------
/_Global_Documentation/Typee_Software_HTML_Documentation/PyYadc/src/utils.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 | """
4 | Copyright (c) 2016-2021 Philippe Schmouker, PyYadc project, https://github.com/schmouk/PyYadc
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | """
24 |
25 |
26 | #=============================================================================
27 | # no import.
28 |
29 |
30 | #=============================================================================
31 | class Utils:
32 | """
33 | This class is used as a namespace for utilities definitions
34 | """
35 |
36 | #-------------------------------------------------------------------------
37 | # Class Data
38 | K_HTML_INDENT_SPACES = 2
39 | K_MAX_ASSIGNS_LINES = 10
40 |
41 | #-------------------------------------------------------------------------
42 | @staticmethod
43 | def html_indent(indent_level, html_str):
44 | '''
45 | Inserts spaces in front of html string according to specified level
46 | of indentation.
47 |
48 | Args:
49 | indent_level: int
50 | The level of indentation. Please notice that this function
51 | uses the class constant K_HTML_INDENT_SPACES which defaults
52 | to 2.
53 | html_str: str
54 | The HTML code to be indented.
55 |
56 | Returns:
57 | The indented HTML code, every inner '\\n' being modified accord-
58 | ingly.
59 | '''
60 | my_indent = ' '*(indent_level * Utils.K_HTML_INDENT_SPACES)
61 | try:
62 | html_split = html_str.split( '\n' )
63 | if html_split[-1] == '':
64 | html_str = ('\n'+my_indent).join( html_split[:-1] ) + '\n'
65 | else:
66 | html_str = ('\n'+my_indent).join( html_split )
67 | except:
68 | pass
69 | return '{:s}{:s}'.format( my_indent, html_str )
70 |
71 |
72 | #-------------------------------------------------------------------------
73 | @staticmethod
74 | def get_decorators_str(decorator_list, module_lines):
75 | '''
76 | Transforms a list of decorators as specified in ast into a string.
77 |
78 | Args:
79 | decorator_list: list
80 | A reference to a list of decorators descriptors.
81 | module_lines: list
82 | A reference to the content of the parsed module,
83 | one line per entry.
84 |
85 | Returns:
86 | A string describing the whole decorators.
87 | '''
88 | myk_decorators_count = len(decorator_list)
89 | if myk_decorators_count == 0:
90 | return None
91 |
92 | my_str = '[ class decorator{:s}: '.format( 's' if myk_decorators_count > 1 else '' )
93 |
94 | for decorator_descr in decorator_list:
95 | my_decorator_line = module_lines[ decorator_descr.lineno-1 ]
96 | try:
97 | my_decorator_line = my_decorator_line.split('#',1)[0]
98 | except:
99 | pass
100 | my_decorator_line = my_decorator_line.strip()
101 | my_str += '{:s}, '.format( my_decorator_line )
102 |
103 | return my_str[:-2] + ' ]'
104 |
105 |
106 | #-------------------------------------------------------------------------
107 | @staticmethod
108 | def path_to_id(path):
109 | '''
110 | Evaluates an HTML id from a path.
111 |
112 | Args:
113 | path: str
114 | The path name to be transformed as an id.
115 |
116 | Returns:
117 | A string corresponding to the transformed path.
118 | '''
119 | return Utils.replace_backslash( path ).replace( '/', '_' )
120 |
121 |
122 | #-------------------------------------------------------------------------
123 | @staticmethod
124 | def replace_backslash(path):
125 | '''
126 | Replaces every backslash with a slash.
127 |
128 | Args:
129 | path: str
130 | The path name to be transformed.
131 |
132 | Returns:
133 | A string corresponding to the transformed path.
134 | '''
135 | return path.replace( '\\', '/' )
136 |
137 | #===== end of module utils.py =====#
138 |
--------------------------------------------------------------------------------
/_Global_Documentation/Typee_Software_HTML_Documentation/README.md:
--------------------------------------------------------------------------------
1 | # Typee automated software documentation
2 |
3 | The software documentation of **Typee** is automated by the use of fair
4 | utility **PyYadc** (https://github.com/schmouk/pyYadc).
5 |
6 | To further automate this automated documentation, we have imported PyYadc
7 | source code into **Typee** directories tree and we have implemented a _Python_
8 | script to automate the generation of the S/W documentation of **Typee_ code.
9 |
10 | First, have a look in directory
11 | `Typee/_Global_Documentation/Typee_Softxare_Documentation`. You will find
12 | there two interesting files:
13 |
14 | 1. `typee_software_doc.html`, and
15 | 2. `typee_automated_documentation_script.py`.
16 |
17 |
18 | ## 1. `typee_software_doc.html`
19 |
20 | The software documentation of **Typee** is generated by PyYadc in an HTML
21 | form. It describes every _package_ of the software and for each of these,
22 | every _Python module_. Every classes, consts and documentation comments in
23 | each _module_ is also described in there.
24 |
25 | This is the official Software documentation of **Typee**.
26 |
27 | To generate it, just run the next _Python_ script
28 |
29 |
30 | ## 2. Automated script `typee_automated_documentation_script.py`
31 |
32 | You may either run this script at command line in any kind of console:
33 |
34 | $ python typee_automated_documentation_script.py
35 |
36 | or run it from your favorite Python development framework (remember, coders
37 | are strongly recommended to use Eclipse Photon on Windows, for which file
38 | `.pydevproject` at root directory contains all the needed stuff (notably, the
39 | PYTHON_PATH set for you) to be able to run this script directly within the
40 | framework.
41 |
42 |
43 | ## Annex - This document revisions history
44 |
45 | | Date | Rev. | Author(s) | Comments |
46 | |---|---|---|---|
47 | | 2018-07-24 | 0.0.1 | Schmouk | Very first creation |
48 | | 2018-07-24 | 1.0 | Schmouk | This document is now considered as being validated. |
49 | | | | | |
50 |
--------------------------------------------------------------------------------
/_Global_Documentation/Typee_Software_HTML_Documentation/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/_Global_Documentation/Typee_Software_HTML_Documentation/__init__.py
--------------------------------------------------------------------------------
/_Global_Documentation/Typee_Software_HTML_Documentation/typee_automated_documentation_script.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 | """
4 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | """
24 |
25 | #=============================================================================
26 | from os import rename as os_rename, remove as os_remove
27 |
28 | from PyYadc.src.html_generator import HtmlGenerator
29 |
30 |
31 | #=============================================================================
32 | if __name__ == '__main__':
33 | """
34 | This script runs PyYadc onto directory 'src/' of this Typee software.
35 | """
36 |
37 | print( "Generating documentation for Typee Project" )
38 | HtmlGenerator( '../../../Typee/src', "Typee Software Documentation" )
39 |
40 |
41 | src_docpath = '../../src/src_doc.html'
42 | dst_docpath = 'typee_software_doc.html'
43 |
44 | try:
45 | os_rename( src_docpath, dst_docpath )
46 | except OSError:
47 | os_remove( dst_docpath )
48 | os_rename( src_docpath, dst_docpath )
49 |
50 |
51 | print( '-- done!' )
52 |
53 | #===== end of _Global_Documentation.Typee_Software_Documentation.typee_automated_documentation_script =====#
54 |
--------------------------------------------------------------------------------
/_Global_Documentation/__main_index.md:
--------------------------------------------------------------------------------
1 | # Software Global Documentation - Index for all documents
2 |
3 | This document is part of the Open Source project **Typee**. As such, it is
4 | delivered under the MIT license:
5 | ```
6 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy
9 | of this software and associated documentation files (the "Software"), to deal
10 | in the Software without restriction, including without limitation the rights
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | copies of the Software, and to permit persons to whom the Software is
13 | furnished to do so, subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in all
16 | copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | SOFTWARE.
25 | ```
26 |
27 | This document is the index of all documents provided for the description or
28 | the specification of **Typee** software architecture, modules and files.
29 |
30 | It is part of the overall documentation of **Typee** and could be used for
31 | the feeding of the related **http://www.typee.ovh** web site, placed at pages
32 | dedicated to developers.
33 |
34 |
35 | ## List of documents
36 |
37 | | Name & direct link | Topic(s) | Place | Comments |
38 | |---|:---:|---|---|
39 | | [README.md](../README.md) | General Documentation | reporitory root | General description of **Typee** project and language |
40 | | [README.md](Typee_Software_HTML_Documentation/README.md) | S/W documentation | \_Global\_Documentation/ Typee_Software\_ HTML_Documentation / | Usage of automated script to generate the whole **Typee** S/W documentation |
41 | | [scanner_tokenization_tests.md](../src/Tests/Documentation-README/scanner_tokenization_tests.md) | Tests | src/ Tests/ Documentation-README/ | Explanations on how to test the Front-End Scanner and how to modify related tests files |
42 | | [typee_front_end_parser_ documentation.md](typee_front_end_parser_documentation.md) | S/W architecture | \_Global\_Documentation/ | Complete description of the role and the architecture of the Front-End **Parser** of **Typee** translator |
43 | | [typee_front_end_scanner_ sw_documentation.md](typee_front_end_scanner_sw_documentation.md) | S/W architecture | \_Global\_Documentation/ | Complete description of the software architecture and data structures of the Front-End **Scanner** of **Typee** translator |
44 | | [typee_software_doesign.html](typee_software_design.html) | S/W documentation | \_Global\_Documentation/ | Design document of the **Typee** translator |
45 | | [typee_software_doc.html](Typee_Software_HTML_Dcumentation/typee_software_doc.html) | S/W documentation | \_Global\_Documentation/ Typee_Software\_ HTML_Documentation | HTML documentation of **all** packages, modules and classes of the whole **Typee** software |
46 | | | | | |
47 |
48 |
49 | (_notice to contributors: either try to maintain this index in alphabetical
50 | order, and as soon as this would be useful create as many tables as
51 | interesting topics, grouping related documents by topics - in which case a
52 | same document could be appearing in multiple topics_)
53 |
54 |
55 |
56 | ## This document revisions history
57 |
58 | | Date | Rev. | Author(s) | Comments |
59 | |---|---|---|---|
60 | | 2018-07-14 | 0.0.1 | Schmouk | Very first creation |
61 | | 2018-07-15 | 0.0.2 | Schmouk | Minor typo correction; modified ordering of documents; added column **Topic** |
62 | | 2018-07-20 | 0.0.3 | Schmouk | Added copyright, license text and index to the Front-End Parser documentation |
63 | | 2018-07-23 | 0.0.4 | Schmouk | Added reference to the Front-End Scanner S/W architecture documentation |
64 | | 2018-07-24 | 0.0.5 | Schmouk | Added ref to the usage of the script that automates the generation of **Typee** S/W documentation |
65 | | 2018-07-24 | 0.0.6 | Schmouk | Added links to the reference table, then corrected the few erroneous ones |
66 | | 2018-07-25 | 0.0.7 | Schmouk | Modified directory name for **Typee** HTML automated documentation; added reference to the HTML documentation of the whole software |
67 | | 2018-08-12 | 0.0.8 | Schmouk | Added design document of Typee translator |
68 | | | | | |
69 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-slate
2 | show_downloads: true
--------------------------------------------------------------------------------
/src/BackEnd/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/Commons/IntermediateCode/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/Commons/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/Commons/access.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | from enum import IntEnum, auto
26 |
27 | from Utils.ut_serialized_enum import UTSerializedEnum
28 |
29 |
30 | #=============================================================================
31 | class Access( IntEnum ):
32 | """
33 | Descriptors for access roles on variables, functions, classes and methods.
34 | This class is just used as a namespace.
35 | """
36 | #--------------------------------------------------------------------------
37 | PUBLIC = auto()
38 | PROTECTED = auto()
39 | HIDDEN = auto()
40 |
41 |
42 | #=============================================================================
43 | class AccessStack( list ):
44 | """
45 | The class of push-and-pop stacks containing access qualifiers.
46 | To be used for the storage of current access status along the
47 | nested instructions blocks (i.e. levels of braces).
48 | """
49 | #--------------------------------------------------------------------------
50 | def __init__(self) -> None:
51 | super().__init__()
52 | self._current_level = 0
53 | self.append( self._DEFAULT )
54 |
55 | #-------------------------------------------------------------------------
56 | def add_level(self, access_qualif: Access = None) -> None:
57 | self._current_level += 1
58 | try:
59 | self[ self._current_level ] = access_qualif or self._DEFAULT
60 | except:
61 | self.append( access_qualif or self._DEFAULT )
62 |
63 | #-------------------------------------------------------------------------
64 | def get_current(self) -> Access:
65 | return self[ self._current_level ]
66 |
67 | #-------------------------------------------------------------------------
68 | def suppress_level(self) -> None:
69 | if self._current_level > 0:
70 | self._current_level -= 1
71 |
72 | #--------------------------------------------------------------------------
73 | # Class data
74 | _DEFAULT = Access.PUBLIC
75 |
76 |
77 | #=============================================================================
78 | class SerializedAccess( UTSerializedEnum ):
79 | """
80 | This class eases the serialization of protection access values in files.
81 | It offers read() and write() goodies of Access values from and to files.
82 | """
83 | #-------------------------------------------------------------------------
84 | def __new__(cls):
85 | '''
86 | Class meta-constructor.
87 | '''
88 | super().__new__( Access )
89 |
90 | #===== end of Commons.access =====#
91 |
--------------------------------------------------------------------------------
/src/FrontEnd/Elaborator/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/FrontEnd/Elaborator/fe_elaborator.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | # no import.
26 |
27 |
28 | #=============================================================================
29 | class FEElaborator:
30 | """
31 | Base class for the Elaboration step of Typee front-End.
32 | """
33 | #-------------------------------------------------------------------------
34 | def __init__(self, params) -> None:
35 | '''
36 | Constructor.
37 |
38 | description
39 |
40 | Args:
41 | ...
42 |
43 | Returns:
44 | ...
45 |
46 | Raises:
47 | ...
48 | '''
49 | pass
50 |
51 | #-------------------------------------------------------------------------
52 |
53 | #===== end of FrontEnd.Elaborator.fe_elaborator =====#
54 |
--------------------------------------------------------------------------------
/src/FrontEnd/Elaborator/fe_symbols_elaborator.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | from FrontEnd.Elaborator.fe_elaborator import FEElaborator
26 |
27 |
28 | #=============================================================================
29 | class FESymbolsElaborator( FEElaborator ):
30 | """
31 | Class description.
32 | """
33 | #-------------------------------------------------------------------------
34 | def __init__(self, params) -> None:
35 | '''
36 | Constructor.
37 |
38 | description
39 |
40 | Args:
41 | ...
42 |
43 | Returns:
44 | ...
45 |
46 | Raises:
47 | ...
48 | '''
49 | super().__init__()
50 |
51 | #-------------------------------------------------------------------------
52 |
53 | #===== end of FrontEnd.Elaborator.fe_symbols_elaborator =====#
54 |
--------------------------------------------------------------------------------
/src/FrontEnd/Elaborator/fe_types_elaborator.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | from FrontEnd.Elaborator.fe_elaborator import FEElaborator
26 |
27 |
28 | #=============================================================================
29 | class FETypesElaborator( FEElaborator ):
30 | """
31 | Class description.
32 | """
33 | #-------------------------------------------------------------------------
34 | def __init__(self, params) -> None:
35 | '''
36 | Constructor.
37 |
38 | description
39 |
40 | Args:
41 | ...
42 |
43 | Returns:
44 | ...
45 |
46 | Raises:
47 | ...
48 | '''
49 | pass
50 |
51 | #-------------------------------------------------------------------------
52 |
53 | #===== end of FrontEnd.Elaborator.fe_types_elaborator =====#
54 |
--------------------------------------------------------------------------------
/src/FrontEnd/Errors/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/FrontEnd/IntermediateCode/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/FrontEnd/IntermediateCode/fe_icblock.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | from FrontEnd.IntermediateCode.fe_icnode import FEICNode
26 | ##from FrontEnd.IntermediateCode.fe_icleaf import FEICLeaf
27 |
28 |
29 | #=============================================================================
30 | class FEICBlock( FEICNode ):
31 | """
32 | The class of blocks of tokens in Intermediate Code trees.
33 | """
34 |
35 | #-------------------------------------------------------------------------
36 | def __init__(self) -> None: ##, parent:FEICNode=None):
37 | '''
38 | Constructor.
39 | '''
40 | super().__init__( [] ) ## content is an empty list (of FEICNode-s)
41 |
42 | #-------------------------------------------------------------------------
43 | def __iadd__(self, ic_node: FEICNode):
44 | '''
45 | Appends a new node into this block.
46 | '''
47 | self.content.append( ic_node )
48 | return self
49 |
50 | #-------------------------------------------------------------------------
51 | def walk(self) -> None:
52 | '''
53 | Walks through the list of nodes contained within
54 | this block.
55 | Walk-through is depth-first implemented.
56 | Returns:
57 | every content of the leaves in this block,
58 | in a depth-first walking through manner.
59 | '''
60 | for icnode in self.content:
61 | yield from icnode.walk()
62 |
63 | #===== end of FrontEnd.IntermediateCode.fe_icblock =====#
64 |
--------------------------------------------------------------------------------
/src/FrontEnd/IntermediateCode/fe_icleaf.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2019-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | from FrontEnd.IntermediateCode.fe_icnode import FEICNode
26 |
27 |
28 | #=============================================================================
29 | class FEICLeaf( FEICNode ):
30 | """
31 | Class of leaves in Intermediate Code trees.
32 | """
33 | #-------------------------------------------------------------------------
34 | def __init__(self, content) -> None:
35 | '''
36 | Constructor.
37 |
38 | Args:
39 | content: a reference to the content of this leaf.
40 | '''
41 | super().__init__( content )
42 |
43 | #-------------------------------------------------------------------------
44 | def set_parent(self, parent: FEICNode):
45 | '''
46 | Sets the parent of this node.
47 | '''
48 | pass
49 |
50 | #-------------------------------------------------------------------------
51 | def __iter__(self):
52 | return self
53 |
54 | #-------------------------------------------------------------------------
55 | def __next__(self):
56 | return self.content
57 |
58 | #-------------------------------------------------------------------------
59 | def walk(self) -> FEICNode:
60 | '''
61 | Walks over this leaf.
62 |
63 | Returns:
64 | A reference to the content of this leaf.
65 | '''
66 | return self.content
67 |
68 | #===== end of FrontEnd.IntermediateCode.fe_icleaf =====#
69 |
--------------------------------------------------------------------------------
/src/FrontEnd/IntermediateCode/fe_icnode.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | class FEICNode:
26 | """
27 | Basic interface for all types of nodes in Intermediate Code Trees.
28 | This is a virtual item of a mental construction. It might be later suppressed!
29 | """
30 |
31 | #-------------------------------------------------------------------------
32 | def __init__(self, content=None) -> None:
33 | '''
34 | Cnstructor.
35 |
36 | Args:
37 | content:
38 | A reference to the content to be associated with this IC node.
39 | '''
40 | self.content = content
41 |
42 | #-------------------------------------------------------------------------
43 | def set_parent(self, parent):
44 | '''
45 | Sets the parent of this node.
46 | '''
47 | self.parent = parent
48 |
49 | #-------------------------------------------------------------------------
50 | def walk(self) -> None:
51 | '''
52 | Walks through the list of nodes contained within this block.
53 | Walk-through is depth-first implemented.
54 | HAS TO BE IMPLEMENTED IN INHERITING CLASSES.
55 | '''
56 | raise NotImplementedError()
57 |
58 | #===== end of FrontEnd.IntermediateCode.fe_icnode =====#
59 |
--------------------------------------------------------------------------------
/src/FrontEnd/IntermediateCode/fe_ictree.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2019-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | from FrontEnd.IntermediateCode.fe_icblock import FEICBlock
26 | from FrontEnd.IntermediateCode.fe_icnode import FEICNode
27 |
28 |
29 | #=============================================================================
30 | class FEICTree:
31 | """
32 | The class of Intermediate Code trees.
33 | """
34 |
35 | #-------------------------------------------------------------------------
36 | def __init__(self) -> None:
37 | '''
38 | Constructor.
39 | '''
40 | self._root = FEICBlock()
41 | self._current = self._root
42 |
43 | #-------------------------------------------------------------------------
44 | def __iadd__(self, ic_node: (FEICBlock,FEICNode)):
45 | '''
46 | In-place appends a new block or node to this intermediate code tree.
47 |
48 | Returns a reference to this IC tree.
49 | '''
50 | ic_node.set_parent( self._current )
51 | self._current += ic_node
52 | if isinstance( ic_node, FEICBlock ):
53 | self._current = ic_node
54 | return self
55 |
56 | #-------------------------------------------------------------------------
57 | def up_level(self) -> None:
58 | '''
59 | Goes one level up in the tree, i.e. back to parent block in the IC Tree.
60 | '''
61 | self._current = self._current.parent
62 |
63 | #-------------------------------------------------------------------------
64 | def walk(self) -> None:
65 | '''
66 | Walks through this Intermediate Code tree, starting at its root.
67 | Walk-through is depth-first implemented.
68 | '''
69 | self._root.walk()
70 |
71 | #===== end of FrontEnd.IntermediateCode.fe_ictree =====#
72 |
--------------------------------------------------------------------------------
/src/FrontEnd/IntermediateCode/fe_tokenized_icode.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | # no import.
26 |
27 |
28 | #=============================================================================
29 | FETokenizedICode = list
30 | """
31 | Well, the tokenized intermediate code for the Typee Front-End
32 | will be a simple list: a list of intermediate code Nodes.
33 | Nevertheless, we still declare a dedicated type for it for the
34 | clearness of the developed code.
35 | """
36 |
37 | #===== end of FrontEnd.IntermediateCode.fe_tokenized_icode =====#
38 |
--------------------------------------------------------------------------------
/src/FrontEnd/Parser/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/FrontEnd/Scanner/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/FrontEnd/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/IntermediateCode/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Typee-Language/Typee/adf61fee616bd798dae3bdc6710fd819e188e925/src/IntermediateCode/__init__.py
--------------------------------------------------------------------------------
/src/IntermediateCode/ic_ast.py:
--------------------------------------------------------------------------------
1 | """
2 | Copyright (c) 2019-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | SOFTWARE.
21 | """
22 |
23 | #=============================================================================
24 | from Utils.Trees.ut_tree_leaf import UTTreeLeaf
25 | from Utils.Trees.ut_tree_node import UTTreeNode
26 | from Utils.Trees.ut_tree import UTTree
27 |
28 |
29 | #=============================================================================
30 | class ICAst( UTTree ):
31 | """
32 | The class of Abstract Syntaxic Trees.
33 | Those trees are created by the Front-End Parser.
34 | They are used by the Front-End Elaborator, when elaborating symbols and
35 | types for instance.
36 | They are used also by the types checker - i.e. the Elaborator.
37 | Finally, they are used by the Back-End Programming-Language Translators.
38 | """
39 | #-------------------------------------------------------------------------
40 | def __init__(self) -> None:
41 | '''
42 | Constructor.
43 | '''
44 | super().__init__()
45 |
46 | #-------------------------------------------------------------------------
47 |
48 | #===== end of IntermediateCode.ic_ast =====#
49 |
--------------------------------------------------------------------------------
/src/Libs/Files/f_types.ty:
--------------------------------------------------------------------------------
1 | /***
2 | Copyright (c) 2019-2021 Philippe Schmouker, schmouk (at) typee.ovh
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | SOFTWARE.
21 | ***/
22 |
23 | //=============================================================================
24 | // Built-in library Files
25 | // Module f_types.ty
26 |
27 | //=============================================================================
28 | // Types aliases
29 | type uint64 as FileCursorPos; /** type for file cursor position - unit: bytes. */
30 | type int64 as FileRelCursorPos; /** type for relative positionning of file cursor. */
31 | type uint64 as FileIndex; /** type for file index position - unit: items size. */
32 | type uint64 as FileSize; /** type for file sizes - unit: bytes. */
33 |
34 | //===== end of module Files.f_types.ty =====//
35 |
--------------------------------------------------------------------------------
/src/Libs/Random/Bases/base_mrg.ty:
--------------------------------------------------------------------------------
1 | /***
2 | Copyright (c) 2019-2021 Philippe Schmouker, schmouk (at) typee.ovh
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | SOFTWARE.
21 | ***/
22 |
23 | //=============================================================================
24 | // Built-in library Random
25 | // Module Bases/base_mrg.ty
26 |
27 | //=============================================================================
28 | from Random.rand32 import Rand32;
29 | from Random.Bases.base_random import BaseRandom;
30 |
31 | //=============================================================================
32 | class BaseMRG : BaseRandState< Rand32, uint32, K_SIZE >
33 | /**
34 | Definition of the base class for all MRG pseudo-random generators.
35 |
36 | Multiple Recursive Generators (MRGs) uses recurrence to evaluate pseudo-random
37 | numbers series. Recurrence is of the form:
38 |
39 | x(i) = A * SUM[ x(i-k) ] mod M,
40 |
41 | for 2 to more different values of k.
42 |
43 | MRGs offer very large periods with the best known results in the evaluation of
44 | their randomness, as stated in the evaluation done by Pierre L'Ecuyer and
45 | Richard Simard (Université de Montréal) in "TestU01: A C Library for Empirical
46 | Testing of Random Number Generators - ACM Transactions on Mathematical Software,
47 | vol.33 n.4, pp.22-40, August 2007". It is recommended to use such pseudo-random
48 | numbers generators rather than LCG ones for serious simulation applications.
49 |
50 | See Rand287 for a short period MR-Generator (2^287, i.e. 2.49e+86) with low
51 | computation time but 256 integers memory consumption.
52 | See Rand1457 for a longer period MR-Generator (2^1457, i.e. 4.0e+438) and longer
53 | computation time (2^31-1 modulus calculations) but less memory space consumption
54 | (47 integers).
55 | See Rand49507 for a far longer period (2^49507, i.e. 1.2e+14903) with lower
56 | computation time too (32-bits modulus) but use of more memory space (1597
57 | integers).
58 |
59 | Please notice that this class and all its inheriting sub-classes are callable.
60 | Example:
61 |
62 | rand = BaseMRG()
63 | print( rand() ) # prints a uniform pseudo-random value within [0.0, 1.0)
64 | print( rand(a) ) # prints a uniform pseudo-random value within [0.0, a)
65 | print( rand(a,b) ) # prints a uniform pseudo-random value within [a , b)
66 |
67 | Reminder:
68 | We give you here below a copy of the table of tests for the LCGs that have
69 | been implemented in PyRandLib, as provided in paper "TestU01, ...".
70 |
71 | | class name | TU01 generator name | Memory Usage | Period | time-32bits | time-64 bits | SmallCrush fails | Crush fails | BigCrush fails |
72 | | ---------- | ------------------- | --------------- | ------- | ----------- | ------------ | ---------------- | ----------- | -------------- |
73 | | Rand287 | Marsa-LFIB4 | 256 x 4-bytes | 2^287 | 3.40 | 0.8 | 0 | 0 | 0 |
74 | | Rand1457 | DX-47-3 | 47 x 4-bytes | 2^1457 | n.a. | 1.4 | 0 | 0 | 0 |
75 | | Rand49507 | DX-1597-2-7 | 1,597 x 4-bytes | 2^49507 | n.a. | 1.4 | 0 | 0 | 0 |
76 |
77 | * _small crush_ is a small set of simple tests that quickly tests some of
78 | the expected characteristics for a pretty good PRG;
79 | * _crush_ is a bigger set of tests that test more deeply expected random
80 | characteristics;
81 | * _big crush_ is the ultimate set of difficult tests that any GOOD PRG
82 | should definitively pass.
83 | */
84 | {
85 | :public:
86 |
87 | //-------------------------------------------------------------------------
88 | BaseMRG()
89 | /**
90 | Constructor.
91 | The shuffling of the local current time value is used as the
92 | initial seed.
93 | */
94 | {
95 | me.set_state();
96 | }
97 | //-------------------------------------------------------------------------
98 | BaseMRG( const MyInternalState seed_state )
99 | /**
100 | Constructor.
101 | seed_state is a valid internal state that has been previously loaded in
102 | memory with get_state().
103 | */
104 | {
105 | me.set_state( seed_state );
106 | }
107 | }
108 |
109 | //===== end of module Random.Bases.base_mrg.ty =====//
110 |
--------------------------------------------------------------------------------
/src/Libs/Random/Bases/base_rand_state.ty:
--------------------------------------------------------------------------------
1 | /***
2 | Copyright (c) 2019-2021 Philippe Schmouker, schmouk (at) typee.ovh
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | SOFTWARE.
21 | ***/
22 |
23 | //=============================================================================
24 | // Built-in library Random
25 | // Module Bases/base_rand_state.ty
26 |
27 | // defined classes
28 | fwd class BaseRandState< RandT, ValuesT, const uint16 K_SIZE >;
29 | fwd class InternalState< RandT, ValuesT, const uint16 K_SIZE >;
30 |
31 |
32 | //=============================================================================
33 | class BaseRandState< RandT, ValuesT, const uint16 K_SIZE >
34 | /**
35 | Definition of the base class for all pseudo-random generators that are based
36 | on internal states with more than 1 value.
37 |
38 | Those values are of type ValuesT. K_SIZE is their number. They are stored in
39 | arrays that are initialized with a pseudo-random generator of type RandT.
40 | */
41 | {
42 | :public:
43 |
44 | //-------------------------------------------------------------------------
45 | // Shortcuts definitions
46 | type BaseRandState< RandT, ValuesT, K_SIZE > as BaseRandType;
47 | type InternalState< RandT, ValuesT, K_SIZE > as InternStateType;
48 |
49 | //-------------------------------------------------------------------------
50 | BaseRandType()
51 | /**
52 | Constructor.
53 | The shuffling of the local current time value is used as the
54 | initial seed.
55 | */
56 | {
57 | me.set_state();
58 | }
59 |
60 | //-------------------------------------------------------------------------
61 | BaseRandType( const InternStateType seed_state )
62 | /**
63 | Constructor.
64 | seed_state is a valid internal state that has been previously loaded in
65 | memory with get_state().
66 | */
67 | {
68 | me.set_state( seed_state );
69 | }
70 |
71 | //-------------------------------------------------------------------------
72 | InternStateType get_state()
73 | /**
74 | Returns an object capturing the current internal state of the generator.
75 | This object can be passed to set_state() to restore the state. It is a
76 | list containing me.K_LIST_SIZE integers and an index pointing in this
77 | list (index value being then in [0:me.K_SIZE).
78 | */
79 | {
80 | return me._state;
81 | }
82 |
83 | //-------------------------------------------------------------------------
84 | none set_state()
85 | /**
86 | Initiliazes the internal state series from scratch.
87 | */
88 | {
89 | me._state = InternStateType();
90 | }
91 |
92 | //-------------------------------------------------------------------------
93 | none set_state( const InternStateType seed_state )
94 | /**
95 | seed_state should have been obtained from a previous call to
96 | getstate(), and setstate() restores the internal state of the
97 | generator to what it was at the time setstate() was called.
98 | */
99 | {
100 | me._state = seed_state;
101 | }
102 |
103 | //-------------------------------------------------------------------------
104 | protected InternStateType _state;
105 | }
106 |
107 |
108 | //=============================================================================
109 | class InternalState< RandT, ValuesT, const uint16 K_SIZE >
110 | /**
111 | Definition of the internal state for pseudo-random generators with more than
112 | one value as their internal states.
113 |
114 | Those values are of type ValuesT. K_SIZE is their number. They are stored in
115 | arrays that are initialized with a pseudo-random generator of type RandT.
116 | */
117 | {
118 | :public:
119 |
120 | //-----------------------------------------------------------------
121 | InternalState< RandT, ValuesT, K_SIZE >()
122 | /**
123 | Constructor.
124 | A shuffling of the local current time value is used as the
125 | initial seed.
126 | */
127 | {
128 | RandT rnd = RandT();
129 | me._list = [ ValuesT( rnd() ) for _ in [:K_SIZE] ]; // got it? Enjoy Typee! ;)
130 | me._index = 0;
131 | }
132 |
133 | //-----------------------------------------------------------------
134 | uint16 _index;
135 | array[K_SIZE] _list;
136 | }
137 |
138 | //===== end of module Random.Bases.base_rand_state.ty =====//
139 |
--------------------------------------------------------------------------------
/src/Libs/Random/Bases/base_random.ty:
--------------------------------------------------------------------------------
1 | /***
2 | Copyright (c) 2019-2021 Philippe Schmouker, schmouk (at) typee.ovh
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | SOFTWARE.
21 | ***/
22 |
23 | //=============================================================================
24 | // Built-in library Random
25 | // Module Bases/base_random.ty
26 |
27 | //=============================================================================
28 | class BaseRandom
29 | /**
30 | This is the base class for all pseudo-random numbers generators.
31 | */
32 | {
33 | :public:
34 |
35 | //-------------------------------------------------------------------------
36 | abstract const float64 random();
37 | /**
38 | This is the core of the pseudo-random generator.
39 | Returned values should be uniformly distributed within [0.0, 1.0).
40 | */
41 |
42 | //-------------------------------------------------------------------------
43 | const float64 operator () ()
44 | /**
45 | Returns a pseudo-random value in interval [0.0, 1.0).
46 | Makes any random object "callable".
47 | */
48 | {
49 | return me.random();
50 | }
51 | //-------------------------------------------------------------------------
52 | const float64 operator () ( const float64 b )
53 | /**
54 | Returns a pseudo-random value in interval: [0.0, b) if b > 0 and (b, 0.0] otherwise.
55 | */
56 | {
57 | return b * me.random();
58 | }
59 | //-------------------------------------------------------------------------
60 | const float64 operator () ( const float64 a, const float64 b )
61 | /**
62 | Returns a pseudo-random value in interval: [a, b) if a >= b and [b, a) otherwise.
63 | */
64 | {
65 | return (max - min) * me.random() + min;
66 | }
67 | //-------------------------------------------------------------------------
68 | const int32 operator() ()
69 | /**
70 | Returns a pseudo-random value in interval: [0, 0x7fff_ffff).
71 | */
72 | {
73 | return const int32( me.random() * 0x7fff_ffff );
74 | }
75 | //-------------------------------------------------------------------------
76 | const int64 operator() ()
77 | /**
78 | Returns a pseudo-random value in interval: [0, 0x7fff_ffff_ffff_ffff).
79 | */
80 | {
81 | return const int64( me.random() * 0x7fff_ffff_ffff_ffff );
82 | }
83 | //-------------------------------------------------------------------------
84 | const int64 operator () ( const int64 b )
85 | /**
86 | Returns a pseudo-random value in interval: [0, b) if b > 0 and (b, 0] otherwise.
87 | */
88 | {
89 | return const int64( b * me.random() );
90 | }
91 | //-------------------------------------------------------------------------
92 | const int64 operator () ( const int64 a, const int64 b )
93 | /**
94 | Returns a pseudo-random value in interval: [a, b) if a >= b and [b, a) otherwise.
95 | */
96 | {
97 | return const int64( (max - min ) * me.random() + min );
98 | }
99 | //-------------------------------------------------------------------------
100 | const uint32 operator() ()
101 | /**
102 | Returns a pseudo-random value in interval: [0, 0xffff_ffff).
103 | */
104 | {
105 | return const uint32( me.random() * 0x7fff_ffff );
106 | }
107 | //-------------------------------------------------------------------------
108 | const uint64 operator() ()
109 | /**
110 | Returns a pseudo-random value in interval: [0, 0xffff_ffff_ffff_ffff).
111 | */
112 | {
113 | return const uint64( me.random() * 0xffff_ffff_ffff_ffff );
114 | }
115 | //-------------------------------------------------------------------------
116 | const uint64 operator () ( const uint64 b )
117 | /**
118 | Returns a pseudo-random value in interval: [0, b) if b > 0 and (b, 0] otherwise.
119 | */
120 | {
121 | return const int64( b * me.random() );
122 | }
123 | //-------------------------------------------------------------------------
124 | const uint64 operator () ( const uint64 a, const uint64 b )
125 | /**
126 | Returns a pseudo-random value in interval: [a, b) if a >= b and [b, a) otherwise.
127 | */
128 | {
129 | return const int64( (max - min ) * me.random() + min );
130 | }
131 | }
132 |
133 | //===== end of module Random.Bases.base_random.ty =====//
--------------------------------------------------------------------------------
/src/Libs/Thread/daemon_thread.ty:
--------------------------------------------------------------------------------
1 | /***
2 | Copyright (c) 2019-2021 Philippe Schmouker, schmouk (at) typee.ovh
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | SOFTWARE.
21 | ***/
22 |
23 | //=============================================================================
24 | // Built-in library Thread
25 | // Module daemon_thread.ty
26 |
27 | // defined class
28 | fwd class DaemonThread;
29 |
30 | //=============================================================================
31 | from Thread.base_thread import BaseThread;
32 | from Thread.thread_exceptions import all ;
33 |
34 | //=============================================================================
35 | // targeted languages specifics
36 | embed py {{
37 | import threading
38 | }}
39 |
40 | //=============================================================================
41 | class DaemonThread : BaseThread
42 | /**
43 | Base class for daemon threads in Typee built-in library Thread.
44 | Daemon threads are neither stoppable nor destroyable threads.
45 | Once run, they keep on running even after the program that created
46 | them has terminated.
47 | Meanwhile, it is always possible to set a daemonic thread as no
48 | more being so.
49 | */
50 | {
51 | :public:
52 |
53 | //-------------------------------------------------------------------------
54 | DaemonThread()
55 | /**
56 | Default constructor.
57 | */
58 | embed cpp {{ : BaseThread() }}
59 | {
60 | embed py {{
61 | threading.Thread.__init__( daemon=True )
62 | }}
63 |
64 | embed java {{
65 | setDaemon( true ) ;
66 | }}
67 | }
68 |
69 | //-------------------------------------------------------------------------
70 | DaemonThread( const ? in (str,str16) name )
71 | /**
72 | Constructor with defined name for this thread.
73 | */
74 | embed cpp {{ : BaseThread(name) }}
75 | {
76 | embed py {{
77 | threading.Thread.__init__( name=name, daemon=True )
78 | }}
79 |
80 | embed java {{
81 | super( name );
82 | setDaemon( true );
83 | }}
84 | }
85 |
86 | //-------------------------------------------------------------------------
87 | none destroy ()
88 | /**
89 | Destructor for this base class.
90 | Caution:
91 | Behaviors may differ between different targeted programming languages.
92 | */
93 | {
94 | BaseThread.destroy();
95 | }
96 |
97 | //-------------------------------------------------------------------------
98 | const bool is_daemon() exclude java, cs
99 | /**
100 | Returns true if this thread is daemonic, and false otherwise.
101 | */
102 | {
103 | embed py {{
104 | return self.daemon
105 | }}
106 |
107 | embed cpp {{
108 | return true;
109 | }}
110 | }
111 |
112 | //-------------------------------------------------------------------------
113 | none join()
114 | /**
115 | This is a synchronization point for external code.
116 | Daemonic threads are NOT joinable: they run for ever.
117 | To avoid any deadlock, and while to 'join()' on a deamonic thread is
118 | not available with some platforms, we nevertheless allow calls to
119 | 'join()' inTypee: joining on daemonic threads returns immediately.
120 | */
121 | {}
122 |
123 | //-------------------------------------------------------------------------
124 | none set_daemon( const bool is_daemon )
125 | /**
126 | Sets the daemonic status of this thread.
127 | */
128 | {
129 | embed py {{
130 | self.daemon = is_daemon
131 | }}
132 |
133 | embed java {{
134 | setDaemon( is_daemon );
135 | }}
136 |
137 | embed cs {{
138 | if ( _cs_thread == null )
139 | throw new ThreadNotStartedException( "set_daemon()" );
140 | _cs_thread.IsBackground = is_daemon;
141 | }}
142 | }
143 |
144 | //-------------------------------------------------------------------------
145 | none start()
146 | /**
147 | Starts this thread in a new thread context and runs its method run().
148 | Raises ThreadException if thread cannot be created or run.
149 | */
150 | {
151 | try {
152 | BaseThread.start();
153 | me.set_daemon( true );
154 | embed cpp {{
155 | this->_c_thread->detach();
156 | }}
157 | }
158 | except ( Exception as e ) {
159 | raise e;
160 | }
161 | }
162 | }
163 |
164 | //===== end of module Thread.daemon_thread.ty =====//
165 |
--------------------------------------------------------------------------------
/src/Libs/Thread/thread_guarded_block.ty:
--------------------------------------------------------------------------------
1 | /***
2 | Copyright (c) 2019-2021 Philippe Schmouker, schmouk (at) typee.ovh
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | SOFTWARE.
21 | ***/
22 |
23 | //=============================================================================
24 | // Built-in library Thread
25 | // Module thread_guarded_block.ty
26 |
27 | // defined classes
28 | fwd class ThreadGuardedBlock;
29 | fwd class ThreadNamedGuardedBlock;
30 |
31 | //=============================================================================
32 | from Thread.thread_mutex import ThreadMutex;
33 |
34 |
35 | //=============================================================================
36 | class ThreadGuardedBlock : ThreadMutex
37 | /**
38 | Guarded blocks (of statements) are parts of code that cannot be processed
39 | simultaneously by different threads.
40 | A mutual exclusive access is applied to them.
41 | */
42 | {
43 | :public:
44 |
45 | //-------------------------------------------------------------------------
46 | ThreadGuardedBlock()
47 | /**
48 | Default constructor.
49 | */
50 | {
51 | ThreadMutex();
52 | me.lock();
53 | }
54 |
55 | //-------------------------------------------------------------------------
56 | none destroy ()
57 | /**
58 | Destructor.
59 | Caution:
60 | Behaviors may differ between different targeted programming languages.
61 | */
62 | {
63 | me.unlock();
64 | }
65 | }
66 |
67 |
68 | //=============================================================================
69 | class ThreadNamedGuardedBlock : ThreadGuardedBlock
70 | /**
71 | Named Guarded blocks (of statements) are used to guard a dedicated part of
72 | code with statement 'with'.
73 | Example:
74 | with ThreadNamedGuardedBlock( 'block-1' ){
75 | // ... guarded block of statements ...
76 | }
77 | */
78 | {
79 | :public:
80 |
81 | //-------------------------------------------------------------------------
82 | ThreadNamedGuardedBlock( ? name )
83 | /**
84 | Constructor.
85 | name is the name associated with the guarded block of instruction.
86 | It may be of any hashable type (string, integer, object, etc.)
87 | */
88 | {
89 | if ( name in me._names )
90 | me._names[ name ].lock();
91 | else
92 | {
93 | me._name = name;
94 | me._names[ name ] = ThreadGuardedBlock();
95 | }
96 | }
97 |
98 | //-------------------------------------------------------------------------
99 | none destroy ()
100 | /**
101 | Destructor.
102 | Caution:
103 | Behaviors may differ between different targeted programming languages.
104 | */
105 | {
106 | me._names[ me._name ].unlock();
107 | }
108 |
109 | :hidden:
110 | //-------------------------------------------------------------------------
111 | ? _name;
112 | static map _names = []:
113 | }
114 |
115 | //===== end of module Thread.thread_guarded_block.ty =====//
116 |
--------------------------------------------------------------------------------
/src/Libs/Thread/thread_guarded_var.ty:
--------------------------------------------------------------------------------
1 | /***
2 | Copyright (c) 2019-2021 Philippe Schmouker, schmouk (at) typee.ovh
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | SOFTWARE.
21 | ***/
22 |
23 | //=============================================================================
24 | // Built-in library Thread
25 | // Module thread_guarded_var.ty
26 |
27 | // defined class
28 | fwd class ThreadGuardedVar;
29 |
30 | //=============================================================================
31 | from Thread.thread_mutex import ThreadMutex;
32 |
33 |
34 | //=============================================================================
35 | class ThreadGuardedVar< VarT >
36 | /**
37 | Guarded variables are variables that are protected from concurrent access.
38 | */
39 | {
40 | :public:
41 |
42 | //-------------------------------------------------------------------------
43 | ThreadGuardedVar()
44 | /**
45 | Default constructor.
46 | */
47 | {
48 | me._mutex = ThreadMutex();
49 | }
50 |
51 | //-------------------------------------------------------------------------
52 | ThreadGuardedVar( const VarT value )
53 | /**
54 | Sets initial value of variable content.
55 | */
56 | {
57 | me._mutex = ThreadMutex();
58 | me._val = value;
59 | }
60 |
61 | //-------------------------------------------------------------------------
62 | none destroy ()
63 | /**
64 | Destructor.
65 | Caution:
66 | Behaviors may differ between different targeted programming languages.
67 | */
68 | {
69 | del me._mutex;
70 | }
71 |
72 | //-------------------------------------------------------------------------
73 | const VarT get()
74 | /**
75 | Returns the guarded value of this variable.
76 | */
77 | {
78 | me._mutex.lock();
79 | const VarT ret_value = me._val;
80 | me._mutex.unlock();
81 | return ret_value;
82 | }
83 |
84 | //-------------------------------------------------------------------------
85 | const VarT set( const VarT value )
86 | /**
87 | Assigns value to this guarded variable.
88 | Returns its new value.
89 | */
90 | {
91 | me._mutex.lock();
92 | me._val = value;
93 | me._mutex.unlock();
94 | return value;
95 | }
96 |
97 | //-------------------------------------------------------------------------
98 | const VarT operator cast VarT ()
99 | /**
100 | Returns the guarded value of this variable.
101 | */
102 | {
103 | return me.get();
104 | }
105 |
106 | //-------------------------------------------------------------------------
107 | const VarT operator = ( const VarT value )
108 | /**
109 | Assigns value to this guarded variable.
110 | */
111 | {
112 | return me.set( value );
113 | }
114 |
115 | :hidden:
116 | //-------------------------------------------------------------------------
117 | VarT _val;
118 | ThreadMutex _mutex;
119 | }
120 |
121 | //===== end of module Thread.thread_guarded_var.ty =====//
122 |
--------------------------------------------------------------------------------
/src/Libs/Thread/utils/utils.ty:
--------------------------------------------------------------------------------
1 | /***
2 | Copyright (c) 2019-2021 Philippe Schmouker, schmouk (at) typee.ovh
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | SOFTWARE.
21 | ***/
22 |
23 | //=============================================================================
24 | // Built-in library Thread
25 | // Module utils.ty
26 |
27 | // defined entities
28 | fwd const int64 sec_to_ms( const float32 time );
29 |
30 | //=============================================================================
31 | const int64 sec_to_ms( const float32 time ) {
32 | try
33 | return int64( 1000.0 * time + 0.5 );
34 | except
35 | return 0xffff_ffff_ffff_ffff
36 | }
37 |
38 | //===== end of module Thread.utils.utils.ty =====//
39 |
--------------------------------------------------------------------------------
/src/Libs/types.ty:
--------------------------------------------------------------------------------
1 | /***
2 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | SOFTWARE.
21 | ***/
22 |
23 | //=============================================================================
24 | // Built-in Types Aliases
25 |
26 | type int8 as byte ;
27 | type int16 as short ;
28 | type int32 as int ;
29 | type int64 as long ;
30 |
31 | type uint8 as ubyte ;
32 | type uint16 as ushort ;
33 | type uint32 as uint ;
34 | type uint64 as ulong ;
35 |
36 | type float32 as float ;
37 | type float64 as double ;
38 |
39 | //===== end of built-in module types.ty =====//
--------------------------------------------------------------------------------
/src/Optimizer/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/Tests/BackEnd/__init__.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 | """
4 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | """
24 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/IntermediateCode/__init__.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 | """
4 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | """
24 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/IntermediateCode/script_ic_tree.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | Copyright (c) 2019-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | """
24 |
25 | #=============================================================================
26 | from FrontEnd.IntermediateCode.fe_icblock import FEICBlock
27 | from FrontEnd.IntermediateCode.fe_icleaf import FEICLeaf
28 | from FrontEnd.IntermediateCode.fe_icnode import FEICNode
29 | from FrontEnd.IntermediateCode.fe_ictree import FEICTree
30 |
31 |
32 | #=============================================================================
33 |
34 | #-------------------------------------------------------------------------
35 | def create_test_tree() -> FEICTree:
36 | '''
37 | '''
38 | my_tree = FEICTree()
39 |
40 | new_block = FEICBlock()
41 | my_tree += new_block
42 | new_block += FEICLeaf( 'C' )
43 |
44 | new_block_2 = FEICBlock()
45 | new_block += new_block_2
46 | new_block_2 += FEICLeaf( 'E' )
47 |
48 | my_tree += FEICLeaf( 'A' )
49 | my_tree += FEICLeaf( 'B' )
50 |
51 | new_block = FEICBlock()
52 | my_tree += new_block
53 | new_block += FEICLeaf( 'D' )
54 |
55 | return my_tree
56 |
57 |
58 |
59 | #-------------------------------------------------------------------------
60 | def walk_through_tree( ic_tree: FEICTree ) -> int:
61 | '''
62 | '''
63 | errors_count = 0
64 | for expected_content, node_content in zip( ['C','E','A','B','D'], ic_tree.walk() ):
65 | if expected_content != node_content:
66 | errors_count += 1
67 | print( expected_content, '->', node_content, end=', ' )
68 | print()
69 |
70 | return errors_count
71 |
72 |
73 | #=============================================================================
74 | if __name__ == '__main__':
75 | """
76 | Script description.
77 | """
78 | #-------------------------------------------------------------------------
79 | test_tree = create_test_tree()
80 | print( walk_through_tree(test_tree), 'error(s)' )
81 |
82 | print( "\n\n-- 2nd test on an empty tree" )
83 | print( walk_through_tree(FEICTree()), 'error(s)' )
84 |
85 |
86 | print( '\n-- done!')
87 |
88 |
89 | #===== end of Tests.FrontEnd.IntermediateCode.script_ic_tree =====#
90 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/Parser_Rules/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/Scanner_Tokens/Data/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/Scanner_Tokens/Data/tokenization_compound_solution.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | Copyright (c) 2018-2021 Philippe Schmouker, Typhee project, http://www.typee.ovh
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | """
24 |
25 | #=============================================================================
26 | from FrontEnd.IntermediateCode.fe_icode_token_node import *
27 |
28 |
29 | #=============================================================================
30 | soluce = [ ICTokenNode_COMMENT( None, " Compound tokens -- tokenization test source" ),
31 | ICTokenNode_NL(),
32 | ICTokenNode_COMMENT_ML( None, "**\nmulti-lines comment\n**" ),
33 | ICTokenNode_NL(),
34 | ICTokenNode_AROBASE(),
35 | ICTokenNode_AUG_AROBASE(),
36 | ICTokenNode_OP_2AROB(),
37 | ICTokenNode_AUG_2AROB(),
38 | ICTokenNode_NL(),
39 | ICTokenNode_BITAND(),
40 | ICTokenNode_AUG_BITAND(),
41 | ICTokenNode_NL(),
42 | ICTokenNode_BITOR(),
43 | ICTokenNode_AUG_BITOR(),
44 | ICTokenNode_NL(),
45 | ICTokenNode_BITXOR(),
46 | ICTokenNode_POWER( None, '^^'),
47 | ICTokenNode_AUG_BITXOR(),
48 | ICTokenNode_AUG_POWER( None, '^^='),
49 | ICTokenNode_NL(),
50 | ICTokenNode_COLON(),
51 | ICTokenNode_AUG_COLN(),
52 | ICTokenNode_OP_2COLN(),
53 | ICTokenNode_AUG_2COLN(),
54 | ICTokenNode_NL(),
55 | ICTokenNode_DIV(),
56 | ICTokenNode_AUG_DIV(),
57 | ICTokenNode_NL(),
58 | ICTokenNode_ASSIGN(),
59 | ICTokenNode_EQ(),
60 | ICTokenNode_NL(),
61 | ICTokenNode_EXCL(),
62 | ICTokenNode_OP_2EXCL(),
63 | ICTokenNode_NE(),
64 | ICTokenNode_AUG_2EXCL(),
65 | ICTokenNode_NL(),
66 | ICTokenNode_ANY_TYPE(),
67 | ICTokenNode_OP_2QUEST(),
68 | ICTokenNode_ANY_TYPE(),
69 | ICTokenNode_ASSIGN(),
70 | ICTokenNode_AUG_2QUEST(),
71 | ICTokenNode_NL(),
72 | ICTokenNode_GT(),
73 | ICTokenNode_SHIFTR(),
74 | ICTokenNode_SHIFT0R(),
75 | ICTokenNode_GE(),
76 | ICTokenNode_AUG_SHIFTR(),
77 | ICTokenNode_AUG_SHIFT0R(),
78 | ICTokenNode_OP_GRLE(),
79 | ICTokenNode_AUG_GRLE(),
80 | ICTokenNode_NL(),
81 | ICTokenNode_LT(),
82 | ICTokenNode_SHIFTL(),
83 | ICTokenNode_SHIFT0L(),
84 | ICTokenNode_LE(),
85 | ICTokenNode_AUG_SHIFTL(),
86 | ICTokenNode_AUG_SHIFT0L(),
87 | ICTokenNode_LEG(),
88 | ICTokenNode_OP_LEGR(),
89 | ICTokenNode_AUG_LEGR(),
90 | ICTokenNode_NL(),
91 | ICTokenNode_MINUS(),
92 | ICTokenNode_DECR(),
93 | ICTokenNode_AUG_MINUS(),
94 | ICTokenNode_ISOF(),
95 | ICTokenNode_NL(),
96 | ICTokenNode_MOD(),
97 | ICTokenNode_AUG_MOD(),
98 | ICTokenNode_NL(),
99 | ICTokenNode_PLUS(),
100 | ICTokenNode_INCR(),
101 | ICTokenNode_AUG_PLUS(),
102 | ICTokenNode_NL(),
103 | ICTokenNode_MUL(),
104 | ICTokenNode_POWER( None, '**' ),
105 | ICTokenNode_AUG_MUL(),
106 | ICTokenNode_AUG_POWER( None, '**=' ),
107 | ICTokenNode_NL(),
108 | ICTokenNode_DECR(),
109 | ICTokenNode_ASSIGN(),
110 | ICTokenNode_INCR(),
111 | ICTokenNode_ASSIGN(),
112 | ICTokenNode_LT(),
113 | ICTokenNode_MINUS(),
114 | ICTokenNode_NL(),
115 | ICTokenNode_DOT(),
116 | ICTokenNode_ELLIPSIS(),
117 | ICTokenNode_UNEXPECTED(None, 'a'),
118 | ICTokenNode_NL(),
119 | ICTokenNode_COMMENT(None, "/* */"),
120 | ICTokenNode_NL(),
121 | ICTokenNode_BRACEOP(),
122 | ICTokenNode_BRACECL(),
123 | ICTokenNode_EMBED_CODE(None, " " ),
124 | ICTokenNode_NL(),
125 | ICTokenNode_EOF()
126 | ]
127 |
128 | #===== end of Tests.Data.tokenization_simple_solution =====#
129 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/Scanner_Tokens/Data/tokenization_compound_tokens.ty:
--------------------------------------------------------------------------------
1 | // Compound tokens -- tokenization test source
2 | /***
3 | multi-lines comment
4 | ***/
5 | @ @= @@ @@=
6 | & &=
7 | | |=
8 | ^ ^^ ^= ^^=
9 | : := :: ::=
10 | / /=
11 | = ==
12 | ! !! != !!=
13 | ? ?? ?= ??=
14 | > >> >>> >= >>= >>>= >< ><=
15 | < << <<< <= <<= <<<= <=> <> <>=
16 | - -- -= ->
17 | % %=
18 | + ++ +=
19 | * ** *= **=
20 | --= ++= <-
21 | . ... ..a
22 | ///* */
23 | {} {{ }}
24 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/Scanner_Tokens/Data/tokenization_names_and_nums_tokens.ty:
--------------------------------------------------------------------------------
1 | // Names and Nums tokens -- tokenization test source
2 | /***
3 | i.e. identifiers, function and class names, reserved keywords, integer and float numbers
4 | ***/
5 | a b c d e f g h i j k l m n o p q r s t u v w x y z
6 | A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
7 | _ _name __ident__ __ set_num
8 | qmsli Qbhjken _123 a1 b2 c3d_ abstract1 _const i_uint32
9 | py python java javascript cpp m6809 ccs csharp
10 | abstract public const uint8 my_abstract_function
11 | return ret
12 | float32 f_num
13 | volatile bool is_ok
14 | assert is_ok
15 | ensure is_ok
16 | require is_ok
17 | if is_ok and is_ok or not is_ok
18 | pass nop
19 | elif elsif elseif else if True true False false
20 | else
21 | array< uint16 >
22 | with var as _var
23 | from import all but
24 | for int8 i in
25 | forever
26 | break
27 | continue
28 | list map set enum file
29 | class
30 | hidden local private protected final
31 | switch case
32 | unnamed lambda
33 | operator cast
34 | try except finally raise
35 | is me none None
36 | while repeat until
37 | embed exclude
38 | char char16 del float32 float64 int8 int16 int32 int64 str str16 uint8 uint16 uint32 uint64
39 | _int_ _float_ _uint_ _numeric_
40 | UInt8 Float32 float double Str string Class
41 | 0 1 2 3 4 5 6 7 8 9 _0 _1 _2 _3 _4 _5 _6 _7 _8 _9
42 | 123.456 123e45 79.46E+13 79.46e+13
43 | -12 -12e008 -12e-009 -12.e-9
44 | 123_456_789 1_234.567_89e1_234
45 | 0x123456789abcdefABCDEF
46 | 0b010_101
47 | 01234567
48 | 0123456789
49 | 0x0123456789abcdefABCDEFg
50 | 0b012
51 | 45__678 123.456__789 15_ _123_456_789
52 | var_name1&var_name2
53 | 45+-45
54 | 125abc
55 | 236_abc
56 | type
57 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/Scanner_Tokens/Data/tokenization_simple_solution.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | Copyright (c) 2018-2021 Philippe Schmouker, Typhee project, http://www.typee.ovh
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | """
24 |
25 | #=============================================================================
26 | from FrontEnd.IntermediateCode.fe_icode_token_node import *
27 |
28 |
29 | #=============================================================================
30 | soluce = [
31 | ICTokenNode_COMMENT( None, " Simple tokens -- tokenization test source" ),
32 | ICTokenNode_NL(),
33 | ICTokenNode_BRACKETOP(),
34 | ICTokenNode_BRACKETCL(),
35 | ICTokenNode_NL(),
36 | ICTokenNode_PAROP(),
37 | ICTokenNode_PARCL(),
38 | ICTokenNode_NL(),
39 | ICTokenNode_COMMA(),
40 | ICTokenNode_SEMICOLON(),
41 | ICTokenNode_NL(),
42 | ICTokenNode_HASH(),
43 | ICTokenNode_NL(),
44 | ICTokenNode_DOT(),
45 | ICTokenNode_NL(),
46 | ICTokenNode_TILD(),
47 | ICTokenNode_NL(),
48 | ICTokenNode_ANY_TYPE( None, '?' ),
49 | ICTokenNode_NL(),
50 | ICTokenNode_EOF()
51 | ]
52 |
53 | #===== end of Tests.Data.tokenization_simple_solution =====#
54 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/Scanner_Tokens/Data/tokenization_simple_tokens.ty:
--------------------------------------------------------------------------------
1 | // Simple tokens -- tokenization test source
2 | []
3 | ()
4 | ,;
5 | #
6 | .
7 | ~
8 | ?
9 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/Scanner_Tokens/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/Scanner_Tokens/readme.md:
--------------------------------------------------------------------------------
1 | # Testing the Front-End Scanner
2 |
3 | Current directory contains all the needed stuff to validate any modification brought to the Front-End Scanner, in an as automated way as possible while being kept simple.
4 |
5 | The only script to run for this purpose is contained in module `script_scanner_test.py` within directory `src/Tests/Scanner_Tokens`.
6 | Users may run this script as a command line in a console window, in directory `Scanner_Tokens`:
7 |
8 | $ python script_scanner_test.py
9 |
10 | or run it from within any developement framework - remember, _Eclipse Photon_ is the recommended one with __Typee__.
11 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/Scanner_Tokens/script_scanner_test.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | Copyright (c) 2018-2021 Philippe Schmouker, Typhon project, http://www.typee.ovh
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | """
24 |
25 | #=============================================================================
26 | from Tests.FrontEnd.Scanner_Tokens.test_compound_tokens import test_compound_tokens
27 | from Tests.FrontEnd.Scanner_Tokens.test_names_and_nums_tokens import test_names_and_nums_tokens
28 | from Tests.FrontEnd.Scanner_Tokens.test_simple_tokens import test_simple_tokens
29 |
30 | #=============================================================================
31 | if __name__ == '__main__':
32 | """
33 | This script calls every test functions dedicated to the Front-End Scanner.
34 | """
35 | #-------------------------------------------------------------------------
36 | test_compound_tokens()
37 | test_names_and_nums_tokens()
38 | test_simple_tokens()
39 |
40 | print( "\n-- done!" )
41 |
42 | #===== end of Tests.Scanner_Tokens.script_scanner_test =====#
43 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/Scanner_Tokens/test_compound_tokens.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | Copyright (c) 2018-2021 Philippe Schmouker, Typhee project, http://www.typee.ovh
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | """
24 |
25 | #=============================================================================
26 | from Tests.FrontEnd.Scanner_Tokens.tokens_test_base import TokensTestBase
27 |
28 | #=============================================================================
29 | def test_compound_tokens() -> None:
30 | TokensTestBase( 'Compound Tokens TEST',
31 | 'Data/tokenization_compound_tokens.ty',
32 | 'Data/tokenization_compound_solution.py' )
33 |
34 | #=============================================================================
35 | if __name__ == '__main__':
36 | """
37 | Simple test for the tokenization of compound tokens.
38 | """
39 | #-------------------------------------------------------------------------
40 | test_compound_tokens()
41 |
42 | #===== end of Tests.Scanner_Tokens.test_compound_tokens =====#
43 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/Scanner_Tokens/test_names_and_nums_tokens.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | Copyright (c) 2018-2021 Philippe Schmouker, Typhee project, http://www.typee.ovh
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | """
24 |
25 | #=============================================================================
26 | from Tests.FrontEnd.Scanner_Tokens.tokens_test_base import TokensTestBase
27 |
28 | #=============================================================================
29 | def test_names_and_nums_tokens() -> None:
30 | TokensTestBase( 'Names and Nums Tokens TEST',
31 | 'Data/tokenization_names_and_nums_tokens.ty',
32 | 'Data/tokenization_names_and_nums_solution.py' )
33 |
34 | #=============================================================================
35 | if __name__ == '__main__':
36 | """
37 | Simple test for the tokenization of compound tokens.
38 | """
39 | #-------------------------------------------------------------------------
40 | test_names_and_nums_tokens()
41 |
42 | #===== end of Tests.Scanner_Tokens.test_names_and_nums_tokens =====#
43 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/Scanner_Tokens/test_simple_tokens.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | Copyright (c) 2018-2021 Philippe Schmouker, Typhee project, http://www.typee.ovh
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | """
24 |
25 | #=============================================================================
26 | from Tests.FrontEnd.Scanner_Tokens.tokens_test_base import TokensTestBase
27 |
28 | #=============================================================================
29 | def test_simple_tokens() -> None:
30 | TokensTestBase( 'Simple Tokens TEST',
31 | 'Data/tokenization_simple_tokens.ty',
32 | 'Data/tokenization_simple_solution.py' )
33 |
34 | #=============================================================================
35 | if __name__ == '__main__':
36 | """
37 | Simple test for the tokenization of simple tokens.
38 | """
39 | #-------------------------------------------------------------------------
40 | test_simple_tokens()
41 |
42 | #===== end of Tests.test_simple_tokens =====#
43 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/Scanner_Tokens/tokens_test_base.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | from importlib import import_module
26 |
27 | from FrontEnd.IntermediateCode.fe_icode_tokens import FEICodeTokens
28 | from FrontEnd.Scanner.fe_scanner import FEScanner
29 |
30 |
31 | #=============================================================================
32 | class TokensTestBase:
33 | """
34 | Base class for all tokens tests.
35 | """
36 | #-------------------------------------------------------------------------
37 | def __init__(self, test_title : str,
38 | test_src_path: str,
39 | soluce_path : str) -> None:
40 | '''
41 | Constructor.
42 | Automatically runs the test.
43 |
44 |
45 | Args:
46 | test_title: str
47 | The title (i.e. name) of this test
48 | test_src_path: str
49 | the path to the Typee test file
50 | soluce_path: str
51 | the path to the file that contains the expected list of
52 | Intermediate Code nodes. This list HAS TO BE NAMED soluce.
53 |
54 | Raises:
55 | IOError: some file has not been found or can't be opened.
56 | '''
57 | print( "--", test_title )
58 |
59 | scanner = FEScanner()
60 | icode = scanner.scan_file( test_src_path )
61 |
62 | if soluce_path.endswith( '.py' ):
63 | soluce_path = soluce_path[:-3]
64 |
65 | solution = import_module( soluce_path.replace('/','.') )
66 |
67 | self.err_count = 0
68 | for i, (s, c) in enumerate( zip(solution.soluce, icode) ):
69 | if not s == c:
70 | print( ' line {:d}:{:d} - node {:d} -- coded {:s}({}) != expected {:s}({})'.format(
71 | c.num_line, c.num_coln, i,
72 | FEICodeTokens.token_name( c.tk_ident ),
73 | c.tk_data,
74 | FEICodeTokens.token_name( s.tk_ident ),
75 | s.tk_data
76 | ) )
77 | self.err_count+= 1
78 |
79 | if self.err_count == 0:
80 | print( ' Ok!' )
81 | else:
82 | print( ' {:d} error{:s}'.format(self.err_count, 's' if self.err_count > 1 else '') )
83 |
84 | #-------------------------------------------------------------------------
85 | def is_ok(self) -> bool:
86 | return self.err_count == 0
87 |
88 | #===== end of Tests.tokens_test_base =====#
89 |
90 |
--------------------------------------------------------------------------------
/src/Tests/FrontEnd/__init__.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 | """
4 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | """
24 |
--------------------------------------------------------------------------------
/src/Tests/Libs/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/Tests/Optimizer/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/Tests/Utils/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/Tests/Utils/script_ut_tree.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | from Utils.ut_tree import UTTree, UTNode, UTLeaf
26 |
27 |
28 | #=============================================================================
29 |
30 | #-----------------------------------------------------------------------------
31 | def test_ut_tree() -> int:
32 | '''
33 | This is the testing of class UTTree.
34 | '''
35 | errors_count = 0
36 |
37 | my_tree = UTTree()
38 |
39 | my_tree.append( UTNode() ).append( UTNode() )
40 | my_tree += UTLeaf( 'A' )
41 | my_tree += UTLeaf( 'B' )
42 | my_tree.up()
43 | my_tree += UTLeaf( 'C' )
44 |
45 | for node in my_tree:
46 | try:
47 | print( node.data )
48 | except:
49 | pass
50 |
51 | return errors_count
52 |
53 |
54 | #=============================================================================
55 | if __name__ == '__main__':
56 | '''
57 | Description of this script.
58 | '''
59 |
60 | #-------------------------------------------------------------------------
61 | print( 'UTTree validation tests' )
62 | count = test_ut_tree()
63 | if count == 0:
64 | print( ' Tests OK')
65 | else:
66 | print( 'detected {} error{}'.format( count, 's' if count > 1 else '') )
67 |
68 | print( '\n-- done!' )
69 |
70 |
71 | #===== end of Tests.Utils.script_ut_tree =====#
72 |
--------------------------------------------------------------------------------
/src/Tests/Utils/test_ut_trees.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2019-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | from Utils.Trees.ut_tree import UTTree
26 | from Utils.Trees.ut_tree_leaf import UTTreeLeaf
27 | from Utils.Trees.ut_tree_node import UTTreeNode
28 |
29 | #=============================================================================
30 | if __name__ == '__main__':
31 | my_tree = UTTree()
32 |
33 | my_tree += UTTreeNode()
34 | my_tree += UTTreeNode()
35 | my_tree.up_level()
36 | my_tree += UTTreeLeaf( 'A' )
37 | my_tree += UTTreeLeaf( 'B' )
38 | my_tree.up_level()
39 | my_tree += UTTreeNode()
40 | my_tree += UTTreeLeaf( 'C' )
41 | my_tree.up_level()
42 | my_tree += UTTreeLeaf( 'D' )
43 |
44 | for node in my_tree.walk():
45 | if isinstance(node, UTTreeLeaf ):
46 | print( 'Leaf:', node.content )
47 | else:
48 | print( 'Node:', node.content )
49 |
50 | print( '-- done!' )
51 |
52 | #===== end of Tests.Utils.test_ut_trees =====#
--------------------------------------------------------------------------------
/src/Tests/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/TypeeInterpreter/Commons/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/TypeeInterpreter/FEInterface/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/TypeeInterpreter/Utils/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/TypeeInterpreter/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/Utils/Trees/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/Utils/Trees/ut_tree.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2019-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | from Utils.Trees.ut_tree_leaf import UTTreeLeaf
26 | from Utils.Trees.ut_tree_node import UTTreeNode
27 | from Utils.Trees.ut_tree_node_base import UTTreeNodeBase
28 |
29 |
30 | #=============================================================================
31 | class UTTree:
32 | """
33 | The utility class of Trees.
34 | """
35 |
36 | #-------------------------------------------------------------------------
37 | def __init__(self) -> None:
38 | '''
39 | Constructor.
40 | '''
41 | self._root = UTTreeNode()
42 | self._current = self._root
43 |
44 | #-------------------------------------------------------------------------
45 | def __iadd__(self, new_node: UTTreeNodeBase):
46 | '''
47 | In-place appends a new node or leaf to this tree.
48 | If new_node is a tree node (and not a tree leaf), new_node
49 | becomes the current node of the tree for next appends.
50 |
51 | Returns a reference to this tree.
52 | '''
53 | new_node.parent = self._current
54 |
55 | self._current += new_node
56 | if isinstance( new_node, UTTreeNode ):
57 | self._current = new_node
58 |
59 | return self
60 |
61 | #-------------------------------------------------------------------------
62 | def up_level(self):
63 | '''
64 | Goes one level up in the tree, i.e. back to parent block in the IC Tree.
65 | '''
66 | self._current = self._current.parent
67 | return self
68 |
69 | #-------------------------------------------------------------------------
70 | def walk(self):
71 | '''
72 | Walks through this Intermediate Code tree, starting at its root.
73 | Walk-through is depth-first implemented.
74 | '''
75 | if self._root is not None:
76 | yield from self._root.walk()
77 |
78 | #===== end of Utils.Trees.ut_tree =====#
79 |
--------------------------------------------------------------------------------
/src/Utils/Trees/ut_tree_leaf.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2019-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | from Utils.Trees.ut_tree_node_base import UTTreeNodeBase
26 |
27 | #=============================================================================
28 | class UTTreeLeaf( UTTreeNodeBase ):
29 | """
30 | The class of leaves in trees.
31 | """
32 |
33 | #-------------------------------------------------------------------------
34 | def __init__(self, content = None) -> None:
35 | '''
36 | Constructor.
37 |
38 | Args:
39 | parent:
40 | A reference to the parent node in tree.
41 | Defaults to None (which means this node is a tree root)
42 | content:
43 | A reference to the content to be associated with this tree leaf.
44 | '''
45 | super().__init__( None, content )
46 |
47 | #-------------------------------------------------------------------------
48 | def walk(self):
49 | '''
50 | Walks over this leaf.
51 |
52 | Returns:
53 | A reference to the content of this leaf inserted in a generator.
54 | '''
55 | return (self, )
56 |
57 | #===== end of Utils.Trees.ut_tree_leaf =====#
58 |
--------------------------------------------------------------------------------
/src/Utils/Trees/ut_tree_node.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2019-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | from Utils.Trees.ut_tree_node_base import UTTreeNodeBase
26 |
27 | #=============================================================================
28 | class UTTreeNode( UTTreeNodeBase ):
29 | """
30 | The class of internal nodes in Trees.
31 | """
32 |
33 | #-------------------------------------------------------------------------
34 | def __init__(self, parent: UTTreeNodeBase = None, children: list = None) -> None:
35 | '''
36 | Constructor.
37 |
38 | Args:
39 | parent:
40 | A reference to the parent node in tree.
41 | Defaults to None (which means this node is a tree root)
42 | children:
43 | A reference to the content to be associated with this IC node.
44 | '''
45 | super().__init__( parent, children or [] )
46 |
47 | #-------------------------------------------------------------------------
48 | def __add__(self, new_child: UTTreeNodeBase) -> UTTreeNodeBase:
49 | '''
50 | Appends a new child to the list of children of this tree node.
51 | Implementation of operator '+'.
52 | '''
53 | self.content.append( new_child )
54 | return self
55 |
56 | #-------------------------------------------------------------------------
57 | def __iadd__(self, new_child: UTTreeNodeBase) -> UTTreeNodeBase:
58 | '''
59 | Appends a new child to the list of children of this tree node.
60 | Implementation of operator '+='.
61 | '''
62 | self.content.append( new_child )
63 | return self
64 |
65 | #-------------------------------------------------------------------------
66 | def walk(self) -> UTTreeNodeBase:
67 | '''
68 | Walks through the tree passing through this node.
69 | Walk-through is depth-first implemented.
70 | '''
71 | for child in self.content:
72 | yield from child.walk()
73 |
74 | #===== end of Utils.Trees.ut_tree_node =====#
75 |
--------------------------------------------------------------------------------
/src/Utils/Trees/ut_tree_node_base.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2019-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | class UTTreeNodeBase:
26 | """
27 | Basic interface for all types of nodes in Trees.
28 | """
29 |
30 | #-------------------------------------------------------------------------
31 | def __init__(self, parent=None, content=None) -> None:
32 | '''
33 | Constructor.
34 |
35 | Args:
36 | parent:
37 | A reference to the parent node in tree.
38 | content:
39 | A reference to the content to be associated with this tree node.
40 | '''
41 | self.parent = parent
42 | if content is None:
43 | self.content = []
44 | elif isinstance( content, list ):
45 | self.content = content
46 | else:
47 | self.content = [ content ]
48 |
49 | #-------------------------------------------------------------------------
50 | def walk(self) -> None:
51 | '''
52 | Walks through the tree passing through this node.
53 | Walk-through is depth-first implemented.
54 | HAS TO BE IMPLEMENTED IN INHERITING CLASSES.
55 | See UTTreeNode and UTTreeLeaf to get examples of implementation.
56 | '''
57 | raise NotImplementedError()
58 |
59 | #===== end of Utils.Trees.ut_tree_node_base =====#
60 |
--------------------------------------------------------------------------------
/src/Utils/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/Utils/archive/ut_tree.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2019-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | # no import.
26 |
27 |
28 | #=============================================================================
29 | ## Local declarations
30 | #-------------------------------------------------------------------------
31 | class UTNode:
32 | '''
33 | The class of internal nodes for trees.
34 | '''
35 | #---------------------------------------------------------------------
36 | def __init__(self, parent=None) -> None:
37 | '''Constructor'''
38 | self._children = []
39 | self.parent = parent
40 | self.DBG_count = UTNode.DBG_Count
41 | UTNode.DBG_Count += 1
42 | #---------------------------------------------------------------------
43 | def __iadd__(self, child):
44 | '''Appends a new child to the children list.'''
45 | self._children.append( child )
46 | return self
47 | #---------------------------------------------------------------------
48 | def __iter__(self):
49 | return self
50 | #---------------------------------------------------------------------
51 | def __next__(self) -> None:
52 | for child in self._children:
53 | if isinstance( child, UTNode ):
54 | yield child
55 | else:
56 | yield child
57 | raise StopIteration()
58 | #---------------------------------------------------------------------
59 | DBG_Count = 0
60 |
61 |
62 | #-------------------------------------------------------------------------
63 | class UTLeaf:
64 | '''
65 | The class of ending nodes (i.e. leaves) for trees.
66 | '''
67 | #---------------------------------------------------------------------
68 | def __init__(self, data=None) -> None:
69 | '''Constructor'''
70 | self.data = data
71 | #---------------------------------------------------------------------
72 | def __iter__(self):
73 | return self
74 | #---------------------------------------------------------------------
75 | def __next__(self):
76 | yield self
77 | raise StopIteration()
78 |
79 |
80 | #=============================================================================
81 | class UTTree:
82 | """
83 | The utility class for Trees management in Typee.
84 |
85 | This is a very minimalist implementation of trees, dedicated
86 | to the Typee Front-End.
87 | Do not aim at using this utility as a general tool for trees
88 | programming. The final deception would only be yours.
89 | """
90 | #-------------------------------------------------------------------------
91 | def __init__(self) -> None:
92 | '''
93 | Constructor.
94 | Instantiates an empty tree.
95 | '''
96 | self._root = UTNode()
97 | self._current = self._root
98 |
99 | #-------------------------------------------------------------------------
100 | def append(self, node):
101 | '''
102 | Appends a new node to the current node.
103 | '''
104 | node.parent = self._current
105 | self._current += node
106 | if not isinstance( node, UTLeaf ):
107 | self._current = node
108 | return self
109 |
110 | #-------------------------------------------------------------------------
111 | def __iadd__(self, node):
112 | '''
113 | Appends a new node to the current node.
114 | '''
115 | return self.append( node )
116 |
117 | #-------------------------------------------------------------------------
118 | def __iter__(self):
119 | return self
120 |
121 | #-------------------------------------------------------------------------
122 | def __next__(self):
123 | for node in self._root:
124 | yield from node
125 | raise StopIteration()
126 |
127 | #-------------------------------------------------------------------------
128 | def up(self):
129 | '''
130 | Returns the parent of current node
131 | '''
132 | return self._current.parent
133 |
134 |
135 | #===== end of Utils.ut_tree =====#
136 |
--------------------------------------------------------------------------------
/src/Utils/ut_decorators.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | def abstract( method ):
26 | '''
27 | `abstract` decorator definition
28 | '''
29 | def abstract_wrapper( *_args, **_kwargs ):
30 | try:
31 | class_name = '.'.join( str(method).split(' ')[1].split('.')[:-1] )
32 | except:
33 | class_name = ''
34 | raise NotImplementedError( "abstract method `{}()` is not implemented in class `{}`.".format(method.__name__, class_name or '') )
35 | return abstract_wrapper
36 |
37 | #===== end of Utils.ut_decorators =====#
38 |
--------------------------------------------------------------------------------
/src/Utils/ut_serialized_enum.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | from math import log2
26 | from struct import Struct
27 |
28 |
29 | #=============================================================================
30 | class UTSerializedEnum( Struct ):
31 | """
32 | This is a generic meta-class for serialize-able Enum classes.
33 | CAUTION:
34 | This is highly pythonized code that intensively takes benefit
35 | of Python built-in classes and meta-classes goodies.
36 | """
37 | #-------------------------------------------------------------------------
38 | def __new__(cls, enum_class, bytes_size:int=None):
39 | '''
40 | Meta-constructor.
41 |
42 | Args:
43 | enum_class:
44 | The enumerated class that has to be serialized.
45 | bytes_size: int
46 | The number of bytes to store the greatest value of the
47 | enumerated values. If None, this size is automatically
48 | deduced from the enumerated values.
49 | bytes_size has to one one of 1, 2, 4 or 8.
50 | '''
51 | if bytes_size is None:
52 | max_value = max( [e.value for e in enum_class] )
53 | bits = log2( max_value )
54 | bytes_count = int( (bits + 7) / 8 )
55 | bytes_size = [1, 1, 2, 4, 4, 8, 8, 8, 8][bytes_count]
56 | else:
57 | assert bytes_size in [1,2,4,8]
58 |
59 | super().__init__( ".BH.L...Q"[bytes_size] )
60 |
61 | cls._enum_class = enum_class
62 | cls._dict_encode = { e.value: e for e in enum_class }
63 | cls._size = bytes_size
64 |
65 | #-------------------------------------------------------------------------
66 | @classmethod
67 | def read(cls, fp):
68 | '''
69 | '''
70 | value = cls.unpack( fp.read(cls._size) )
71 | return cls._dict_encode[ value ]
72 |
73 | #-------------------------------------------------------------------------
74 | @classmethod
75 | def write(cls, fp, value) -> None:
76 | '''
77 | '''
78 | fp.write( cls.pack(value) )
79 |
80 | #===== end of Utils.ut_serialized_enum =====#
81 |
--------------------------------------------------------------------------------
/src/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/local_tools/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
--------------------------------------------------------------------------------
/src/local_tools/copyright_years_modif.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | from datetime import date
26 | import os
27 |
28 | #=============================================================================
29 | class CopyrightYearsModif:
30 | """
31 | The utility to modify years of copyright
32 | notices in directories and in files.
33 | """
34 | #-------------------------------------------------------------------------
35 | def __init__(self) -> None:
36 | '''
37 | Constructor.
38 |
39 | Initializes current year value.
40 | '''
41 | self._current_year = date.today().year
42 |
43 | #-------------------------------------------------------------------------
44 | def modify_file(self, file_path: str):
45 | '''
46 | Modifies copyright notices in a specified file.
47 | '''
48 | print( file_path, end='' )
49 | try:
50 |
51 | with open( file_path, 'r' ) as fp:
52 | file_content = fp.readlines()
53 |
54 | modified = False
55 | for num_line, line in enumerate( file_content ):
56 | if 'opyright (c)' in line:
57 | parsed_line = line.split( '(c)' )
58 | parsed_years = parsed_line[1].split()
59 | years = parsed_years[0].split( '-' )
60 | try:
61 | if int(years[-1]) != self._current_year:
62 | if len( years ) > 1:
63 | years[-1] = '{}'.format( self._current_year )
64 | parsed_years[0] = '-'.join( years )
65 | else:
66 | parsed_years[0] = '{}-{}'.format( years[0], self._current_year )
67 | parsed_line[1] = " {:s}\n".format( ' '.join( parsed_years ) )
68 | file_content[ num_line ] = '(c)'.join( parsed_line )
69 | modified = True
70 | print( ' - modified:', file_content[num_line] )
71 | except:
72 | pass
73 |
74 | if modified:
75 | with open( file_path, 'w' ) as fp:
76 | fp.writelines( file_content )
77 | else:
78 | print( ' - ok' )
79 |
80 | except Exception:
81 | print( ' - unprocessed' )
82 |
83 | return self
84 |
85 | #-------------------------------------------------------------------------
86 | def modify_files(self, files_list: list):
87 | '''
88 | Modifies copyright notices in every specified files.
89 | '''
90 | for file_path in files_list:
91 | self.modify_file( file_path )
92 |
93 | return self
94 |
95 | #-------------------------------------------------------------------------
96 | def modify_directory(self, rootdir_path: str = '.'):
97 | '''
98 | Modifies copyright notices in every file of specified directory.
99 | '''
100 | for current_dir_path, _dir_names, file_names in os.walk( rootdir_path ):
101 | self.modify_files( [os.path.join(current_dir_path, file_name) for file_name in file_names] )
102 |
103 | return self
104 |
105 | #-------------------------------------------------------------------------
106 | def modify_directories(self, dirs_list: list):
107 | '''
108 | Automates the modification of coyright notices in many directories.
109 | '''
110 | for dir_path in dirs_list:
111 | self.modify_directory( dir_path )
112 |
113 | return self
114 |
115 | #===== end of scripts.utils.copyright_years_modif =====#
116 |
117 |
--------------------------------------------------------------------------------
/src/local_tools/script_copyright_automated_modification.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | """
24 |
25 | #=============================================================================
26 | from local_tools.copyright_years_modif import CopyrightYearsModif
27 |
28 | #=============================================================================
29 | if __name__ == '__main__':
30 | """
31 | Runs the script function.
32 | """
33 | #-------------------------------------------------------------------------
34 | my_copyright_modifier = CopyrightYearsModif()
35 |
36 | my_copyright_modifier.modify_directories( ['../BackEnd',
37 | '../Commons',
38 | '../FrontEnd',
39 | '../local_tools',
40 | '../Tests',
41 | '../Utils',
42 | '../../Language-specifications'] )
43 |
44 | my_copyright_modifier.modify_files( ['../../development-framework.md',
45 | '../../LICENSE',
46 | '../../notepad-readme.md',
47 | '../../README.md'] )
48 |
49 | #===== end of local_tools.script_copyright_automated_modification =====#
--------------------------------------------------------------------------------
/src/local_tools/template_class.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | """
23 |
24 | #=============================================================================
25 | # no import.
26 |
27 |
28 | #=============================================================================
29 | class Class:
30 | """
31 | Class description.
32 | """
33 | #-------------------------------------------------------------------------
34 | def __init__(self, params) -> None:
35 | '''
36 | Constructor.
37 |
38 | description
39 |
40 | Args:
41 | ...
42 |
43 | Returns:
44 | ...
45 |
46 | Raises:
47 | ...
48 | '''
49 | pass
50 |
51 | #-------------------------------------------------------------------------
52 |
53 | #===== end of local_tools.template_class =====#
54 |
--------------------------------------------------------------------------------
/src/local_tools/template_main.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | """
4 | Copyright (c) 2018-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | """
24 |
25 | #=============================================================================
26 | # no import.
27 |
28 |
29 | #=============================================================================
30 |
31 | #-------------------------------------------------------------------------
32 | def function(params):
33 | '''
34 | Function description.
35 |
36 | Args:
37 | ...
38 |
39 | Returns:
40 | ...
41 |
42 | Raises:
43 | ...
44 | '''
45 | pass
46 |
47 |
48 | #-------------------------------------------------------------------------
49 |
50 |
51 | #=============================================================================
52 | if __name__ == '__main__':
53 | """
54 | Script description.
55 | """
56 | #-------------------------------------------------------------------------
57 | pass
58 |
59 |
60 | #===== end of local_tools.template_main =====#
61 |
--------------------------------------------------------------------------------
/src/local_tools/tool_generate_html_grammar.py:
--------------------------------------------------------------------------------
1 | """
2 | Copyright (c) 2019-2021 Philippe Schmouker, Typee project, http://www.typee.ovh
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | SOFTWARE.
21 | """
22 |
23 | #=============================================================================
24 | #-------------------------------------------------------------------------
25 | def translate( grm_path: str, html_path: str) -> None:
26 | '''
27 | Translates .grm file into its HTML equivalence.
28 |
29 | Args:
30 | grm_path: str
31 | The path to the EBFN .grm source.
32 | html_path: str
33 | The path to the HTML destination file.
34 | '''
35 | with open( grm_path, 'r') as fsrc:
36 | content = fsrc.read()
37 |
38 | with open( html_path, 'w' ) as fdst:
39 | fdst.write( content.replace('<', '<').replace('>', '>').replace(" '", " '").replace("' ", "' ") )
40 |
41 |
42 | #=============================================================================
43 | if __name__ == '__main__':
44 | """
45 | Script for the translation of EBNF.grm files into their HTML equivalence.
46 | """
47 | #-------------------------------------------------------------------------
48 | translate( '../../Language-specifications/typee_specs_LL1-v10-EBNF.grm',
49 | './tmp_data/typee_specs_LL1-v10-EBNF.html' )
50 |
51 | print( '-- done!' )
52 |
53 | #===== end of local_tools.tool_generate_html_grammar =====#
54 |
--------------------------------------------------------------------------------