Skip to content

Instantly share code, notes, and snippets.

@xiez
xiez / s-exp.py
Created November 1, 2022 08:44
s-expression parsing
# lisp expression LL(1) grammar:
# expr -> "(" operator operands ")"
# operator -> "string"|expr
# operands -> operand*
# operand -> "int"|"float"|"string"|expr
#################### lexical analyzer
def tokenize(lines):
print(f'lexical analyze lines: {lines}')
def _tokenize(line):
import time
import urllib2
import json
import oauth2
url1 = "https://api.twitter.com/1.1/search/tweets.json"
params = {
"oauth_version": "1.0",
"oauth_nonce": oauth2.generate_nonce(),
"oauth_timestamp": int(time.time())
}