├── .deepsource.toml ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── codeql-analysis.yml │ └── python-publish.yml ├── .gitignore ├── .idea ├── .gitignore ├── IGCSE-CS-PC-Compiler.iml ├── encodings.xml ├── inspectionProfiles │ └── profiles_settings.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Classes.py ├── Commands.py ├── Config.py ├── Errors.py ├── Functions.py ├── LICENSE ├── Main.py ├── Procfile ├── README.md ├── Test Cases.txt ├── To be translated.txt └── requirements.txt /.deepsource.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | 3 | [[analyzers]] 4 | name = "python" 5 | enabled = true 6 | 7 | [analyzers.meta] 8 | runtime_version = "3.x.x" 9 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: Sherlemious 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | # The branches below must be a subset of the branches above 8 | branches: [ master ] 9 | schedule: 10 | - cron: '28 6 * * 4' 11 | 12 | jobs: 13 | analyze: 14 | name: Analyze 15 | runs-on: ubuntu-latest 16 | 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | language: [ 'python' ] 21 | 22 | steps: 23 | - name: Checkout repository 24 | uses: actions/checkout@v2 25 | 26 | # Initializes the CodeQL tools for scanning. 27 | - name: Initialize CodeQL 28 | uses: github/codeql-action/init@v1 29 | with: 30 | languages: ${{ matrix.language }} 31 | # If you wish to specify custom queries, you can do so here or in a config file. 32 | # By default, queries listed here will override any specified in a config file. 33 | # Prefix the list here with "+" to use these queries and those in the config file. 34 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 35 | 36 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 37 | # If this step fails, then you should remove it and run the build manually (see below) 38 | - name: Autobuild 39 | uses: github/codeql-action/autobuild@v1 40 | 41 | # ℹ️ Command-line programs to run using the OS shell. 42 | # 📚 https://git.io/JvXDl 43 | 44 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 45 | # and modify them (or add more) to build your code if your project 46 | # uses a compiled language 47 | 48 | #- run: | 49 | # make bootstrap 50 | # make release 51 | 52 | - name: Perform CodeQL Analysis 53 | uses: github/codeql-action/analyze@v1 54 | -------------------------------------------------------------------------------- /.github/workflows/python-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflows will upload a Python Package using Twine when a release is created 2 | # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries 3 | 4 | name: Upload Python Package 5 | 6 | on: 7 | release: 8 | types: [created] 9 | 10 | jobs: 11 | deploy: 12 | 13 | runs-on: Windows 10 14 | 15 | steps: 16 | - uses: actions/checkout@v2 17 | - name: Set up Python 18 | uses: actions/setup-python@v2 19 | with: 20 | python-version: '3.x' 21 | - name: Install dependencies 22 | run: | 23 | python -m pip install --upgrade pip 24 | pip install setuptools wheel twine 25 | - name: Build and publish 26 | env: 27 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} 28 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 29 | run: | 30 | python setup.py sdist bdist_wheel 31 | twine upload dist/* 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/IGCSE-CS-PC-Compiler.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /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, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, or religion. 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 [github](https://github.com/Sherlemious). 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 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, 4 | email, or any other method with the owners of this repository before making a change. 5 | 6 | Please note we have a code of conduct, please follow it in all your interactions with the project. 7 | 8 | ## Pull Request Process 9 | 10 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a 11 | build. 12 | 2. You may merge the Pull Request in once you have the sign-off of two other developers, or if you 13 | do not have permission to do that, you may request the second reviewer to merge it for you. 14 | 15 | ## Code of Conduct 16 | 17 | ### Our Pledge 18 | 19 | In the interest of fostering an open and welcoming environment, we as 20 | contributors and maintainers pledge to making participation in our project and 21 | our community a harassment-free experience for everyone, regardless of age, body 22 | size, disability, ethnicity, gender identity and expression, level of experience, 23 | nationality, personal appearance, race, religion, or sexual identity and 24 | orientation. 25 | 26 | ### Our Standards 27 | 28 | Examples of behavior that contributes to creating a positive environment 29 | include: 30 | 31 | * Using welcoming and inclusive language 32 | * Being respectful of differing viewpoints and experiences 33 | * Gracefully accepting constructive criticism 34 | * Focusing on what is best for the community 35 | * Showing empathy towards other community members 36 | 37 | Examples of unacceptable behavior by participants include: 38 | 39 | * The use of sexualized language or imagery and unwelcome sexual attention or 40 | advances 41 | * Trolling, insulting/derogatory comments, and personal or political attacks 42 | * Public or private harassment 43 | * Publishing others' private information, such as a physical or electronic 44 | address, without explicit permission 45 | * Other conduct which could reasonably be considered inappropriate in a 46 | professional setting 47 | 48 | ### Our Responsibilities 49 | 50 | Project maintainers are responsible for clarifying the standards of acceptable 51 | behavior and are expected to take appropriate and fair corrective action in 52 | response to any instances of unacceptable behavior. 53 | 54 | Project maintainers have the right and responsibility to remove, edit, or 55 | reject comments, commits, code, wiki edits, issues, and other contributions 56 | that are not aligned to this Code of Conduct, or to ban temporarily or 57 | permanently any contributor for other behaviors that they deem inappropriate, 58 | threatening, offensive, or harmful. 59 | 60 | ### Scope 61 | 62 | This Code of Conduct applies both within project spaces and in public spaces 63 | when an individual is representing the project or its community. Examples of 64 | representing a project or community include using an official project e-mail 65 | address, posting via an official social media account, or acting as an appointed 66 | representative at an online or offline event. Representation of a project may be 67 | further defined and clarified by project maintainers. 68 | 69 | ### Enforcement 70 | 71 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 72 | reported by contacting the project team at abd.moh.yousef@gmail.com. All 73 | complaints will be reviewed and investigated and will result in a response that 74 | is deemed necessary and appropriate to the circumstances. The project team is 75 | obligated to maintain confidentiality with regard to the reporter of an incident. 76 | Further details of specific enforcement policies may be posted separately. 77 | 78 | Project maintainers who do not follow or enforce the Code of Conduct in good 79 | faith may face temporary or permanent repercussions as determined by other 80 | members of the project's leadership. 81 | 82 | ### Attribution 83 | 84 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 85 | available at [http://contributor-covenant.org/version/1/4][version] 86 | 87 | [homepage]: http://contributor-covenant.org 88 | [version]: http://contributor-covenant.org/version/1/4/ 89 | -------------------------------------------------------------------------------- /Classes.py: -------------------------------------------------------------------------------- 1 | class FUNCTION: 2 | def __init__(self, line_list): 3 | self.line_number = 0 4 | self.cur_line = "" 5 | self.line_list = line_list 6 | 7 | 8 | class FOR_LOOP(FUNCTION): 9 | def __init__(self, lcv, start, end, line_list): 10 | super().__init__(self) 11 | self.LCV = lcv 12 | self.start = start 13 | self.end = end 14 | self.line_list = line_list 15 | 16 | 17 | class COND_STATEMENT(FUNCTION): 18 | def __init__(self): 19 | super().__init__(self) 20 | self.Cond = "" 21 | 22 | 23 | class Loop_Counts: 24 | def __init__(self): 25 | pass 26 | 27 | While = 0 28 | Repeat = 0 29 | If = 0 30 | -------------------------------------------------------------------------------- /Commands.py: -------------------------------------------------------------------------------- 1 | import Functions as Fun 2 | import Config 3 | import Classes 4 | 5 | 6 | def main(line_used): 7 | if line_used[0:5] == "PRINT" or line_used[0:6] == "OUTPUT": 8 | PRINT(line_used) 9 | 10 | elif line_used[0:5] == "WHILE": 11 | WHILE() 12 | 13 | elif line_used[0:6] == "REPEAT": 14 | REPEAT() 15 | 16 | elif line_used[0:5] == "INPUT": 17 | INPUT(line_used) 18 | 19 | elif line_used[0:3] == "FOR": 20 | FOR() 21 | 22 | elif line_used[0:2] == "IF": 23 | IF() 24 | 25 | elif "=" in line_used: 26 | ASSIGNMENT(line_used) 27 | 28 | elif line_used[0:2] == "//" or line_used == "": 29 | pass 30 | 31 | 32 | def IF(): 33 | Fun.object_gen() 34 | Config.Iteratables[-1] = Classes.COND_STATEMENT() 35 | 36 | found_endif = False 37 | alt_lines = True 38 | line_list = [] 39 | 40 | line_split = Config.Iteratables[-2].line_list[Config.Iteratables[-2].line_number].split() 41 | 42 | if line_split[-1] == "THEN": 43 | del line_split[-1] 44 | else: 45 | Config.Iteratables[-2].line_number += 1 46 | 47 | Config.Iteratables[-1].Cond = line_split 48 | cond = Config.Iteratables[-1].Cond 49 | Config.Iteratables[-1].Cond = Fun.compare(cond) 50 | 51 | if Config.Iteratables[-1].Cond: 52 | 53 | while True: 54 | 55 | Config.Iteratables[-2].line_number += 1 56 | try: 57 | Config.Iteratables[-2].cur_line = Config.Iteratables[-2].line_list[Config.Iteratables[-2].line_number] 58 | 59 | line_list.append(Config.Iteratables[-2].cur_line) 60 | line_split = Config.Iteratables[-2].cur_line.split() 61 | 62 | if line_split[0] == "IF": 63 | Classes.Loop_Counts.If += 1 64 | 65 | if line_split[0] == "ENDIF" and Classes.Loop_Counts.If == 0: 66 | found_endif = True 67 | del line_list[-1] 68 | break 69 | 70 | if line_split[0] == "ELSE" and Classes.Loop_Counts.If == 0: 71 | del line_list[-1] 72 | break 73 | 74 | if line_split[0] == "ENDIF": 75 | Classes.Loop_Counts.If -= 1 76 | 77 | except IndexError: 78 | pass 79 | 80 | Config.Iteratables[-1].line_list = line_list 81 | while not found_endif: 82 | Config.Iteratables[-2].line_number += 1 83 | Config.Iteratables[-2].cur_line = Config.Iteratables[-2].line_list[Config.Iteratables[-2].line_number] 84 | line_split = Config.Iteratables[-2].cur_line.split() 85 | if line_split[0] == "IF": 86 | Classes.Loop_Counts.If += 1 87 | if line_split[0] == "ENDIF": 88 | if Classes.Loop_Counts.If == 0: 89 | break 90 | else: 91 | Classes.Loop_Counts.If -= 1 92 | 93 | else: 94 | Classes.Loop_Counts.If = 1 95 | while not (Classes.Loop_Counts.If >= 1 and line_split[0] == "ELSE"): 96 | Config.Iteratables[-2].line_number += 1 97 | Config.Iteratables[-2].cur_line = Config.Iteratables[-2].line_list[Config.Iteratables[-2].line_number] 98 | line_split = Config.Iteratables[-2].cur_line.split() 99 | if line_split[0] == "IF": 100 | Classes.Loop_Counts.If += 1 101 | if line_split[0] == "ENDIF": 102 | Classes.Loop_Counts.If -= 1 103 | if Classes.Loop_Counts.If == 0 and line_split[0] == "ENDIF": 104 | alt_lines = False 105 | break 106 | 107 | Classes.Loop_Counts.If = 0 108 | while Classes.Loop_Counts.If > 0 and line_split[0] != "ENDIF" and alt_lines: 109 | 110 | Config.Iteratables[-2].line_number += 1 111 | try: 112 | Config.Iteratables[-2].cur_line = Config.Iteratables[-2].line_list[Config.Iteratables[-2].line_number] 113 | 114 | line_list.append(Config.Iteratables[-2].cur_line) 115 | line_split = Config.Iteratables[-2].cur_line.split() 116 | 117 | if line_split[0] == "IF": 118 | Classes.Loop_Counts.If += 1 119 | if line_split[0] == "ENDIF": 120 | Classes.Loop_Counts.If -= 1 121 | if Classes.Loop_Counts.If == 0: 122 | del line_list[-1] 123 | 124 | except IndexError: 125 | pass 126 | Config.Iteratables[-1].line_list = line_list 127 | 128 | while Config.Iteratables[-1].line_number < len(Config.Iteratables[-1].line_list): 129 | cur_line = Config.Iteratables[-1].line_list[Config.Iteratables[-1].line_number] 130 | main(cur_line) 131 | Config.Iteratables[-1].line_number += 1 132 | del Config.Iteratables[-1] 133 | 134 | 135 | def FOR(): 136 | Fun.object_gen() 137 | line_list = [] 138 | 139 | cur_line_split = Config.Iteratables[-2].line_list[Config.Iteratables[-2].line_number].split() 140 | lcv = cur_line_split[1] 141 | Config.variables[lcv] = lcv 142 | start = int(cur_line_split[3]) 143 | if cur_line_split[5] in Config.variables: 144 | end = int(Config.variables[cur_line_split[5]]) + 1 145 | else: 146 | end = int(cur_line_split[5]) + 1 147 | while True: 148 | Config.Iteratables[-2].line_number += 1 149 | try: 150 | Config.Iteratables[-2].cur_line = Config.Iteratables[-2].line_list[Config.Iteratables[-2].line_number] 151 | line_list.append(Config.Iteratables[-2].cur_line) 152 | cur_line_split = Config.Iteratables[-2].cur_line.split() 153 | except IndexError: 154 | pass 155 | if cur_line_split[0] == "NEXT" and cur_line_split[1] == lcv: 156 | del line_list[-1] 157 | break 158 | try: 159 | Config.Iteratables[-2].cur_line = Config.Iteratables[-2].line_list[Config.Iteratables[-2].line_number] 160 | except IndexError: 161 | pass 162 | 163 | Config.Iteratables[-1] = Classes.FOR_LOOP(line_list=line_list, lcv=lcv, start=start, end=end) 164 | for i in range(Config.Iteratables[-1].start, Config.Iteratables[-1].end): 165 | Config.variables[lcv] = i 166 | while Config.Iteratables[-1].line_number < len(Config.Iteratables[-1].line_list): 167 | cur_line = Config.Iteratables[-1].line_list[Config.Iteratables[-1].line_number] 168 | main(cur_line) 169 | Config.Iteratables[-1].line_number += 1 170 | Config.Iteratables[-1].line_number = 0 171 | del Config.Iteratables[-1] 172 | del Config.variables[lcv] 173 | 174 | 175 | def WHILE(): 176 | Fun.object_gen() 177 | Config.Iteratables[-1] = Classes.COND_STATEMENT() 178 | 179 | line_list = [] 180 | 181 | line_split = Config.Iteratables[-2].line_list[Config.Iteratables[-2].line_number].split() 182 | 183 | if line_split[-1] == "DO": 184 | del line_split[-1] 185 | 186 | Config.Iteratables[-1].Cond = line_split 187 | cond = Config.Iteratables[-1].Cond 188 | 189 | Config.Iteratables[-1].Cond = Fun.compare(cond) 190 | 191 | while True: 192 | Config.Iteratables[-2].line_number += 1 193 | try: 194 | Config.Iteratables[-2].cur_line = Config.Iteratables[-2].line_list[Config.Iteratables[-2].line_number] 195 | 196 | line_list.append(Config.Iteratables[-2].cur_line) 197 | line_split = Config.Iteratables[-2].cur_line.split() 198 | 199 | if line_split[0] == "WHILE": 200 | Classes.Loop_Counts.While += 1 201 | 202 | if line_split[0] == "ENDWHILE" and Classes.Loop_Counts.While == 0: 203 | del line_list[-1] 204 | break 205 | 206 | if line_split[0] == "ENDWHILE": 207 | Classes.Loop_Counts.While -= 1 208 | 209 | except IndexError: 210 | pass 211 | 212 | # Config.Iteratables[-2].line_number -= 1 213 | Config.Iteratables[-1].line_list = line_list 214 | 215 | while Config.Iteratables[-1].Cond: 216 | 217 | while Config.Iteratables[-1].line_number < len(Config.Iteratables[-1].line_list): 218 | cur_line = Config.Iteratables[-1].line_list[Config.Iteratables[-1].line_number] 219 | main(cur_line) 220 | Config.Iteratables[-1].line_number += 1 221 | 222 | Config.Iteratables[-1].line_number = 0 223 | Config.Iteratables[-1].Cond = Fun.compare(cond) 224 | del Config.Iteratables[-1] 225 | 226 | 227 | def REPEAT(): 228 | Fun.object_gen() 229 | Config.Iteratables[-1] = Classes.COND_STATEMENT() 230 | 231 | line_list = [] 232 | 233 | while True: 234 | Config.Iteratables[-2].line_number += 1 235 | try: 236 | Config.Iteratables[-2].cur_line = Config.Iteratables[-2].line_list[Config.Iteratables[-2].line_number] 237 | 238 | line_list.append(Config.Iteratables[-2].cur_line) 239 | line_split = Config.Iteratables[-2].cur_line.split() 240 | 241 | if line_split[0] == "REPEAT": 242 | Classes.Loop_Counts.Repeat += 1 243 | 244 | if line_split[0] == "UNTIL" and Classes.Loop_Counts.Repeat == 0: 245 | 246 | Config.Iteratables[-1].Cond = line_split 247 | cond = Config.Iteratables[-1].Cond 248 | 249 | Config.Iteratables[-1].Cond = Fun.compare(cond) 250 | 251 | del line_list[-1] 252 | break 253 | 254 | if line_split[0] == "UNTIL": 255 | Classes.Loop_Counts.Repeat -= 1 256 | 257 | except IndexError: 258 | pass 259 | 260 | # Config.Iteratables[-2].line_number -= 1 261 | Config.Iteratables[-1].line_list = line_list 262 | 263 | while True: 264 | 265 | while Config.Iteratables[-1].line_number < len(Config.Iteratables[-1].line_list): 266 | cur_line = Config.Iteratables[-1].line_list[Config.Iteratables[-1].line_number] 267 | main(cur_line) 268 | Config.Iteratables[-1].line_number += 1 269 | 270 | Config.Iteratables[-1].line_number = 0 271 | Config.Iteratables[-1].Cond = Fun.compare(cond) 272 | 273 | if Config.Iteratables[-1].Cond: 274 | break 275 | del Config.Iteratables[-1] 276 | 277 | 278 | def ASSIGNMENT(line_used): 279 | lst = line_used.split() 280 | # check if this is an array declaration 281 | if not Fun.check_array_declaration(lst): 282 | Fun.assign(line_used) 283 | else: 284 | Fun.declare_array(lst) 285 | 286 | 287 | def INPUT(line_used): 288 | varwanted = line_used.split() 289 | varwanted = varwanted[1] 290 | if "[" in line_used: 291 | A_S = varwanted.find("[") 292 | pos_num = varwanted[A_S + 1:-1] 293 | try: 294 | pos_num = int(pos_num) 295 | except ValueError: 296 | pos_num = Config.variables[pos_num] 297 | var = varwanted[:A_S] 298 | if var not in Config.variables: 299 | Config.variables[var] = {} 300 | Config.variables[var][pos_num] = Fun.take_input() 301 | else: 302 | Config.variables[varwanted] = Fun.take_input() 303 | 304 | 305 | def PRINT(line_used): 306 | lst = line_used.split() 307 | string_flag = False 308 | printed = "" 309 | del lst[0] 310 | for w in range(len(lst)): 311 | 312 | word = lst[w] 313 | if word[0] == '\"': 314 | string_flag = True 315 | if word[-1] == '\"': 316 | string_flag = False 317 | printed += word[1:-1] 318 | continue 319 | else: 320 | printed += word[1:] 321 | printed += " " 322 | elif word[-1] == '\"': 323 | string_flag = False 324 | printed += word[:-1] 325 | printed += " " 326 | elif string_flag: 327 | printed += word[:] 328 | printed += " " 329 | if not string_flag: 330 | if word in Config.variables: # This checks if it is a variable and if the variable exists 331 | printed += str(Config.variables[word]) 332 | continue 333 | elif "[" in word: 334 | printed += str(Fun.fetch_value(word)) 335 | elif word == ",": 336 | printed += " " 337 | print(printed) 338 | -------------------------------------------------------------------------------- /Config.py: -------------------------------------------------------------------------------- 1 | variables = {} 2 | Flags = {} 3 | counter = 0 4 | to_be_eval = "" 5 | Iteratables = [] 6 | FileList = [] 7 | op_list = ['=', '>', '<', '<=', '>=', '<>'] 8 | logic_list = ['AND', "OR", "XOR", "NAND", "NOR"] 9 | mops = ["+", "-", "*", "/"] 10 | -------------------------------------------------------------------------------- /Errors.py: -------------------------------------------------------------------------------- 1 | import Config 2 | import sys 3 | 4 | 5 | class Error: 6 | def __init__(self, error_name): 7 | self.printed = error_name 8 | 9 | def isprint(self): 10 | print(self.printed) 11 | print(f"This error has been generated in Line number #{Config.Iteratables[0].line_number}") 12 | sys.exit(-1) 13 | 14 | 15 | VarNotPresent = Error("Variable Identifier does not exist.") 16 | 17 | NoEqualSpaces = Error( 18 | "Please make sure that there is a space " " character between each identifier(variable) operand, or an equal sign") 19 | 20 | OpInvalid = Error("There is an invalid operand") 21 | 22 | LogInvalid = Error("There is an invalid logic gate") 23 | 24 | Absent = Error("There is an invalid operand. Please input a valid variable or number") 25 | 26 | Backslash = Error("Please Do not use a backslash in a string : \\") 27 | -------------------------------------------------------------------------------- /Functions.py: -------------------------------------------------------------------------------- 1 | import Config 2 | import Errors 3 | 4 | 5 | def op_dict(toc1, toc2): 6 | return { 7 | "=": toc1 == toc2, 8 | ">": toc1 > toc2, 9 | "<": toc1 < toc2, 10 | "<=": toc1 <= toc2, 11 | ">=": toc1 >= toc2, 12 | "<>": toc1 != toc2 13 | } 14 | 15 | 16 | def log_dict(exp1, exp2): 17 | return { 18 | "AND": exp1 and exp2, 19 | "OR": exp1 or exp2, 20 | "XOR": exp1 != exp2, 21 | "NAND": not (exp1 and exp2), 22 | "NOR": not (exp1 or exp2) 23 | } 24 | 25 | 26 | def take_input(): 27 | x = input() 28 | x = find_type(x) 29 | return x 30 | 31 | 32 | def find_type(Obj): 33 | try: 34 | if "." in Obj: 35 | Obj = float(Obj) 36 | else: 37 | Obj = int(Obj) 38 | except ValueError: 39 | obj = str(Obj) 40 | return Obj 41 | 42 | 43 | def find_value(val): 44 | if val in Config.variables: 45 | try: 46 | toc = float(Config.variables[val]) 47 | except ValueError: 48 | toc = Config.variables[val] 49 | elif "[" in val: 50 | toc = fetch_value(val) 51 | elif "\"" in val: 52 | toc = val[1:-1] 53 | else: 54 | try: 55 | toc = float(val) 56 | toc = float(val) 57 | except ValueError: 58 | pass 59 | return toc 60 | 61 | 62 | def comp(val1, val2, operand): 63 | # First Variable or Number 64 | toc1 = find_value(val1) 65 | 66 | # Second Variable or Number 67 | toc2 = find_value(val2) 68 | # Comparison 69 | if operand in Config.op_list: 70 | return op_dict(toc1, toc2)[operand] 71 | else: 72 | Errors.OpInvalid.isprint() 73 | 74 | 75 | # Compares two expressions by using comp function 76 | def compExpressions(exp1, exp2, logic_gate): 77 | logic_eval = None 78 | if logic_gate in Config.logic_list: 79 | # expressions should be passed in as array in form [val1,val2,operand] 80 | flag1 = comp(exp1[0], exp1[2], exp1[1]) 81 | flag2 = comp(exp2[0], exp2[2], exp2[1]) 82 | logic_eval = log_dict(flag1, flag2)[logic_gate] 83 | else: 84 | Errors.LogInvalid.isprint() 85 | 86 | if logic_eval is not None: 87 | return log_dict(flag1, flag2)[logic_gate] 88 | 89 | 90 | def compare(lst): 91 | if lst[0] == "IF" or lst[0] == "WHILE" or lst[0] == "UNTIL": 92 | del lst[0] 93 | if len(lst) == 3: 94 | return comp(lst[0], lst[2], lst[1]) 95 | elif len(lst) == 7: 96 | return compExpressions(lst[0:3], lst[4:], lst[3]) 97 | elif lst[1] == "DIV" or lst[1] == "MOD": 98 | return comp(op_dict(lst[0], lst[2]), lst[2], lst[1]) 99 | 100 | 101 | # Removes the escape character at the end of all lines 102 | def rem_end(the_list): 103 | for line in range(len(the_list)): 104 | the_list[line] = the_list[line].strip() 105 | 106 | 107 | # Creates a string that is appended to the objects list. This string is to be of a function class, where it is going 108 | # to contain the attributes of the loop/ function 109 | def object_gen(): 110 | Config.Iteratables.append("Statement " + str(len(Config.Iteratables))) 111 | 112 | 113 | def fetch_value(word): 114 | var = word 115 | A_S = var.find("[") 116 | pos_num = var[A_S + 1:-1] 117 | var = var[:A_S] 118 | try: 119 | pos_num = int(pos_num) 120 | except ValueError: 121 | pos_num = int(Config.variables[pos_num]) 122 | return Config.variables[var][pos_num] 123 | 124 | 125 | def listToString(s): 126 | Str = " " 127 | return Str.join(s) 128 | 129 | 130 | def check_array_declaration(lst): 131 | st = lst[2:] 132 | st = listToString(st) 133 | if st[0] == "[" and st[-1] == "]": 134 | return True 135 | else: 136 | return False 137 | 138 | 139 | def declare_array(lst): 140 | st = lst 141 | array_name = st[0] 142 | del st[0:2] 143 | old = listToString(st) 144 | lst = "" 145 | for ch in range(1, len(old) - 1): 146 | lst += str(old[ch]) 147 | Config.variables[array_name] = {} 148 | added = "" 149 | c = 1 150 | for ch in range(len(lst)): 151 | if lst[ch] == ",": 152 | try: 153 | added = float(added) 154 | except ValueError: 155 | pass 156 | Config.variables[array_name][c] = added 157 | added = "" 158 | c += 1 159 | elif lst[ch] == " ": 160 | continue 161 | else: 162 | added += str(lst[ch]) 163 | try: 164 | added = float(added) 165 | except ValueError: 166 | pass 167 | Config.variables[array_name][c] = added 168 | 169 | 170 | def assign(line_used): 171 | to_be_eval = "" 172 | lst = line_used.split() 173 | var = lst[0] 174 | pos_num = 0 175 | array = False 176 | string = False 177 | # Check for array 178 | A_S = var.find("[") 179 | if A_S == -1: 180 | if var not in Config.variables: 181 | Config.variables[var] = 0 182 | else: 183 | array = True 184 | pos_num = var[A_S + 1:-1] 185 | try: 186 | pos_num = int(pos_num) 187 | except ValueError: 188 | pos_num = Config.variables[pos_num] 189 | var = var[:A_S] 190 | if var not in Config.variables: 191 | Config.variables[var] = {} 192 | if pos_num not in Config.variables[var]: 193 | Config.variables[var][pos_num] = 0 194 | del lst[0:2] 195 | 196 | if lst[0] != "USERINPUT": 197 | for V in lst: 198 | if V[0] == '"' and V[-1] == '"': 199 | string = True 200 | to_be_eval += V[1:-1] 201 | continue 202 | elif "[" in str(V): 203 | to_be_eval += str(fetch_value(V)) 204 | continue 205 | elif V in Config.variables: 206 | to_be_eval += str(Config.variables[V]) 207 | elif isinstance(find_type(V), float) or isinstance(find_type(V), int): 208 | to_be_eval += str(V) 209 | elif V in Config.mops: 210 | to_be_eval += str(V) 211 | elif V == "DIV" or V == "MOD": 212 | if V == "MOD": 213 | to_be_eval += "%" 214 | else: 215 | to_be_eval += "//" 216 | else: 217 | to_be_eval += " " + str(V) 218 | if not string: 219 | try: 220 | to_be_eval = eval(to_be_eval) 221 | except ValueError: 222 | pass 223 | except NameError: 224 | pass 225 | else: 226 | to_be_eval = take_input() 227 | 228 | if array: 229 | Config.variables[var][pos_num] = to_be_eval 230 | else: 231 | Config.variables[var] = to_be_eval 232 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /Main.py: -------------------------------------------------------------------------------- 1 | import Classes 2 | import os 3 | import Commands as Do 4 | import Config 5 | import Functions as Fun 6 | 7 | 8 | # Taking in the Pseudocode (currently through a text file) 9 | dirname = os.path.dirname(__file__) 10 | dirname += "\\To be translated.txt" 11 | File = open(dirname, "r") 12 | Config.FileList = list(File) 13 | File.close() 14 | 15 | Fun.rem_end(Config.FileList) 16 | 17 | Fun.object_gen() 18 | Config.Iteratables[0] = Classes.FUNCTION(Config.FileList) 19 | 20 | # Iterates through the list of the lines 21 | while Config.Iteratables[0].line_number < len(Config.Iteratables[0].line_list): 22 | cur_line = Config.Iteratables[0].line_list[Config.Iteratables[0].line_number] 23 | Do.main(cur_line) 24 | Config.Iteratables[0].line_number += 1 25 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: python main.py 2 | worker: python main.py -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IGCSE CS PseudoCode Transpiler [![forthebadge made-with-python](http://ForTheBadge.com/images/badges/made-with-python.svg)](https://www.python.org/) 2 | 3 | This program translates the Pseudocode syntax studied in the IGCSE Computer Science 0478/0984 Syllabus. 4 | 5 | 6 | ## Note 7 | This program is usage-ready with just a couple additional features under development. For any suggestions or bug reports, please submit an issue on GitHub. 8 | 9 | If you liked it, please don't forget to star this repository. Thanks! 10 | 11 | ## Prerequisites 12 | [Python 3](https://www.python.org/downloads/) 13 | 14 | 15 | ## How to use 16 | 17 | ### Syntax 18 | For starters, it is required to leave a space character between each variable, function or operator. 19 | For example, when assigning a value to a variable, this is the correct way to do it. 20 | ``` 21 | variable = 16 * 14 + variable2 22 | ``` 23 | While this, on the other hand, will not work. 24 | ``` 25 | variable=16*14+variable2 26 | ``` 27 | ##### Arrays (example): 28 | ``` 29 | Numbers = [ 3, 4 ] 30 | Numbers[Count] = 123 31 | INPUT Numbers[3] 32 | ``` 33 | 34 | 35 | ### Available Functions 36 | 37 | #### PRINT (Fully functional): 38 | This is a simple statement use as in the following examples 39 | ``` 40 | PRINT "HELLO WORLD !" 41 | ``` 42 | The OUTPUT keyword also works 43 | ``` 44 | OUTPUT "HELLO WORLD !" 45 | ``` 46 | To print the string between two quotation marks " ". 47 | ###### Note that you should ***never** put quotations within pre-existing quotations and/or use a backslash character "\\". 48 | It is also possible to print/output the contents of a variable. 49 | ``` 50 | PRINT Variable 51 | ``` 52 | The OUTPUT keyword also works 53 | ``` 54 | OUTPUT Variable 55 | ``` 56 | To print multiple strings, or variable or both, separate them using commas. 57 | sum = 99 58 | ``` 59 | PRINT "The sum is equal to:" , sum 60 | ``` 61 | Output: The sum is equal to: 99 62 | 63 | Note that spaces are automatically added between printed entites 64 | 65 | 66 | #### INPUT (Fully functional): 67 | This is a simple statement that can be used as in the following example. 68 | ``` 69 | INPUT Variable 70 | ``` 71 | The keyword, "USERINPUT", can also be used. 72 | ``` 73 | Variable = USERINPUT 74 | ``` 75 | #### IF (Fully functional): 76 | A conditional statement that carries out a number of statements between the IF statement and the ENDIF statement. The ELSE statement will also be functional. 77 | ``` 78 | IF I = T THEN 79 | PRINT "HELLO WORLD !" 80 | I = I + 1 81 | ELSE 82 | "Print Hello" 83 | ENDIF 84 | ``` 85 | (The 'THEN' keyword is optional) 86 | 87 | 88 | #### FOR Loop (Fully functional): 89 | This is to repeat a number of statements, which are inserted between the FOR "LCV" = "Start" TO "End" and the NEXT "LCV", for a set number of times. 90 | ``` 91 | FOR I = 1 TO 5 92 | PRINT "HELLO WORLD !" 93 | NEXT I 94 | ``` 95 | 96 | 97 | #### WHILE Loop (Fully functional): 98 | A conditional loop that is repeated as long as a condition is true. Any statements should be inserted between the WHILE "Condition" and the ENDWHILE STATEMENT. 99 | ``` 100 | WHILE I < 5 DO 101 | PRINT "HELLO WORLD !" 102 | I = I + 1 103 | ENDWHILE 104 | ``` 105 | (The 'DO' keyword is optional) 106 | 107 | 108 | #### REPEAT Loop (Fully functional): 109 | A conditional loop that is repeated until a certain condition is met. Any statements should be inserted between the REPEAT and the UNTIL statement. 110 | ``` 111 | REPEAT 112 | PRINT "HELLO WORLD !" 113 | I = I + 1 114 | UNTIL I = 5 115 | ``` 116 | 117 | 118 | #### Commenting (Functional): 119 | Comments should be preceded by two slashes and a space character as follows. 120 | ``` 121 | // This is a comment 122 | ``` 123 | 124 | 125 | ### Contributing 126 | Please read [CONTRIBUTING.md](https://github.com/Sherlemious/IGCSE-CS-PC-Transpiler/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. 127 | -------------------------------------------------------------------------------- /Test Cases.txt: -------------------------------------------------------------------------------- 1 | // Test cases 2 | 3 | m = 0 4 | FOR i = 1 TO 6 5 | FOR t = 1 TO 7 6 | FOR l = 1 to 9 7 | m = m + 1 8 | NEXT l 9 | NEXT t 10 | NEXT i 11 | PRINT m 12 | // Correct Output 378 (Tested) 13 | 14 | // Advanced IF statements (Tested) 15 | INPUT H 16 | INPUT M 17 | IF H > 0 THEN 18 | PRINT "Outer" 19 | IF M > 0 THEN 20 | PRINT "Both Greater than 0" 21 | ENDIF 22 | ELSE 23 | PRINT "Other" 24 | ENDIF 25 | PRINT "Done" 26 | IF M > -5 THEN 27 | PRINT "Test Done" 28 | ELSE 29 | PRINT "ELSE DONE" 30 | ENDIF 31 | 32 | // Works Perfectly 33 | INPUT M 34 | WHILE M > 0 DO 35 | PRINT "M is POSITIVE" 36 | INPUT H 37 | WHILE H > 5 DO 38 | PRINT "H Greater than 5" 39 | INPUT H 40 | ENDWHILE 41 | INPUT M 42 | ENDWHILE 43 | 44 | // Works Perfectly 45 | INPUT H 46 | WHILE H > 5 DO 47 | PRINT "H Greater than 5" 48 | INPUT H 49 | ENDWHILE 50 | 51 | // Works perfectly 52 | Count = 1 53 | WHILE Count < 10 DO 54 | PRINT Count 55 | Count = Count + 1 56 | ENDWHILE 57 | PRINT "Done" 58 | 59 | // Works Perfectly 60 | FOR I = 1 TO 3 61 | INPUT H 62 | WHILE H = 0 63 | PRINT "Please input a value other than zero" 64 | INPUT H 65 | ENDWHILE 66 | IF H > 0 THEN 67 | PRINT "Positive" 68 | ELSE 69 | PRINT "Negative" 70 | ENDIF 71 | NEXT I 72 | PRINT "Done" 73 | 74 | // Custom For iterations (Tested) 75 | INPUT X 76 | FOR I = 1 TO X 77 | PRINT I 78 | NEXT I 79 | PRINT "DONE" 80 | 81 | // Works 82 | INPUT H 83 | INPUT M 84 | IF H > 0 THEN 85 | PRINT "Outer" 86 | IF M > 0 THEN 87 | PRINT "Both Greater than 0" 88 | ENDIF 89 | ELSE 90 | PRINT "Other" 91 | ENDIF 92 | PRINT "Done" 93 | 94 | // Fully working 95 | // Calculate average of positive numbers with validation. Where number of numbers input is an input Integer (X) 96 | Total = 0 97 | INPUT X 98 | FOR I = 1 TO X 99 | INPUT T 100 | WHILE T <= 0 DO 101 | PRINT "Please Input a positive number" 102 | INPUT T 103 | ENDWHILE 104 | Total = Total + T 105 | NEXT I 106 | Average = Total / X 107 | PRINT "The average is" 108 | PRINT Average 109 | 110 | // Fully works 111 | Count = 1 112 | INPUT X 113 | REPEAT 114 | Count = Count + 1 115 | PRINT Count 116 | UNTIL Count > 10 117 | PRINT "Done" 118 | 119 | // Fully works 120 | Count = 0 121 | INPUT X 122 | REPEAT 123 | Cf = 0 124 | PRINT "2nd Repeat" 125 | REPEAT 126 | PRINT "Iter" 127 | Cf = Cf + 1 128 | UNTIL Cf = 2 129 | Count = Count + 1 130 | PRINT Count 131 | UNTIL Count = X 132 | PRINT "Done" 133 | 134 | // FOR, WHILE, IF Testing (Fully works) 135 | FOR I = 1 TO 3 136 | INPUT H 137 | WHILE H = 0 138 | PRINT "Please input a value other than zero" 139 | INPUT H 140 | ENDWHILE 141 | IF H > 0 THEN 142 | PRINT "Positive" 143 | ELSE 144 | PRINT "Negative" 145 | ENDIF 146 | NEXT I 147 | PRINT "Done" 148 | 149 | // Pre-release 150 | Name = "Class 10" 151 | OUTPUT Name 152 | St_num = USERINPUT 153 | INPUT Cand_num 154 | 155 | FOR Count = 1 TO Cand_num 156 | PRINT "Enter Cand name:" 157 | INPUT Candidate[Count] 158 | NEXT Count 159 | 160 | Abstain = 0 161 | 162 | FOR J = 1 TO Cand_num 163 | Votes[J] = 0 164 | NEXT J 165 | 166 | FOR I = 1 TO St_num 167 | vote = USERINPUT 168 | IF vote = "abstain" THEN 169 | Abstain = Abstain + 1 170 | ENDIF 171 | FOR J = 1 TO Cand_num 172 | IF vote = Candidate[J] THEN 173 | Votes[J] = Votes[J] + 1 174 | ENDIF 175 | NEXT J 176 | NEXT I 177 | 178 | Max = -1000 179 | FOR Count = 1 TO Cand_num 180 | IF Votes[Count] > Max THEN 181 | Max = Votes[Count] 182 | ENDIF 183 | NEXT Count 184 | 185 | NumOfWinners = 0 186 | Winner = "" 187 | 188 | FOR Count = 1 TO Cand_num 189 | IF Votes[Count] = Max THEN 190 | Winner = Candidate[Count] 191 | NumOfWinners = NumOfWinners + 1 192 | ENDIF 193 | NEXT Count 194 | 195 | PRINT Name 196 | 197 | FOR Count = 1 TO Cand_num 198 | PRINT "candidate:" , Candidate[Count] , "got" , Votes[Count] , "votes" 199 | NEXT Count 200 | 201 | PRINT Winner , "Won the election" -------------------------------------------------------------------------------- /To be translated.txt: -------------------------------------------------------------------------------- 1 | INPUT X 2 | IF X >= 0 THEN 3 | PRINT "POSITIVE OR ZERO" 4 | IF X = 0 THEN 5 | PRINT "EQUAL TO ZERO" 6 | ELSE 7 | IF X > 0 THEN 8 | PRINT "POSITIVE" 9 | ENDIF 10 | ENDIF 11 | ELSE 12 | PRINT "Negative" 13 | ENDIF -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sherlemious/IGCSE-CS-PC-Transpiler/c4fe04edb25d0824981d0aa0c856a76e83c8b67b/requirements.txt --------------------------------------------------------------------------------