Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum Expr{
- case Literal{
- case Int(value:bigint);
- case String(value:bytearray);
- var type: *Type;
- }
- case BinOp(op:Token, lhs: *Expr, rhs: *Expr);
- case UnOp(op:Token, arg: *Expr);
- var loc: SourceLocation;
- var meta: *MetadataNode;
- }
- void process_expr(e:*Expr){
- switch (e){
- case Literal.String(value):
- print("found some string!" + value.to_utf8() + " at " + e.loc);
- case BinOp(_, lhs, rhs):
- process_expr(lhs);
- process_expr(rhs);
- case UnOp(_, arg) as unop:
- process_expr(arg);
- work_with_unop(unop);
- }
- }
- void work_with_unop(unop:*UnOp){
- if (unop.op == Token.Plus) {
- unop.op = Token.Minus;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement