40: def tokens
41: @sql.scan(%r{
42: (
43: -- .* (?# matches "--" style comments to the end of line or string )
44: | - (?# matches single "-" )
45: |
46: /[*] .*? [*]/ (?# matches C-style comments )
47: | / (?# matches single slash )
48: |
49: ' ( [^'\\] | '' | \\. )* ' (?# match strings surrounded by apostophes )
50: |
51: " ( [^"\\] | "" | \\. )* " (?# match strings surrounded by " )
52: |
53: \?\?? (?# match one or two question marks )
54: |
55: [^-/'"?]+ (?# match all characters except ' " ? - and / )
56:
57: )}x).collect {|t| t.first}
58: end