Skip to content

Commit 3ee127b

Browse files
authored
Merge pull request #296 from asteroid-lang/dev-2.0.1
Dev 2.0.1
2 parents 29ce86e + 8bc7f4a commit 3ee127b

262 files changed

Lines changed: 5363 additions & 6778 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/generate_documentation.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
# this script throws an error when trying to commit the generated documentation
2+
# right now set to 'none' branch that will not match anything in this repo
13
name: Documentation Generation
24
on:
35
pull_request:
46
branches:
5-
- 'dev-**'
7+
#- 'dev-**'
8+
- 'none'
69

710
push:
811
branches:
9-
- 'dev-**'
12+
#- 'dev-**'
13+
- 'none'
1014
env:
1115
PYTHONPATH: ${{ github.workspace }}
1216
jobs:

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,31 @@ be found at the website [asteroid-lang.org](https://asteroid-lang.org).
44
Documentation on Asteroid can be found at
55
[asteroid-lang.readthedocs.io](https://asteroid-lang.readthedocs.io).
66

7+
## New in Release 2.0.1
8+
9+
* We now support the ASTEROIDPATH environment variable which is expected to have a colon seperated list of directories to search for user defined modules.
10+
11+
* The logical operators 'and' and 'or' are now evaluated in short-circuit fashion.
12+
13+
* Files loaded with the 'load' statement are now considered modules and work similarly to Python modules.
14+
15+
* Added the 'toplevel' function which returns true if control is in the module originally loaded by the interpreter.
16+
17+
* Added the match statement similar to the match statement in Python.
18+
19+
* No longer supports type hierarchies for the primitive types. The functions in the 'type' module are now considered builtins. The 'type' module itself has been eliminated.
20+
21+
* The Minimal Asteroid Debugger (MAD) replaces ADB in this release.
22+
23+
* The shorthand conditional pattern can now be applied to arbitrary patterns. E.g. The pattern
24+
```
25+
(a,b,c):(%integer,%integer,%integer)
26+
```
27+
constrains the triple `(a,b,c)` to be a triple of integers. The above shorthand conditional pattern is equivalent to the conditional pattern,
28+
```
29+
(a,b,c) if (a,b,c) is (%integer,%integer,%integer)
30+
```
31+
732
## New in Release 1.1.4
833

934
* Allows pattern constraint operator to map certain variables that a pattern

asteroid/__init__.py

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,45 @@
1212
from asteroid.interp import interp
1313
from asteroid.repl import repl
1414
from asteroid.version import VERSION
15-
from asteroid.adb import adb
15+
from asteroid.mad import MAD
1616

1717
def display_help():
18-
print("** Asteroid Version {} **".format(VERSION))
18+
print("Asteroid {}".format(VERSION))
1919
print("(c) University of Rhode Island")
20-
print("usage: asteroid [-<switch>] <input file>")
20+
print("usage: asteroid [<switch>] <input file>")
2121
print("")
22-
print("command line flags:")
22+
print("command line switches:")
23+
print(" -d run program through debugger")
24+
print(" -e show Python exceptions")
25+
print(" -F functional mode")
26+
print(" -h, --help display help")
27+
print(" -p disable prologue")
28+
print(" -r disable redundant pattern detector")
2329
print(" -s enable symbol table dump")
2430
print(" -t AST dump")
2531
print(" -v, --version version")
2632
print(" -w disable tree walk")
33+
print(" -W disable warnings")
2734
print(" -z generate pstats")
28-
print(" -p disable prologue")
29-
print(" -h, --help display help")
30-
print(" -r disable redundant pattern detector")
31-
print(" -e show Python exceptions")
32-
print(" -F functional mode")
33-
print(" -g, --adb run program through debugger")
3435

3536
def main():
36-
# defaults for the flags - when the flag is set on the command line
37+
# defaults for the switches or flags - when the flag is set on the command line
3738
# it simply toggles the default value in this table.
3839
flags = {
40+
'-d' : False, # Short debugger flag
41+
'-e' : False, # show full exceptions
42+
'-F' : False, # functional mode
43+
'--help' : False, # display help flag
44+
'-h' : False, # display help flag
45+
'-p' : True, # prologue flag
46+
'-r' : True, # redundant pattern dectector
3947
'-s' : False, # symbol table dump flag
4048
'-t' : False, # AST dump flag
4149
'--version' : False, # version flag
4250
'-v' : False, # version flag
4351
'-w' : True, # tree walk flag
52+
'-W' : True, # warnings
4453
'-z' : False, # generate pstats flag
45-
'-p' : True, # prologue flag
46-
'--help' : False, # display help flag
47-
'-h' : False, # display help flag
48-
'-r' : True, # redundant pattern dectector
49-
'-e' : False, # show full exceptions
50-
'-F' : False, # functional mode
51-
'--adb': False, # debugger flag
52-
'-g': False # Short debugger flag
5354
}
5455

5556
flag_names = list(flags.keys())
@@ -80,10 +81,10 @@ def main():
8081
sys.exit(0)
8182

8283
if flags['--version'] or flags['-v']:
83-
print("** Asteroid Version {} **".format(VERSION))
84+
print("Asteroid {}".format(VERSION))
8485
sys.exit(0)
8586

86-
debug_flag = flags['--adb'] or flags['-g']
87+
debug_flag = flags['-d']
8788

8889
# determine if we are starting in interactive mode or not
8990
# Note: first non-switch argument has to be an Asteroid source file
@@ -108,22 +109,11 @@ def main():
108109
print("error: unknown file '{}'".format(input_file))
109110
sys.exit(1)
110111

111-
# run the debugger
112112
if debug_flag:
113-
if input_ext == '':
114-
print("error: please provide a file to debug")
115-
sys.exit(1)
116113
# Create a new debugger
117-
db = adb.ADB()
118-
# Set the debugger's internal interpretation options
119-
db.interp_options = {
120-
'redundancy': flags['-r'],
121-
'prologue': flags['-p'],
122-
'functional_mode': flags['-F'],
123-
'exceptions': flags['-e'],
124-
}
125-
db.run(input_file)
126-
sys.exit(0)
114+
db = MAD()
115+
else:
116+
db = None
127117

128118
# execute the interpreter
129119
f = open(input_file, 'r')
@@ -134,18 +124,21 @@ def main():
134124
interp_object = \
135125
'''interp(program=input_stream,
136126
program_name = input_file,
137-
tree_dump=flags['-t'],
138-
do_walk=flags['-w'],
139-
symtab_dump=flags['-s'],
140127
exceptions=flags['-e'],
141-
redundancy=flags['-r'],
128+
functional_mode=flags['-F'],
142129
prologue=flags['-p'],
143-
functional_mode=flags['-F'])'''
130+
redundancy=flags['-r'],
131+
symtab_dump=flags['-s'],
132+
tree_dump=flags['-t'],
133+
do_walk=flags['-w'],
134+
warnings=flags['-W'],
135+
debugger=db
136+
)'''
144137

145138
if flags['-z']:
146139
# generates pstats into the file 'pstats'
147140
# see https://docs.python.org/3/library/profile.html
148-
cProfile.run(interp_object, 'pstats')
141+
cProfile.runctx(interp_object, globals(), locals(), filename='pstats')
149142
else:
150143
exec(interp_object)
151144

asteroid/adb/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)