bffuck 3.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,172 @@
1
+ Metadata-Version: 2.1
2
+ Name: bffuck
3
+ Version: 3.0.1
4
+ Summary: Makes Brainfucking Easier!
5
+ Home-page: https://github.com/none-None1/BFFuck
6
+ Classifier: Operating System :: OS Independent
7
+ Classifier: Programming Language :: Python :: 3 :: Only
8
+ Classifier: Topic :: Software Development :: Code Generators
9
+ Description-Content-Type: text/markdown
10
+
11
+ [![Downloads](https://static.pepy.tech/badge/bffuck)](https://pepy.tech/project/bffuck) [![Downloads](https://static.pepy.tech/badge/bffuck/month)](https://pepy.tech/project/bffuck) [![Downloads](https://static.pepy.tech/badge/bffuck/week)](https://pepy.tech/project/bffuck)
12
+
13
+ # BFFuck
14
+ Makes brainfucking easier
15
+
16
+ The tools is an esoteric language that compiles to brainfuck, using algorithms in [brainfuck algorithms](https://esolangs.org/wiki/Brainfuck_algorithms).
17
+
18
+ ### Usage:
19
+ Run this in Python:
20
+ ```python
21
+ from bffuck import BFFuck
22
+ bff=BFFuck()
23
+ bf=bff.compile('Your code')
24
+ ```
25
+
26
+ Note that if a BFFuck object is created and used, its status will change and therefore cannot compile another program.
27
+ ### Syntax
28
+ BFFuck currently supports the following syntax:
29
+
30
+ Comment:
31
+ ```
32
+ # Comment
33
+ ```
34
+ Variable definition:
35
+ ```text
36
+ <variable 1>=<variable 2>
37
+ or
38
+ <variable>=<number>
39
+ ```
40
+
41
+ Addition:
42
+ ```text
43
+ add(x,<number>)
44
+ or
45
+ add(x,<variable>)
46
+ ```
47
+
48
+ Subtraction:
49
+ ```
50
+ sub(x,<number>)
51
+ or
52
+ sub(x,<variable>)
53
+ ```
54
+
55
+ Multiplication:
56
+ ```
57
+ mul(x,<number>)
58
+ or
59
+ mul(x,<variable>)
60
+ ```
61
+
62
+ Modulo:
63
+ ```
64
+ mod(x,<number>)
65
+ or
66
+ mod(x,<variable>)
67
+ ```
68
+
69
+ While loop:
70
+ ```text
71
+ while(<variable or number>)
72
+ CODE
73
+ endwhile
74
+ ```
75
+
76
+ I/O:
77
+ ```text
78
+ <variable>=in # Reads <variable> as decimal integer
79
+ <variable>=inc # Reads <variable> as ASCII character
80
+ out(<variable or number>) # Outputs <variable> as decimal integer
81
+ outc(<variable or number>) # Outputs <variable> as ASCII character
82
+ ```
83
+
84
+ String output shortcut:
85
+ ```text
86
+ print(STRING) # Without quotes
87
+ # For instance
88
+ print(Hello World!)
89
+ ```
90
+
91
+ If statement:
92
+ ```text
93
+ if(<variable or number>)
94
+ CODE
95
+ endif
96
+
97
+ if(<variable or number>)
98
+ CODE1
99
+ else
100
+ CODE2
101
+ endif
102
+ ```
103
+
104
+ Comparison:
105
+ ```text
106
+ lt(x,<number>) # Compares x and the variable or number, if x is less than the variable or number, set x to 1, otherwise 0
107
+ or
108
+ lt(x,<variable>)
109
+
110
+ eq(x,<number>) # Compares x and the variable or number, if x is equal to the variable or number, set x to 1, otherwise 0
111
+ or
112
+ eq(x,<variable>)
113
+ ```
114
+
115
+ Macros:
116
+ ```text
117
+ macro $<name> # Macro with no arguments
118
+ CODE
119
+ endmacro
120
+
121
+ macro $<name>(<arg1>,<arg2>,...) # Macro with arguments
122
+ CODE
123
+ endmacro
124
+
125
+ $<name> # Using a macro with no arguments
126
+ $<name>(<arg1>,<arg2>,...) # Using a macro with arguments
127
+ ```
128
+
129
+ Memory:
130
+ ```text
131
+ ptr(a,b) # Store address of a to variable b
132
+ ref(a,b) # Store value of address b to variable a
133
+ set(a,b) # Set value of address b to a (variable or integer literal)
134
+ ```
135
+
136
+ Libraries
137
+ ```text
138
+ ?libraryname
139
+ ```
140
+ Includes the library `library name` (with file extension).
141
+
142
+ It first searches the library in current directory, and then in the `stdlib` directory in the package.
143
+
144
+ There are standard libraries for BFFuck, they are:
145
+ * `env.bff` gets size of a "byte" specified by the compiler
146
+ * `alloc.bff` allocates memory
147
+ * `array.bff` manages memory using arrays
148
+ * `rng.bff` a not very decent random number generator
149
+
150
+ An example of the `rng.bff` library is here:
151
+ ```text
152
+ ?rng.bff
153
+ x=0
154
+ while(1)
155
+ $rnd(x)
156
+ outc(x)
157
+ endwhile
158
+ ```
159
+ Prints random bytes.
160
+ ### Platform
161
+ BFFuck is in **pure Python** and therefore it supports any platform.
162
+
163
+ ### Constraints
164
+ Programs compiled from BFFuck needs you to have 8 bit cells that wrap.
165
+
166
+ ### Disadvantages
167
+ BFFuck currently has these disadvantages:
168
+ 1. <s>It's numbers are 8 bit numbers.</s> You can choose 8-bit, 16-bit or 32-bit numbers using the `byte` keyword argument. But you need to run it on a 8-bit interpreter. <font color="red">REMEMBER: Using numbers with more bits is slower and increases the size of program largely! If you're using 32 bit, remember to use an extremely optimizing interpreter like bffsree!</font>
169
+ 2. It has some bugs.
170
+
171
+
172
+ The repository contains some examples, including a Hello World program, a cat program and an A+B program.
@@ -0,0 +1,19 @@
1
+ MANIFEST.in
2
+ README.md
3
+ setup.py
4
+ BFFuck.egg-info/PKG-INFO
5
+ BFFuck.egg-info/SOURCES.txt
6
+ BFFuck.egg-info/dependency_links.txt
7
+ BFFuck.egg-info/entry_points.txt
8
+ BFFuck.egg-info/top_level.txt
9
+ bffuck/__init__.py
10
+ bffuck/bffuck.py
11
+ bffuck.egg-info/PKG-INFO
12
+ bffuck.egg-info/SOURCES.txt
13
+ bffuck.egg-info/dependency_links.txt
14
+ bffuck.egg-info/entry_points.txt
15
+ bffuck.egg-info/top_level.txt
16
+ bffuck/stdlib/alloc.bff
17
+ bffuck/stdlib/array.bff
18
+ bffuck/stdlib/env.bff
19
+ bffuck/stdlib/rng.bff
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ bffuck = bffuck:_cli
@@ -0,0 +1 @@
1
+ bffuck
@@ -0,0 +1 @@
1
+ recursive-include bffuck/stdlib *.bff
bffuck-3.0.1/PKG-INFO ADDED
@@ -0,0 +1,172 @@
1
+ Metadata-Version: 2.1
2
+ Name: bffuck
3
+ Version: 3.0.1
4
+ Summary: Makes Brainfucking Easier!
5
+ Home-page: https://github.com/none-None1/BFFuck
6
+ Classifier: Operating System :: OS Independent
7
+ Classifier: Programming Language :: Python :: 3 :: Only
8
+ Classifier: Topic :: Software Development :: Code Generators
9
+ Description-Content-Type: text/markdown
10
+
11
+ [![Downloads](https://static.pepy.tech/badge/bffuck)](https://pepy.tech/project/bffuck) [![Downloads](https://static.pepy.tech/badge/bffuck/month)](https://pepy.tech/project/bffuck) [![Downloads](https://static.pepy.tech/badge/bffuck/week)](https://pepy.tech/project/bffuck)
12
+
13
+ # BFFuck
14
+ Makes brainfucking easier
15
+
16
+ The tools is an esoteric language that compiles to brainfuck, using algorithms in [brainfuck algorithms](https://esolangs.org/wiki/Brainfuck_algorithms).
17
+
18
+ ### Usage:
19
+ Run this in Python:
20
+ ```python
21
+ from bffuck import BFFuck
22
+ bff=BFFuck()
23
+ bf=bff.compile('Your code')
24
+ ```
25
+
26
+ Note that if a BFFuck object is created and used, its status will change and therefore cannot compile another program.
27
+ ### Syntax
28
+ BFFuck currently supports the following syntax:
29
+
30
+ Comment:
31
+ ```
32
+ # Comment
33
+ ```
34
+ Variable definition:
35
+ ```text
36
+ <variable 1>=<variable 2>
37
+ or
38
+ <variable>=<number>
39
+ ```
40
+
41
+ Addition:
42
+ ```text
43
+ add(x,<number>)
44
+ or
45
+ add(x,<variable>)
46
+ ```
47
+
48
+ Subtraction:
49
+ ```
50
+ sub(x,<number>)
51
+ or
52
+ sub(x,<variable>)
53
+ ```
54
+
55
+ Multiplication:
56
+ ```
57
+ mul(x,<number>)
58
+ or
59
+ mul(x,<variable>)
60
+ ```
61
+
62
+ Modulo:
63
+ ```
64
+ mod(x,<number>)
65
+ or
66
+ mod(x,<variable>)
67
+ ```
68
+
69
+ While loop:
70
+ ```text
71
+ while(<variable or number>)
72
+ CODE
73
+ endwhile
74
+ ```
75
+
76
+ I/O:
77
+ ```text
78
+ <variable>=in # Reads <variable> as decimal integer
79
+ <variable>=inc # Reads <variable> as ASCII character
80
+ out(<variable or number>) # Outputs <variable> as decimal integer
81
+ outc(<variable or number>) # Outputs <variable> as ASCII character
82
+ ```
83
+
84
+ String output shortcut:
85
+ ```text
86
+ print(STRING) # Without quotes
87
+ # For instance
88
+ print(Hello World!)
89
+ ```
90
+
91
+ If statement:
92
+ ```text
93
+ if(<variable or number>)
94
+ CODE
95
+ endif
96
+
97
+ if(<variable or number>)
98
+ CODE1
99
+ else
100
+ CODE2
101
+ endif
102
+ ```
103
+
104
+ Comparison:
105
+ ```text
106
+ lt(x,<number>) # Compares x and the variable or number, if x is less than the variable or number, set x to 1, otherwise 0
107
+ or
108
+ lt(x,<variable>)
109
+
110
+ eq(x,<number>) # Compares x and the variable or number, if x is equal to the variable or number, set x to 1, otherwise 0
111
+ or
112
+ eq(x,<variable>)
113
+ ```
114
+
115
+ Macros:
116
+ ```text
117
+ macro $<name> # Macro with no arguments
118
+ CODE
119
+ endmacro
120
+
121
+ macro $<name>(<arg1>,<arg2>,...) # Macro with arguments
122
+ CODE
123
+ endmacro
124
+
125
+ $<name> # Using a macro with no arguments
126
+ $<name>(<arg1>,<arg2>,...) # Using a macro with arguments
127
+ ```
128
+
129
+ Memory:
130
+ ```text
131
+ ptr(a,b) # Store address of a to variable b
132
+ ref(a,b) # Store value of address b to variable a
133
+ set(a,b) # Set value of address b to a (variable or integer literal)
134
+ ```
135
+
136
+ Libraries
137
+ ```text
138
+ ?libraryname
139
+ ```
140
+ Includes the library `library name` (with file extension).
141
+
142
+ It first searches the library in current directory, and then in the `stdlib` directory in the package.
143
+
144
+ There are standard libraries for BFFuck, they are:
145
+ * `env.bff` gets size of a "byte" specified by the compiler
146
+ * `alloc.bff` allocates memory
147
+ * `array.bff` manages memory using arrays
148
+ * `rng.bff` a not very decent random number generator
149
+
150
+ An example of the `rng.bff` library is here:
151
+ ```text
152
+ ?rng.bff
153
+ x=0
154
+ while(1)
155
+ $rnd(x)
156
+ outc(x)
157
+ endwhile
158
+ ```
159
+ Prints random bytes.
160
+ ### Platform
161
+ BFFuck is in **pure Python** and therefore it supports any platform.
162
+
163
+ ### Constraints
164
+ Programs compiled from BFFuck needs you to have 8 bit cells that wrap.
165
+
166
+ ### Disadvantages
167
+ BFFuck currently has these disadvantages:
168
+ 1. <s>It's numbers are 8 bit numbers.</s> You can choose 8-bit, 16-bit or 32-bit numbers using the `byte` keyword argument. But you need to run it on a 8-bit interpreter. <font color="red">REMEMBER: Using numbers with more bits is slower and increases the size of program largely! If you're using 32 bit, remember to use an extremely optimizing interpreter like bffsree!</font>
169
+ 2. It has some bugs.
170
+
171
+
172
+ The repository contains some examples, including a Hello World program, a cat program and an A+B program.
bffuck-3.0.1/README.md ADDED
@@ -0,0 +1,162 @@
1
+ [![Downloads](https://static.pepy.tech/badge/bffuck)](https://pepy.tech/project/bffuck) [![Downloads](https://static.pepy.tech/badge/bffuck/month)](https://pepy.tech/project/bffuck) [![Downloads](https://static.pepy.tech/badge/bffuck/week)](https://pepy.tech/project/bffuck)
2
+
3
+ # BFFuck
4
+ Makes brainfucking easier
5
+
6
+ The tools is an esoteric language that compiles to brainfuck, using algorithms in [brainfuck algorithms](https://esolangs.org/wiki/Brainfuck_algorithms).
7
+
8
+ ### Usage:
9
+ Run this in Python:
10
+ ```python
11
+ from bffuck import BFFuck
12
+ bff=BFFuck()
13
+ bf=bff.compile('Your code')
14
+ ```
15
+
16
+ Note that if a BFFuck object is created and used, its status will change and therefore cannot compile another program.
17
+ ### Syntax
18
+ BFFuck currently supports the following syntax:
19
+
20
+ Comment:
21
+ ```
22
+ # Comment
23
+ ```
24
+ Variable definition:
25
+ ```text
26
+ <variable 1>=<variable 2>
27
+ or
28
+ <variable>=<number>
29
+ ```
30
+
31
+ Addition:
32
+ ```text
33
+ add(x,<number>)
34
+ or
35
+ add(x,<variable>)
36
+ ```
37
+
38
+ Subtraction:
39
+ ```
40
+ sub(x,<number>)
41
+ or
42
+ sub(x,<variable>)
43
+ ```
44
+
45
+ Multiplication:
46
+ ```
47
+ mul(x,<number>)
48
+ or
49
+ mul(x,<variable>)
50
+ ```
51
+
52
+ Modulo:
53
+ ```
54
+ mod(x,<number>)
55
+ or
56
+ mod(x,<variable>)
57
+ ```
58
+
59
+ While loop:
60
+ ```text
61
+ while(<variable or number>)
62
+ CODE
63
+ endwhile
64
+ ```
65
+
66
+ I/O:
67
+ ```text
68
+ <variable>=in # Reads <variable> as decimal integer
69
+ <variable>=inc # Reads <variable> as ASCII character
70
+ out(<variable or number>) # Outputs <variable> as decimal integer
71
+ outc(<variable or number>) # Outputs <variable> as ASCII character
72
+ ```
73
+
74
+ String output shortcut:
75
+ ```text
76
+ print(STRING) # Without quotes
77
+ # For instance
78
+ print(Hello World!)
79
+ ```
80
+
81
+ If statement:
82
+ ```text
83
+ if(<variable or number>)
84
+ CODE
85
+ endif
86
+
87
+ if(<variable or number>)
88
+ CODE1
89
+ else
90
+ CODE2
91
+ endif
92
+ ```
93
+
94
+ Comparison:
95
+ ```text
96
+ lt(x,<number>) # Compares x and the variable or number, if x is less than the variable or number, set x to 1, otherwise 0
97
+ or
98
+ lt(x,<variable>)
99
+
100
+ eq(x,<number>) # Compares x and the variable or number, if x is equal to the variable or number, set x to 1, otherwise 0
101
+ or
102
+ eq(x,<variable>)
103
+ ```
104
+
105
+ Macros:
106
+ ```text
107
+ macro $<name> # Macro with no arguments
108
+ CODE
109
+ endmacro
110
+
111
+ macro $<name>(<arg1>,<arg2>,...) # Macro with arguments
112
+ CODE
113
+ endmacro
114
+
115
+ $<name> # Using a macro with no arguments
116
+ $<name>(<arg1>,<arg2>,...) # Using a macro with arguments
117
+ ```
118
+
119
+ Memory:
120
+ ```text
121
+ ptr(a,b) # Store address of a to variable b
122
+ ref(a,b) # Store value of address b to variable a
123
+ set(a,b) # Set value of address b to a (variable or integer literal)
124
+ ```
125
+
126
+ Libraries
127
+ ```text
128
+ ?libraryname
129
+ ```
130
+ Includes the library `library name` (with file extension).
131
+
132
+ It first searches the library in current directory, and then in the `stdlib` directory in the package.
133
+
134
+ There are standard libraries for BFFuck, they are:
135
+ * `env.bff` gets size of a "byte" specified by the compiler
136
+ * `alloc.bff` allocates memory
137
+ * `array.bff` manages memory using arrays
138
+ * `rng.bff` a not very decent random number generator
139
+
140
+ An example of the `rng.bff` library is here:
141
+ ```text
142
+ ?rng.bff
143
+ x=0
144
+ while(1)
145
+ $rnd(x)
146
+ outc(x)
147
+ endwhile
148
+ ```
149
+ Prints random bytes.
150
+ ### Platform
151
+ BFFuck is in **pure Python** and therefore it supports any platform.
152
+
153
+ ### Constraints
154
+ Programs compiled from BFFuck needs you to have 8 bit cells that wrap.
155
+
156
+ ### Disadvantages
157
+ BFFuck currently has these disadvantages:
158
+ 1. <s>It's numbers are 8 bit numbers.</s> You can choose 8-bit, 16-bit or 32-bit numbers using the `byte` keyword argument. But you need to run it on a 8-bit interpreter. <font color="red">REMEMBER: Using numbers with more bits is slower and increases the size of program largely! If you're using 32 bit, remember to use an extremely optimizing interpreter like bffsree!</font>
159
+ 2. It has some bugs.
160
+
161
+
162
+ The repository contains some examples, including a Hello World program, a cat program and an A+B program.
@@ -0,0 +1,42 @@
1
+ from .bffuck import BFFuck
2
+ import argparse, sys
3
+
4
+
5
+ def _cli():
6
+ ap = argparse.ArgumentParser(
7
+ description="BFFuck CLI tool\nMakes Brainfucking Easier!\nEnjoy brainfucking with the tool\nIf you encounter any error, you can post an issue at GitHub."
8
+ )
9
+ ap.add_argument("program", help="BFFuck program file name")
10
+ ap.add_argument(
11
+ "--playfield", "-p", help="Number of bytes for playfield, must be an integer"
12
+ )
13
+ ap.add_argument(
14
+ "--output",
15
+ "-o",
16
+ help="Output brainfuck file name, default is the standard output",
17
+ )
18
+ ap.add_argument("--byte", "-b", help="Use multi-byte integers (1 or 2 or 3 bytes)")
19
+ a = ap.parse_args()
20
+ program = a.program
21
+ with open(program, "r") as f:
22
+ code = f.read()
23
+ playfield = 15
24
+ if a.playfield:
25
+ playfield = int(a.playfield)
26
+ if a.byte:
27
+ byte = int(a.byte)
28
+ try:
29
+ bf = BFFuck(playfield).compile(code, byte=int(a.byte))
30
+ except Exception as err:
31
+ print("Compilation error: %s" % str(err))
32
+ sys.exit(1)
33
+ else:
34
+ file = sys.stdout
35
+ if a.output:
36
+ file = open(a.output, "w")
37
+ print(bf, file=file)
38
+
39
+
40
+ if __name__ == "__main__":
41
+ _cli()
42
+