Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed include to import #130

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ lint:

.PHONY: test
test:
@$(PYTHON) test.py run
@$(PYTHON) test.py full

.PHONY: test-record
test-record:
Expand Down
2 changes: 1 addition & 1 deletion core/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def visit_VarAssignNode(self, node: VarAssignNode, context: Context) -> RTResult
pos_end=node.pos_end,
)

def visit_IncludeNode(self, node: IncludeNode, context: Context) -> RTResult[Value]:
def visit_ImportNode(self, node: ImportNode, context: Context) -> RTResult[Value]:
res = RTResult[Value]()
exec_ctx = context

Expand Down
2 changes: 1 addition & 1 deletion core/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __init__(
)


class IncludeNode:
class ImportNode:
module: Token

pos_start: Position
Expand Down
6 changes: 3 additions & 3 deletions core/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,22 +221,22 @@ def statement(self) -> ParseResult[Node]:
assert switch_node is not None
return res.success(switch_node)

if self.current_tok.matches(TT_KEYWORD, "include"):
if self.current_tok.matches(TT_KEYWORD, "import"):
self.advance(res)

if self.current_tok.type != TT_STRING and self.current_tok.type != TT_IDENTIFIER:
return res.failure(
InvalidSyntaxError(
self.current_tok.pos_start,
self.current_tok.pos_end,
"Expected string or identifier as included module",
"Expected string or identifier as imported module",
)
)

module = self.current_tok
self.advance(res)

return res.success(IncludeNode(module))
return res.success(ImportNode(module))

expr = res.register(self.expr())
if res.error:
Expand Down
2 changes: 1 addition & 1 deletion core/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def copy(self) -> Position:
"continue",
"break",
"class",
"include",
"import",
"try",
"catch",
"as",
Expand Down
2 changes: 1 addition & 1 deletion examples/args_test.rn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include Argparser
import Argparser

parser = Argparser("Utility Tool", "A simple utility tool.")

Expand Down
2 changes: 1 addition & 1 deletion examples/arrays.rn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include Array
import Array

arr = Array.Array([1,2,3,4,5,6,7,8,9,10])
arr.append(11)
Expand Down
2 changes: 1 addition & 1 deletion examples/colors_test.rn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include Colorlib
import Colorlib

# Print colored text to the console using the colorlib library
print(Colorlib.white("My name is John Doe"))
Expand Down
4 changes: 2 additions & 2 deletions examples/import_test.rn
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
# require("String")

#!
include String
import String

data = "Hello World !"
str = String.String(data)

print(str.len())

!#
include Math
import Math

print(Math.PI) # Ligal

12 changes: 12 additions & 0 deletions examples/operators-bug.rn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
x = 5
y = 2

x /= y
print(x) # 2.5 OK as floor division.

x //= y
print(x) # 1.0 Failed as Integer division

assert 5 / 5 == 1.0 # 1.0 OK as floor division.

assert 5 // 5 == 1 # Invalid Syntax: Token cannot appear after previous tokens
2 changes: 1 addition & 1 deletion tests/universe.rn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

include Universe
import Universe