This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "container/vector" | |
type fsa_s struct { | |
states []StringVector | |
cur_state []StringVector | |
} | |
func initFsa(states *StringVector, alphabet *StringVector) { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import vector "container/vector" | |
import "fmt" | |
type Fsa struct { | |
States *vector.StringVector | |
Alpha *vector.StringVector | |
Current string | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ---------------------------------------------------------------------- | |
# phplex.py | |
# | |
# A lexer for PHP. | |
# ---------------------------------------------------------------------- | |
import ply.lex as lex | |
# todo: literal html | |
# todo: double-quoted strings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ply import lex | |
t_ignore = ' \t' | |
reserved = {'Theorem': 'THEOREM', | |
'Goal': 'GOAL', | |
'Proof': 'PROOF', | |
'Prop': 'PROP', | |
'forall': 'FORALL', | |
'exists': 'EXISTS', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ply import lex | |
t_ignore = ' \t' | |
reserved = {'Theorem': 'THEOREM', | |
'Goal': 'GOAL', | |
'Proof': 'PROOF', | |
'Prop': 'PROP', | |
'forall': 'FORALL', | |
'exists': 'EXISTS', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ast | |
node = ast.Expression(ast.BinOp(left=ast.Num(5, lineno=0, col_offset=0), | |
op=ast.Add(), | |
right=ast.Num(2, lineno=0, col_offset=0), | |
lineno=0, | |
col_offset=0), | |
lineno=0, | |
col_offset=0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ast | |
from phpparse import parser | |
input = '<?php echo "hello, world!"; ?>' | |
output = parser.parse(input) | |
map = {'Echo': ast.Print} | |
node_type, args = output[0].generic() | |
op = map[node_type](values=[ast.Str(args['nodes'].pop(), lineno=0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZOMG WOMBAT! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import takewhile | |
from math import sqrt | |
class Fib(object): | |
def __init__(self): | |
self.i = 2 | |
self.items = [0, 1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ctypes import * | |
class Node(Structure): | |
pass | |
Node._fields_ = [("next", POINTER(Node)), | |
("foo", c_int)] | |
OlderNewer