lib/smurf/javascript.rb
def action(a)
      if(a==1)
        @output.write @theA
      end
      if(a==1 || a==2)
        @theA = @theB
        if (@theA == "\'" || @theA == "\"")
          while (true)
            @output.write @theA
            @theA = get
            break if (@theA == @theB)

            # raise "Unterminated string literal"
            debugger if (@theA <= "\n")
            if (@theA == "\\")
              # allow multi-line strings if each line is terminated by \\n (or \\r\n)
              if ["\r", "\n"].include? peek
                get # throw away the line ending
                get if ["\r", "\n"].include? peek
              else
                @output.write @theA
              end
              @theA = get
            end
          end
        end
      end
      if(a==1 || a==2 || a==3)
        @theB = mynext
        if (@theB == "/" && (@theA == "(" || @theA == "," || @theA == "=" ||
                             @theA == ":" || @theA == "[" || @theA == "!" ||
                             @theA == "&" || @theA == "|" || @theA == "?" ||
                             @theA == "{" || @theA == "}" || @theA == ";" ||
                             @theA == "\n"))

          @output.write(@theA) unless peek(2) == '@'
          @output.write @theB
          while (true)
            @theA = get
            if (@theA == "/")
              break
            elsif (@theA == "\\")
              @output.write @theA
              @theA = get
            elsif (@theA <= "\n")
              raise "Unterminated RegExp Literal"
            end
            @output.write @theA
          end
          @theB = mynext
        end
      end
    end
def action(a)
      if(a==1)
        @output.write @theA
      end
      if(a==1 || a==2)
        @theA = @theB
        if (@theA == "\'" || @theA == "\"")
          while (true)
            @output.write @theA
            @theA = get
            break if (@theA == @theB)

            # raise "Unterminated string literal"
            debugger if (@theA <= "\n")
            if (@theA == "\\")
              # allow multi-line strings if each line is terminated by \\n (or \\r\n)
              if ["\r", "\n"].include? peek
                get # throw away the line ending
                get if ["\r", "\n"].include? peek
              else
                @output.write @theA
              end
              @theA = get
            end
          end
        end
      end
      if(a==1 || a==2 || a==3)
        @theB = mynext
        if (@theB == "/" && (@theA == "(" || @theA == "," || @theA == "=" ||
                             @theA == ":" || @theA == "[" || @theA == "!" ||
                             @theA == "&" || @theA == "|" || @theA == "?" ||
                             @theA == "{" || @theA == "}" || @theA == ";" ||
                             @theA == "\n"))

          @output.write(@theA) unless peek(2) == '@'
          @output.write @theB
          while (true)
            @theA = get
            if (@theA == "/")
              break
            elsif (@theA == "\\")
              @output.write @theA
              @theA = get
            elsif (@theA <= "\n")
              raise "Unterminated RegExp Literal"
            end
            @output.write @theA
          end
          @theB = mynext
        end
      end
    end
def action ( a ) if ( a == 1 ) @output . write @theA end if ( a == 1 || a == 2 ) @theA = @theB if ( @theA == "\'" || @theA == "\"" ) while ( true ) @output . write @theA @theA = get break if ( @theA == @theB ) # raise "Unterminated string literal" debugger if ( @theA <= "\n" ) if ( @theA == "\\" ) # allow multi-line strings if each line is terminated by \\n (or \\r\n) if [ "\r" , "\n" ] . include? peek get # throw away the line ending get if [ "\r" , "\n" ] . include? peek else @output . write @theA end @theA = get end end end end if ( a == 1 || a == 2 || a == 3 ) @theB = mynext if ( @theB == "/" && ( @theA == "(" || @theA == "," || @theA == "=" || @theA == ":" || @theA == "[" || @theA == "!" || @theA == "&" || @theA == "|" || @theA == "?" || @theA == "{" || @theA == "}" || @theA == ";" || @theA == "\n" ) ) @output . write ( @theA ) unless peek ( 2 ) == '@' @output . write @theB while ( true ) @theA = get if ( @theA == "/" ) break elsif ( @theA == "\\" ) @output . write @theA @theA = get elsif ( @theA <= "\n" ) raise "Unterminated RegExp Literal" end @output . write @theA end @theB = mynext end end end
action -- do something! What you do is determined by the argument: 1
 Output A. Copy B to A. Get the next B. 2 Copy B to A. Get the next B.
 (Delete A). 3 Get the next B. (Delete B). action treats a string as a
 single character. Wow! action recognizes a regular expression if it is
 preceded by ( or , or =.
action -- do something! What you do is determined by the argument : 1 Output A . Copy B to A . Get the next B . 2 Copy B to A . Get the next B . ( Delete A ) . 3 Get the next B . ( Delete B ) . action treats a string as a single character . Wow! action recognizes a regular expression if it is preceded by ( or or = .