forked from skulpt/skulpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hex, oct, and bin builtin functions.
- Loading branch information
Showing
7 changed files
with
223 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
for ch in "Hello world!": | ||
d = ord(ch) | ||
h = hex(d) | ||
o = oct(d) | ||
b = bin(d) | ||
|
||
print ch, d, h, o, b | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
H 72 0x48 0110 0b1001000 | ||
e 101 0x65 0145 0b1100101 | ||
l 108 0x6c 0154 0b1101100 | ||
l 108 0x6c 0154 0b1101100 | ||
o 111 0x6f 0157 0b1101111 | ||
32 0x20 040 0b100000 | ||
w 119 0x77 0167 0b1110111 | ||
o 111 0x6f 0157 0b1101111 | ||
r 114 0x72 0162 0b1110010 | ||
l 108 0x6c 0154 0b1101100 | ||
d 100 0x64 0144 0b1100100 | ||
! 33 0x21 041 0b100001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
Sym_type: module | ||
Sym_name: top | ||
Sym_lineno: 0 | ||
Sym_nested: False | ||
Sym_haschildren: False | ||
-- Identifiers -- | ||
name: b | ||
is_referenced: True | ||
is_imported: False | ||
is_parameter: False | ||
is_global: False | ||
is_declared_global: False | ||
is_local: True | ||
is_free: False | ||
is_assigned: True | ||
is_namespace: False | ||
namespaces: [ | ||
] | ||
name: bin | ||
is_referenced: True | ||
is_imported: False | ||
is_parameter: False | ||
is_global: True | ||
is_declared_global: False | ||
is_local: False | ||
is_free: False | ||
is_assigned: False | ||
is_namespace: False | ||
namespaces: [ | ||
] | ||
name: ch | ||
is_referenced: True | ||
is_imported: False | ||
is_parameter: False | ||
is_global: False | ||
is_declared_global: False | ||
is_local: True | ||
is_free: False | ||
is_assigned: True | ||
is_namespace: False | ||
namespaces: [ | ||
] | ||
name: d | ||
is_referenced: True | ||
is_imported: False | ||
is_parameter: False | ||
is_global: False | ||
is_declared_global: False | ||
is_local: True | ||
is_free: False | ||
is_assigned: True | ||
is_namespace: False | ||
namespaces: [ | ||
] | ||
name: h | ||
is_referenced: True | ||
is_imported: False | ||
is_parameter: False | ||
is_global: False | ||
is_declared_global: False | ||
is_local: True | ||
is_free: False | ||
is_assigned: True | ||
is_namespace: False | ||
namespaces: [ | ||
] | ||
name: hex | ||
is_referenced: True | ||
is_imported: False | ||
is_parameter: False | ||
is_global: True | ||
is_declared_global: False | ||
is_local: False | ||
is_free: False | ||
is_assigned: False | ||
is_namespace: False | ||
namespaces: [ | ||
] | ||
name: o | ||
is_referenced: True | ||
is_imported: False | ||
is_parameter: False | ||
is_global: False | ||
is_declared_global: False | ||
is_local: True | ||
is_free: False | ||
is_assigned: True | ||
is_namespace: False | ||
namespaces: [ | ||
] | ||
name: oct | ||
is_referenced: True | ||
is_imported: False | ||
is_parameter: False | ||
is_global: True | ||
is_declared_global: False | ||
is_local: False | ||
is_free: False | ||
is_assigned: False | ||
is_namespace: False | ||
namespaces: [ | ||
] | ||
name: ord | ||
is_referenced: True | ||
is_imported: False | ||
is_parameter: False | ||
is_global: True | ||
is_declared_global: False | ||
is_local: False | ||
is_free: False | ||
is_assigned: False | ||
is_namespace: False | ||
namespaces: [ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
Module(body=[For(target=Name(id='ch', | ||
ctx=Store()), | ||
iter=Str(s='Hello world!'), | ||
body=[Assign(targets=[Name(id='d', | ||
ctx=Store())], | ||
value=Call(func=Name(id='ord', | ||
ctx=Load()), | ||
args=[Name(id='ch', | ||
ctx=Load())], | ||
keywords=[], | ||
starargs=None, | ||
kwargs=None)), | ||
Assign(targets=[Name(id='h', | ||
ctx=Store())], | ||
value=Call(func=Name(id='hex', | ||
ctx=Load()), | ||
args=[Name(id='d', | ||
ctx=Load())], | ||
keywords=[], | ||
starargs=None, | ||
kwargs=None)), | ||
Assign(targets=[Name(id='o', | ||
ctx=Store())], | ||
value=Call(func=Name(id='oct', | ||
ctx=Load()), | ||
args=[Name(id='d', | ||
ctx=Load())], | ||
keywords=[], | ||
starargs=None, | ||
kwargs=None)), | ||
Assign(targets=[Name(id='b', | ||
ctx=Store())], | ||
value=Call(func=Name(id='bin', | ||
ctx=Load()), | ||
args=[Name(id='d', | ||
ctx=Load())], | ||
keywords=[], | ||
starargs=None, | ||
kwargs=None)), | ||
Print(dest=None, | ||
values=[Name(id='ch', | ||
ctx=Load()), | ||
Name(id='d', | ||
ctx=Load()), | ||
Name(id='h', | ||
ctx=Load()), | ||
Name(id='o', | ||
ctx=Load()), | ||
Name(id='b', | ||
ctx=Load())], | ||
nl=True)], | ||
orelse=[])]) |