Project

Profile

Help

Revision 457ab841

Added by Vincent Le Goff over 4 years ago

Now handle semi-colons in SharpScript

View differences:

src/sharp/engine.py
111 111
                argument = "compile(" + argument + ", 'SharpScript', 'exec')"
112 112
            elif argument.startswith("{"):
113 113
                argument = repr(argument[1:-1])
114
                argument = self.replace_semicolons(argument)
114 115
            elif argument[0] in "-+":
115 116
                kwargs[argument[1:]] = True if argument[0] == "+" else False
116 117
                continue
117 118
            else:
118 119
                argument = repr(argument)
120
                argument = self.replace_semicolons(argument)
119 121

  
120 122
            arguments.append(argument)
121 123

  
......
214 216
            i += 1
215 217

  
216 218
        return None
219

  
220
    @staticmethod
221
    def replace_semicolons(text):
222
        """Replace all not-escaped semi-colons."""
223
        i = 0
224
        while i < len(text):
225
            remaining = text[i:]
226
            if remaining.startswith(";;"):
227
                i += 2
228
                continue
229
            elif remaining.startswith(";"):
230
                text = text[:i] + "\n" + text[i + 1:]
231
            i += 1
232

  
233
        return text.replace(";;", ";")

Also available in: Unified diff