123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- AbstractInterpreter.prototype.TYPE_INHERITANCE = {
- "Sequence": ["List", "Set", "Tuple", "Str"],
- "Num": ["Int", "Float"]
- }
- AbstractInterpreter.prototype.BUILTINS = {
- //
- 'KeyError': {"type": "Exception"},
- 'IOError': {"type": "Exception"},
- // Values
- 'True': {"type": "Bool"},
- 'False': {"type": "Bool"},
- 'None': {"type": 'None'},
- // Functions
- "print": {
- "type": "Function",
- "returns": {"type": "None"},
- "parameters": [
- {"type": "Any", "var": true}
- ]
- },
- "sum": {
- "type": "Function",
- "returns": {"type": "Num"},
- "parameters": [
- {"type": "Sequence"},
- {"type": "Num", "optional": true}
- ]
- },
- "max": {
- "type": "Function",
- "returns": {"type": "Num"},
- "parameters": [
- {"type": "Sequence"},
- ]
- },
- "min": {
- "type": "Function",
- "returns": {"type": "Num"},
- "parameters": [
- {"type": "Sequence"},
- ]
- },
- "open": {
- "type": "Function",
- "returns": {"type": "File"},
- "parameters": [
- {"type": "Str"},
- {"type": "Str", "name": "mode", "optional": true}
- ]
- },
- "round": {
- "type": "Function",
- "returns": {"type": "Num"},
- "parameters": [
- {"type": "Num"},
- {"type": "Num"}
- ]
- },
- "float": {
- "type": "Function",
- "returns": {"type": "Num"},
- "parameters": [
- {"type": ["Str", "Num", "Bool"]}
- ]
- },
- "range": {
- "type": "Function",
- "returns": {"type": "List", "subtype": {"type": "Num"}},
- "parameters": [
- {"type": "Num"},
- {"type": "Num", "optional": true}
- ]
- },
- "map": {
- "type": "Function",
- "returns": {"type": "List"},
- "parameters": [
- {"type": "Function"},
- {"type": "Sequence"}
- ]
- },
- "filter": {
- "type": "Function",
- "returns": {"type": "List"},
- "parameters": [
- {"type": "Function"},
- {"type": "Sequence"}
- ]
- },
- "sorted": {
- "type": "Function",
- "returns": {"type": "List"},
- "parameters": [
- {"type": "Sequence"},
- {"type": "Function", "optional": true},
- {"type": "Function", "optional": true}
- ]
- },
- "xrange": {
- "type": "Function",
- "returns": {"type": "List", "subtype": {"type": "Num"}},
- "parameters": [
- {"type": "Num"},
- {"type": "Num", "optional": true}
- ]
- },
- "str": {
- "type": "Function",
- "returns": {"type": "Str"},
- "parameters": [
- {"type": "Any"}
- ]
- },
- "set": {
- "type": "Function",
- "returns": {"type": "Set"},
- "parameters": [
- {"type": "Any"}
- ]
- },
- "list": {
- "type": "Function",
- "returns": {"type": "List"},
- "parameters": [
- {"type": "Any"}
- ]
- },
- "dict": {
- "type": "Function",
- "returns": {"type": "Dict"},
- "parameters": [
- {"type": "Any"}
- ]
- },
- "abs": {
- "type": "Function",
- "returns": {"type": "Num"},
- "parameters": [
- {"type": "Num"}
- ]
- },
- "int": {
- "type": "Function",
- "returns": {"type": "Num"},
- "parameters": [
- {"type": "Any"}
- ]
- },
- "len": {
- "type": "Function",
- "returns": {"type": "Num"},
- "parameters": [
- {"type": "Sequence"}
- ]
- },
- 'input': {"type": "Str"},
- 'reversed': {"type": "List"},
- 'type': {"type": "Any"},
- 'dir': {"type": "List"}
- };
- AbstractInterpreter.METHODS = {
- "List": {
- "append": {
- "type": "Function",
- "returns": {"type": "None"}
- }
- },
- "Str": {
- "strip": {
- "type": "Function",
- "returns": {"type": "Str"}
- }
- }
- }
- AbstractInterpreter.MODULES = {
- 'random': {
- 'randint': { "type": "Function", "returns": {"type": "Num"}},
- 'choice': { "type": "Function", "returns": {"type": "Any"}},
- 'shuffle': { "type": "Function", "returns": {"type": "None"}},
- },
- 'parking': {
- 'now': { 'type': 'ParkingTime'},
- 'Time': { 'type': 'ParkingTime'},
- 'Day': { 'type': 'ParkingDay'},
- 'today': { 'type': 'ParkingDay'}
- },
- 'weather': {
- 'get_temperature': {"type": 'Num'},
- 'get_forecasts': {"type": "List", "empty": false, "component": {"type": 'Num'}},
- 'get_report': {"type": "Dict", "all_strings": true,
- "keys": {"temperature": {"type": 'Num'},
- "humidity": {"type": "Num"},
- "wind": {"type": "Num"}}},
- 'get_forecasted_reports': [{"temperature": 'Num', "humidity": "Num", "wind": "Num"}],
- 'get_all_forecasted_temperatures': [{'city': 'str', 'forecasts': ['int']}],
- 'get_highs_lows': {'highs': ['Num'], 'lows': ['Num']}
- },
- 'image': {
-
- },
- 'stocks': {
- 'get_current': 'float',
- 'get_past': ['float'],
- },
- 'earthquakes': {
- 'get': ['float'],
- 'get_both': [{'magnitude': 'float', 'depth': 'float'}],
- 'get_all': [{'magnitude': 'float', 'distance': 'float', 'gap': 'int',
- 'id': 'str', 'significance': 'int', 'time': 'int',
- 'location': {'depth': 'float', 'latitude': 'float', 'longitude': 'float',
- 'location_description': 'str'}}]
- },
- 'crime': {
- 'get_property_crimes': ['float'],
- 'get_violent_crimes': ['float'],
- 'get_both_crimes': ['float'],
- 'get_by_year': [{'state': 'str', 'violent': 'float', 'property': 'float', 'population': 'int'}],
- 'get_all': {}
- },
- 'books': {
- 'get_all': [{'title': 'str', 'author': 'str', 'price': 'float', 'paperback': 'bool', 'page count': 'int'}]
- }
- }
|