(Arne Babenhauserheide)
2013-08-25: wisp-guile.w no longer dies too badly, and found a bug in wisp.py wisp-guile.w no longer dies too badly, and found a bug in wisp.py
diff --git a/.bugs/bugs b/.bugs/bugs --- a/.bugs/bugs +++ b/.bugs/bugs @@ -6,4 +6,5 @@ wisp-guile.w does not yet remove the lea inline ' : should be '( | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:72d534a8b23b4cb168017f1bb7d8816f0ea170c4, time:1366497335.26 wisp-mode: handle lines starting with underscores: currently sees the underscores as function call. | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:b2c3755e1deb8355655a334d569679e2e62d2836, time:1376612093.55 make this work: let : : origfile ( open-file : nth 1 : command-line ) r | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:d6de2074a5017f1f29f34d142ce797981ed270a0, time:1366529287.67 +wisp.py breaks on \ - quote, escaped backslash, quote | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:d75a93ca58ade5b3e3e51f1e7ee9782e743ac131, time:1377424552.02 comments containing a closing parenthesis can break the parser. | owner:, open:False, id:d9147504868960e5fbc2648474d48ce5c9bd1a02, time:1374838747.22 diff --git a/wisp-guile.w b/wisp-guile.w --- a/wisp-guile.w +++ b/wisp-guile.w @@ -24,11 +24,16 @@ define : nostringandbracketbreaks inport incharform 0 ; #\<something> while : not : eof-object? nextchar ; incommentfirstchar is only valid for exactly one char - when incommentfirstchar : set! incommentfirstchar #f + when incommentfirstchar : set! incommentfirstchar #f ; already started char forms win over everything, so process them first. ; already started means: after the #\ + ; FIXME: Fails to capture #t and #f which can kill line splitting if it happens inside brackets + when : = incharform 1 + when : not : char=? #\" nextchar + set! incharform 0 + when : >= incharform 2 - if : char=? nextchar #\space + if : or (char=? nextchar #\space) (char=? nextchar #\linefeed ) (char=? nextchar #\newline ) set! incharform 0 ; else set! incharform : + incharform 1 @@ -40,7 +45,11 @@ define : nostringandbracketbreaks inport . instring ; when I’m in a string, I can get out char=? lastchar #\space ; when the last char was a space, I can get into a string char=? lastchar #\linefeed ; same for newline chars - char=? lastchar #\newline + char=? lastchar #\newline + and : not instring ; outside of strings, brackets are pseudo-whitespace, too + or + char=? lastchar #\( + char=? lastchar #\) not incomment < incharform 1 set! instring : not instring @@ -77,7 +86,7 @@ define : nostringandbracketbreaks inport char=? lastchar #\# char=? nextchar #\\ set! incharform 2 - + ; check for brackets when : and ( char=? nextchar #\( ) ( not instring ) ( not incomment ) ( = incharform 0 ) set! inbrackets : + inbrackets 1 @@ -466,12 +475,12 @@ let* ; line-functions for details. textlines : split-wisp-lines text lines : linestoindented textlines - lisp : wisp2lisp lines + ; lisp : wisp2lisp lines display : length textlines newline display : length lines newline - display : length lisp + ; display : length lisp newline ; display : list-ref lines 100 ; seems good let show : (processed '()) (unprocessed lines) diff --git a/wisp.py b/wisp.py --- a/wisp.py +++ b/wisp.py @@ -27,7 +27,6 @@ Currently it is written in Python, becau but crave the power of lisp. """ - def replaceinwisp(code, string, replacement): """Replace the given string with the replacement, but only in indentation sensitive parts of the code. @@ -56,7 +55,8 @@ def replaceinwisp(code, string, replacem incomment = not incomment # all processing stops in comments continue - if i == '"' and not code[n-1:n] == "\\": + # FIXME: This still breaks at "\\" + if i == '"' and (not code[n-1:n] == "\\" or (code[n-2:n] == "\\\\" and not code[n-3:n] == "\\\\\\")): instring = not instring # all processing stops in strings if instring: