Run the format tool.

This commit is contained in:
Danila Fedorin 2018-07-25 13:53:35 -07:00
parent fa00bda8ab
commit df2a00fd66
7 changed files with 570 additions and 551 deletions

View File

@ -1,10 +1,10 @@
require "./builder.cr"
module Chalk
abstract class BasicParser(T)
abstract def parse?(tokens : Array(Token),
index : Int64) : Tuple(T, Int64)?
def parse(tokens : Array(Token),
index : Int64) : Tuple(T, Int64)
return parse?(tokens, index).not_nil!
@ -15,9 +15,7 @@ module Chalk
end
def then(other : BasicParser(R)) : BasicParser(Array(T | R)) forall R
return NextParser
.new(self, other)
.as(BasicParser(Array(T | R)))
return NextParser.new(self, other).as(BasicParser(Array(T | R)))
end
end

View File

@ -16,19 +16,25 @@ module Chalk
class TreeId < Tree
property id : String
def initialize(@id : String) end
def initialize(@id : String)
end
end
class TreeLit < Tree
property lit : Int64
def initialize(@lit : Int64) end
def initialize(@lit : Int64)
end
end
class TreeCall < Tree
property name : String
property params : Array(Tree)
def initialize(@name : String, @params : Array(Tree)) end
def initialize(@name : String, @params : Array(Tree))
end
def accept(v : Visitor)
v.visit(self)
@params.each &.accept(v)
@ -40,7 +46,9 @@ module Chalk
property op : TokenType
property left : Tree
property right : Tree
def initialize(@op : TokenType, @left : Tree, @right : Tree) end
def initialize(@op : TokenType, @left : Tree, @right : Tree)
end
def accept(v : Visitor)
v.visit(self)
@ -51,7 +59,8 @@ module Chalk
end
class TreeBlock < Tree
def initialize(@children : Array(Tree)) end
def initialize(@children : Array(Tree))
end
def accept(v : Visitor)
v.visit(self)
@ -65,7 +74,9 @@ module Chalk
property params : Array(String)
property block : Tree
def initialize(@name : String, @params : Array(String), @block : Tree) end
def initialize(@name : String, @params : Array(String), @block : Tree)
end
def accept(v : Visitor)
v.visit(self)
@block.accept(v)
@ -77,7 +88,9 @@ module Chalk
property name : String
property expr : Tree
def initialize(@name : String, @expr : Tree) end
def initialize(@name : String, @expr : Tree)
end
def accept(v : Visitor)
v.visit(self)
@expr.accept(v)
@ -89,7 +102,9 @@ module Chalk
property name : String
property expr : Tree
def initialize(@name : String, @expr : Tree) end
def initialize(@name : String, @expr : Tree)
end
def accept(v : Visitor)
v.visit(self)
@expr.accept(v)
@ -102,7 +117,9 @@ module Chalk
property block : Tree
property otherwise : Tree?
def initialize(@condition : Tree, @block : Tree, @otherwise : Tree? = nil) end
def initialize(@condition : Tree, @block : Tree, @otherwise : Tree? = nil)
end
def accept(v : Visitor)
v.visit(self)
@condition.accept(v)
@ -116,7 +133,9 @@ module Chalk
property condition : Tree
property block : Tree
def initialize(@condition : Tree, @block : Tree) end
def initialize(@condition : Tree, @block : Tree)
end
def accept(v : Visitor)
v.visit(self)
@condition.accept(v)
@ -128,7 +147,9 @@ module Chalk
class TreeReturn < Tree
property rvalue : Tree
def initialize(@rvalue : Tree) end
def initialize(@rvalue : Tree)
end
def accept(v : Visitor)
v.visit(self)
@rvalue.accept(v)