mirror of
https://github.com/Zandercraft/Aurora-lang.git
synced 2026-10-29 04:39:21 +00:00
Initial Upload
This commit is contained in:
130
.gitignore
vendored
Normal file
130
.gitignore
vendored
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
### Python Files
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
cover/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
.pybuilder/
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# pytype static type analyzer
|
||||||
|
.pytype/
|
||||||
|
|
||||||
|
# Cython debug symbols
|
||||||
|
cython_debug/
|
||||||
|
|
||||||
|
# PyCharm
|
||||||
|
.idea/sonarlint/
|
||||||
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
11
.idea/AuroraLang.iml
generated
Normal file
11
.idea/AuroraLang.iml
generated
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.idea/sonarlint" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
7
.idea/discord.xml
generated
Normal file
7
.idea/discord.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DiscordProjectSettings">
|
||||||
|
<option name="show" value="PROJECT_FILES" />
|
||||||
|
<option name="description" value="" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
12
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
12
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoredIdentifiers">
|
||||||
|
<list>
|
||||||
|
<option value="venue_management.models.VenueManager.*" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
4
.idea/misc.xml
generated
Normal file
4
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (AuroraLang)" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/AuroraLang.iml" filepath="$PROJECT_DIR$/.idea/AuroraLang.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -9,4 +9,11 @@ d88P aaa Y88888 888 Y88P 888 Y888888
|
|||||||
-- Copyright © 2023 Zandercraft. All rights reserved. --
|
-- Copyright © 2023 Zandercraft. All rights reserved. --
|
||||||
```
|
```
|
||||||
## Welcome!
|
## Welcome!
|
||||||
This is Aurora! It is a
|
This is Aurora! It is a high-level interpreted language currently interpreted by Python (however an interpreter should
|
||||||
|
be able to be written in any language).
|
||||||
|
|
||||||
|
## Features
|
||||||
|
- Unique syntax
|
||||||
|
- Intuitive writing
|
||||||
|
- Error handling
|
||||||
|
-
|
||||||
2
Vocabulary.MD
Normal file
2
Vocabulary.MD
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Aurora Vocabulary
|
||||||
|
This file sets out the various terms used to describe the
|
||||||
168
aurora.py
Normal file
168
aurora.py
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
"""
|
||||||
|
d888888
|
||||||
|
d88P aaa 888 888 888d88 .d88b. 888d88 8888b.
|
||||||
|
d88P aaa 888 888 888P d88^^88b 888P 88b
|
||||||
|
d88P aaa 888 888 888 888 888 888 .d888888
|
||||||
|
d8888888888 Y88b 888 888 Y88..88P 888 888 888
|
||||||
|
d88P aaa Y88888 888 Y88P 888 Y888888
|
||||||
|
-- Copyright © 2023 Zandercraft. All rights reserved. --
|
||||||
|
|
||||||
|
Purpose: Main implementation of Aurora
|
||||||
|
"""
|
||||||
|
|
||||||
|
#############
|
||||||
|
# CONSTANTS #
|
||||||
|
#############
|
||||||
|
DIGITS = "0123456789"
|
||||||
|
|
||||||
|
|
||||||
|
#############
|
||||||
|
# ERRORS #
|
||||||
|
#############
|
||||||
|
class Error:
|
||||||
|
def __init__(self, pos_start, pos_end, error_name, details):
|
||||||
|
self.pos_start = pos_start
|
||||||
|
self.pos_end = pos_end
|
||||||
|
self.error_name = error_name
|
||||||
|
self.details = details
|
||||||
|
|
||||||
|
def as_string(self):
|
||||||
|
result = f'{self.error_name}: {self.details}\n'
|
||||||
|
result += f'File {self.pos_start.fn}, line {self.pos_start.ln + 1}'
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
class IllegalCharError(Error):
|
||||||
|
def __init__(self, pos_start, pos_end, details):
|
||||||
|
super().__init__(pos_start, pos_end, 'IllegalCharacter', details)
|
||||||
|
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# POSITION
|
||||||
|
#######################################
|
||||||
|
class Position:
|
||||||
|
def __init__(self, idx, ln, col, fn, ftxt):
|
||||||
|
self.idx = idx
|
||||||
|
self.ln = ln
|
||||||
|
self.col = col
|
||||||
|
self.fn = fn
|
||||||
|
self.ftxt = ftxt
|
||||||
|
|
||||||
|
def advance(self, current_char):
|
||||||
|
self.idx += 1
|
||||||
|
self.col += 1
|
||||||
|
|
||||||
|
if current_char == '\n':
|
||||||
|
self.ln += 1
|
||||||
|
self.col = 0
|
||||||
|
|
||||||
|
return self
|
||||||
|
|
||||||
|
def copy(self):
|
||||||
|
return Position(self.idx, self.ln, self.col, self.fn, self.ftxt)
|
||||||
|
|
||||||
|
|
||||||
|
#############
|
||||||
|
# Tokens #
|
||||||
|
#############
|
||||||
|
# Token types
|
||||||
|
TT_INT = "INT"
|
||||||
|
TT_FLOAT = "FLOAT"
|
||||||
|
TT_PLUS = "PLUS"
|
||||||
|
TT_MINUS = "MINUS"
|
||||||
|
TT_MUL = "MUL"
|
||||||
|
TT_DIV = "DIV"
|
||||||
|
TT_LPAREN = "LPAREN"
|
||||||
|
TT_RPAREN = "RPAREN"
|
||||||
|
|
||||||
|
|
||||||
|
class Token:
|
||||||
|
def __init__(self, type_, value=None):
|
||||||
|
self.type = type_
|
||||||
|
self.value = value
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
"""
|
||||||
|
Will return "type:value" if a value exists. Otherwise, just "type".
|
||||||
|
"""
|
||||||
|
return f"<{self.type}:{self.value}>" if self.value else f"<{self.type}>"
|
||||||
|
|
||||||
|
|
||||||
|
#############
|
||||||
|
# Lexer #
|
||||||
|
#############
|
||||||
|
class Lexer:
|
||||||
|
def __init__(self, fn, text):
|
||||||
|
self.fn = fn
|
||||||
|
self.text = text
|
||||||
|
self.pos = Position(-1, 0, -1, fn, text)
|
||||||
|
self.current_char = None
|
||||||
|
self.advance()
|
||||||
|
|
||||||
|
def advance(self):
|
||||||
|
self.pos.advance(self.current_char)
|
||||||
|
self.current_char = self.text[self.pos.idx] if self.pos.idx < len(self.text) else None
|
||||||
|
|
||||||
|
def make_tokens(self):
|
||||||
|
tokens = []
|
||||||
|
|
||||||
|
while self.current_char is not None:
|
||||||
|
if self.current_char in ' \t':
|
||||||
|
# Ignore spaces and tabs
|
||||||
|
self.advance()
|
||||||
|
elif self.current_char in DIGITS:
|
||||||
|
tokens.append(self.make_number())
|
||||||
|
elif self.current_char == "+":
|
||||||
|
tokens.append(Token(TT_PLUS))
|
||||||
|
self.advance()
|
||||||
|
elif self.current_char == "-":
|
||||||
|
tokens.append(Token(TT_MINUS))
|
||||||
|
self.advance()
|
||||||
|
elif self.current_char == "*":
|
||||||
|
tokens.append(Token(TT_MUL))
|
||||||
|
self.advance()
|
||||||
|
elif self.current_char == "/":
|
||||||
|
tokens.append(Token(TT_DIV))
|
||||||
|
self.advance()
|
||||||
|
elif self.current_char == "(":
|
||||||
|
tokens.append(Token(TT_LPAREN))
|
||||||
|
self.advance()
|
||||||
|
elif self.current_char == ")":
|
||||||
|
tokens.append(Token(TT_RPAREN))
|
||||||
|
self.advance()
|
||||||
|
else:
|
||||||
|
pos_start = self.pos.copy()
|
||||||
|
char = self.current_char
|
||||||
|
self.advance()
|
||||||
|
return [], IllegalCharError(pos_start, self.pos, "'" + char + "'")
|
||||||
|
|
||||||
|
return tokens, None
|
||||||
|
|
||||||
|
def make_number(self):
|
||||||
|
num_str = ''
|
||||||
|
dot_count = 0
|
||||||
|
|
||||||
|
while self.current_char is not None and self.current_char in (DIGITS + '.'):
|
||||||
|
if self.current_char == '.':
|
||||||
|
if dot_count == 1:
|
||||||
|
break # Break if multiple dots.
|
||||||
|
dot_count += 1
|
||||||
|
num_str += '.'
|
||||||
|
else:
|
||||||
|
num_str += self.current_char
|
||||||
|
self.advance()
|
||||||
|
|
||||||
|
if dot_count == 0:
|
||||||
|
return Token(TT_INT, int(num_str))
|
||||||
|
else:
|
||||||
|
return Token(TT_FLOAT, float(num_str))
|
||||||
|
|
||||||
|
|
||||||
|
#############
|
||||||
|
# Runner #
|
||||||
|
#############
|
||||||
|
def evaluate(fn, text):
|
||||||
|
lexer = Lexer(fn, text)
|
||||||
|
tokens, error = lexer.make_tokens()
|
||||||
|
|
||||||
|
return tokens, error
|
||||||
63
example_program.aur
Normal file
63
example_program.aur
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# d888888
|
||||||
|
# d88P aaa 888 888 888d88 .d88b. 888d88 8888b.
|
||||||
|
# d88P aaa 888 888 888P d88^^88b 888P 88b
|
||||||
|
# d88P aaa 888 888 888 888 888 888 .d888888
|
||||||
|
# d8888888888 Y88b 888 888 Y88..88P 888 888 888
|
||||||
|
# d88P aaa Y88888 888 Y88P 888 Y888888
|
||||||
|
# -- Copyright © 2023 Zandercraft. All rights reserved. --
|
||||||
|
#
|
||||||
|
# Purpose: Example of Aurora's basic syntax.
|
||||||
|
|
||||||
|
set Ball(
|
||||||
|
struct(
|
||||||
|
x: int,
|
||||||
|
y: int,
|
||||||
|
dx: int | null,
|
||||||
|
dy: int | null
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
set Paddle(
|
||||||
|
struct(
|
||||||
|
x: int,
|
||||||
|
y: int,
|
||||||
|
dy: int | null
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
set create_ball(
|
||||||
|
fun(() -> Ball:
|
||||||
|
return(Ball(x: 400, y: 300, dx: 2, dy: 2))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
set create_paddle(
|
||||||
|
fun((x: int) -> Paddle:
|
||||||
|
return(Paddle(x: x, y: 250, dy: 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
set update_ball(
|
||||||
|
fun((ball: Ball) -> Ball:
|
||||||
|
set ball.x(float(ball.x + 1))
|
||||||
|
set ball.y(float(ball.y + 1))
|
||||||
|
if((ball.x > 255 or ball.y > 255):
|
||||||
|
# Don't let the ball go further than the screen
|
||||||
|
set ball.x(float(ball.x - 1))
|
||||||
|
set ball.y(float(ball.y - 1))
|
||||||
|
) eli((ball.x < 0 or ball.y < 0):
|
||||||
|
# Don't let the ball go further than the screen
|
||||||
|
set ball.x(float(ball.x + 1))
|
||||||
|
set ball.y(float(ball.y + 1))
|
||||||
|
) eli(():
|
||||||
|
# Code here to be executed. No conditions means "else".
|
||||||
|
)
|
||||||
|
return(ball)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Start execution.
|
||||||
|
set ball(create_ball())
|
||||||
|
set paddle1(create_paddle(1))
|
||||||
|
set paddle2(create_paddle(254))
|
||||||
|
update_ball(ball)
|
||||||
11
exceptions/__init__.py
Normal file
11
exceptions/__init__.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
"""
|
||||||
|
d888888
|
||||||
|
d88P aaa 888 888 888d88 .d88b. 888d88 8888b.
|
||||||
|
d88P aaa 888 888 888P d88^^88b 888P 88b
|
||||||
|
d88P aaa 888 888 888 888 888 888 .d888888
|
||||||
|
d8888888888 Y88b 888 888 Y88..88P 888 888 888
|
||||||
|
d88P aaa Y88888 888 Y88P 888 Y888888
|
||||||
|
-- Copyright © 2023 Zandercraft. All rights reserved. --
|
||||||
|
|
||||||
|
Purpose: Basic exception types.
|
||||||
|
"""
|
||||||
12
internal/__init__.py
Normal file
12
internal/__init__.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
"""
|
||||||
|
d888888
|
||||||
|
d88P aaa 888 888 888d88 .d88b. 888d88 8888b.
|
||||||
|
d88P aaa 888 888 888P d88^^88b 888P 88b
|
||||||
|
d88P aaa 888 888 888 888 888 888 .d888888
|
||||||
|
d8888888888 Y88b 888 888 Y88..88P 888 888 888
|
||||||
|
d88P aaa Y88888 888 Y88P 888 Y888888
|
||||||
|
-- Copyright © 2023 Zandercraft. All rights reserved. --
|
||||||
|
|
||||||
|
Purpose: Internal utilities and functions.
|
||||||
|
NOTE: Meant to be used internally in Aurora. It is not meant for external use.
|
||||||
|
"""
|
||||||
61
internal/term_utils.py
Normal file
61
internal/term_utils.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
"""
|
||||||
|
d888888
|
||||||
|
d88P aaa 888 888 888d88 .d88b. 888d88 8888b.
|
||||||
|
d88P aaa 888 888 888P d88^^88b 888P 88b
|
||||||
|
d88P aaa 888 888 888 888 888 888 .d888888
|
||||||
|
d8888888888 Y88b 888 888 Y88..88P 888 888 888
|
||||||
|
d88P aaa Y88888 888 Y88P 888 Y888888
|
||||||
|
-- Copyright © 2023 Zandercraft. All rights reserved. --
|
||||||
|
|
||||||
|
Purpose: Contains utility functions to enhance terminal functionality.
|
||||||
|
NOTE: Meant to be used internally in Aurora. It is not meant for external use.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Imports
|
||||||
|
import enum
|
||||||
|
|
||||||
|
|
||||||
|
class Colour(enum.Enum):
|
||||||
|
"""
|
||||||
|
ANSII colour code representations.
|
||||||
|
(Use in the colour() function)
|
||||||
|
"""
|
||||||
|
RED = 91
|
||||||
|
GREEN = 92
|
||||||
|
YELLOW = 93
|
||||||
|
LIGHT_PURPLE = 94
|
||||||
|
PURPLE = 95
|
||||||
|
CYAN = 96
|
||||||
|
|
||||||
|
|
||||||
|
def colour(text: str, variant: Colour):
|
||||||
|
"""
|
||||||
|
Sets the colour of the given text. (To be used in print() calls)
|
||||||
|
:param text: text to set the colour of.
|
||||||
|
:param variant: the colour to set the text to.
|
||||||
|
:return: coloured text (when printed).
|
||||||
|
"""
|
||||||
|
return f"\033[{variant.value}m{text}\033[00m"
|
||||||
|
|
||||||
|
|
||||||
|
color = colour # Alias (for the United States)
|
||||||
|
|
||||||
|
# --- Constants ---
|
||||||
|
AURORA_TEXT = f"{colour('A', Colour.CYAN)}" \
|
||||||
|
f"{colour('u', Colour.LIGHT_PURPLE)}" \
|
||||||
|
f"{colour('r', Colour.GREEN)}" \
|
||||||
|
f"{colour('o', Colour.PURPLE)}" \
|
||||||
|
f"{colour('r', Colour.LIGHT_PURPLE)}" \
|
||||||
|
f"{colour('a', Colour.CYAN)}"
|
||||||
|
|
||||||
|
COPYRIGHT_NOTICE = "-- Copyright © 2023 Zandercraft. All rights reserved. --"
|
||||||
|
|
||||||
|
WELCOME = f"Welcome to the {AURORA_TEXT} CLI interpreter! To exit type 'exit'"
|
||||||
|
|
||||||
|
AURORA_BANNER = f' {colour("d888888", Colour.CYAN)}\n' \
|
||||||
|
f' {colour("d88P aaa", Colour.CYAN)} {colour("888 888", Colour.LIGHT_PURPLE)} {colour("888d88", Colour.GREEN)} {colour(".d88b.", Colour.PURPLE)} {colour("888d88", Colour.LIGHT_PURPLE)} {colour("8888b.", Colour.CYAN)}\n' \
|
||||||
|
f' {colour("d88P aaa", Colour.CYAN)} {colour("888 888", Colour.LIGHT_PURPLE)} {colour("888P", Colour.GREEN)} {colour("d88^^88b", Colour.PURPLE)} {colour("888P", Colour.LIGHT_PURPLE)} {colour("88b", Colour.CYAN)}\n' \
|
||||||
|
f' {colour("d88P aaa", Colour.CYAN)} {colour("888 888", Colour.LIGHT_PURPLE)} {colour("888", Colour.GREEN)} {colour("888 888", Colour.PURPLE)} {colour("888", Colour.LIGHT_PURPLE)} {colour(".d888888", Colour.CYAN)}\n' \
|
||||||
|
f' {colour("d8888888888", Colour.CYAN)} {colour("Y88b 888", Colour.LIGHT_PURPLE)} {colour("888", Colour.GREEN)} {colour("Y88..88P", Colour.PURPLE)} {colour("888", Colour.LIGHT_PURPLE)} {colour("888 888", Colour.CYAN)}\n' \
|
||||||
|
f'{colour("d88P aaa", Colour.CYAN)} {colour(" Y88888", Colour.LIGHT_PURPLE)} {colour("888", Colour.GREEN)} {colour("Y88P", Colour.PURPLE)} {colour("888", Colour.LIGHT_PURPLE)} {colour("Y888888", Colour.CYAN)}\n' \
|
||||||
|
f'{COPYRIGHT_NOTICE}'
|
||||||
40
main.py
Normal file
40
main.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
"""
|
||||||
|
d888888
|
||||||
|
d88P aaa 888 888 888d88 .d88b. 888d88 8888b.
|
||||||
|
d88P aaa 888 888 888P d88^^88b 888P 88b
|
||||||
|
d88P aaa 888 888 888 888 888 888 .d888888
|
||||||
|
d8888888888 Y88b 888 888 Y88..88P 888 888 888
|
||||||
|
d88P aaa Y88888 888 Y88P 888 Y888888
|
||||||
|
-- Copyright © 2023 Zandercraft. All rights reserved. --
|
||||||
|
|
||||||
|
Purpose: Command-line interface for the aurora language.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Imports
|
||||||
|
import aurora
|
||||||
|
from internal.term_utils import AURORA_TEXT, AURORA_BANNER, WELCOME
|
||||||
|
|
||||||
|
|
||||||
|
def interactive_shell():
|
||||||
|
"""
|
||||||
|
An interactive shell implementation.
|
||||||
|
Allows for command-like execution of Aurora code.
|
||||||
|
"""
|
||||||
|
# Print the banner and welcome message
|
||||||
|
print(AURORA_BANNER)
|
||||||
|
print(WELCOME)
|
||||||
|
|
||||||
|
# Start the programming loop.
|
||||||
|
while (u := input(f"{AURORA_TEXT}> ")) != "exit":
|
||||||
|
result, error = aurora.evaluate('<stdin>', u)
|
||||||
|
|
||||||
|
if error:
|
||||||
|
print(error.as_string())
|
||||||
|
else:
|
||||||
|
print(result)
|
||||||
|
|
||||||
|
print(f"Thanks for using {AURORA_TEXT}! See you soon!")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
interactive_shell()
|
||||||
Reference in New Issue
Block a user