Skip to content

Instantly share code, notes, and snippets.

@FerrielMelarpis
Created March 29, 2016 15:08
Show Gist options
  • Select an option

  • Save FerrielMelarpis/5d45ccf33e8f6eb2eeda to your computer and use it in GitHub Desktop.

Select an option

Save FerrielMelarpis/5d45ccf33e8f6eb2eeda to your computer and use it in GitHub Desktop.
def analyze(code):
tokenizer = _lexemes.scanner(code)
tokenpairs = []
while 1:
token = tokenizer.match()
if not token:
break
tokenpairs.append(tuple([token.group(token.lastindex), _tokendesc[token.lastindex - 1]]))
return tokenpairs
if __name__ == "__main__":
code = "SELECT col_1, COUNT(col_2) FROM tb_1 WHERE col_1 = col_2"
tokens = analyze(code)
for t in tokens:
print t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment