Skip to content

Commit

Permalink
fixing comment detection bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
dekuNukem committed Mar 31, 2024
1 parent 2622866 commit 5abb857
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 15 deletions.
30 changes: 24 additions & 6 deletions pc_software/ds3_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,27 @@ def split_str_cmd(cmd_type, this_line):
return cmd_list

def run_all(program_listing):

# a bit preprocessing
new_program_listing = []
for index, this_line in enumerate(program_listing):

# remove leading space and tabs
this_line = this_line.lstrip(" ").lstrip("\t")
first_word = this_line.split(" ")[0]

# remove single-line comments
if first_word == cmd_REM or first_word.startswith(cmd_C_COMMENT):
continue

# remove cmd_INJECT_MOD
if first_word == cmd_INJECT_MOD:
this_line = this_line.replace(cmd_INJECT_MOD, "", 1)

this_line = this_line.lstrip(" ").lstrip("\t")
new_program_listing.append(this_line)
program_listing = new_program_listing

# ----------- expand MOUSE_MOVE ----------
new_program_listing = []
for index, this_line in enumerate(program_listing):
Expand All @@ -801,12 +822,9 @@ def run_all(program_listing):

program_listing = new_program_listing

# ----------- remove cmd_INJECT_MOD ----------

for index, this_line in enumerate(program_listing):
first_word = this_line.split(" ")[0]
if first_word == cmd_INJECT_MOD:
program_listing[index] = this_line.replace(cmd_INJECT_MOD, "", 1)
print("preprocessed lines:")
for item in program_listing:
print(item)

# ----------- Do a pass ---------------

Expand Down
Binary file modified pc_software/duckypad_config_latest_source.zip
Binary file not shown.
32 changes: 23 additions & 9 deletions pc_software/sample_script.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
DEFINE TEN 10
VAR $spam = TEN*7+3
FUNCTION wait_keypress()
VAR $k = 0
WHILE $k == 0
$k = $_READKEY
DELAY 50
END_WHILE
END_FUNCTION

DEFAULTDELAY 30
OLED_CLEAR
OLED_CURSOR 0 0
OLED_PRINT READY
OLED_UPDATE

STRINGLN_BLOCK
VAR $row = 1
VAR $col = 1
INJECT_MOD ALT
WHILE $row <= 5
WHILE $col <= 4
// wait_keypress()
STRINGLN WTFSW_R$rowC$col
$col = $col + 1
END_WHILE
$row = $row + 1
END_WHILE

I'd just like to interject for a moment. What you're refering to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called Linux, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project. There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux!
OLED_RESTORE

hello world!

END_STRINGLN

DELAY $spam

1 comment on commit 5abb857

@jeanstack
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.