Skip to content

Carriage return in constant throws off scanner #6

Description

@danmcmahill

the carriage return in this LAP file throws off the scanner.

    262     constant  define-key
    263     varref    map
    264     constant  "^M"
    267     constant  il-electric-return
    270     call      3
    271     discard

This seems to fix that but probably isn't so DOS friendly:

diff --git a/lapdecompile/main.py b/lapdecompile/main.py
index de0cd58..a4c029a 100755
--- a/lapdecompile/main.py
+++ b/lapdecompile/main.py
@@ -54,7 +54,7 @@ def control_flow(name, instructions, show_assembly, write_cfg):
 
 def deparse(path, outstream, show_assembly, write_cfg, show_grammar, show_tree):
     # Scan...
-    with open(path, "r") as fp:
+    with open(path, "r", newline="\n") as fp:
         scanner = LapScanner(fp, show_assembly=show_assembly)
         pass

a similar change would go at the very bottom of scanner.py

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions