def fibo(n): in n <= 2: return 1 else: return fibo(n-1)+fibo(n-2) print fibo(20) [/python] [python] chart = {} def memofibo(n): if n in chart: return chart[n] elif n <= 2: chart[n] = 1 print memofibo(24) [/python] [python] def t_javascript(token): r'<script\ type=\"text\/javascript\"\>' token.lexer.code_start = token.lexer.lexpos token.lexer.begin("javascript") def t_javascript_end(token):
def t_javascript(token): r'<script\ type=\"text\/javascript\"\>' token.lexer.code_start = token.lexer.lexpos token.lexer.begin("javascript") def t_javascript_end(token): r'\<\/script\>' token.value = token.lexer.lexdata[token.lexer.code_start: token.lexer.lexpos-9] token.type = 'JAVASCRIPT' token.lexer.lineno += token.value.count('\n') token.lexer.begin.('INITIAL') return token
parthing:構文解析 lexing:字句解析
after regular expression, lexer get token value.