lib/parser.rb
# Public: Parses a set of Lisp tokens (see #tokenize)
#
# tokens - the array of Lisp tokens to parse
# tree - the AST that will be eventually returned (used for recuring)
#
# Examples
#
#   tokens = parser.tokenize('(define woot (* 3 2))')
#   parser.parse(tokens)
#   # => [ 'define', 'woot', ['*', '3', '2'] ]
#
# Returns the tokens as a parse tree according to the above specification
Parses a set of Lisp tokens
tokens - the array of Lisp tokens to parse
tree - the AST that will be eventually returned (used for recuring)

Examples



Returns the tokens as a parse tree according to the above specification
Parses a set of Lisp tokens tokens - the array of Lisp tokens to parse tree - the AST that will be eventually returned ( used for recuring ) Examples Returns the tokens as a parse tree according to the above specification
def parse(tokens, tree=[])
    token = tokens.shift
    case token
      when "("; parse_block(tokens, tree)
      else; parse_token(token)
    end
  end
def parse ( tokens , tree = [ ] ) token = tokens . shift case token when "(" ; parse_block ( tokens , tree ) else ; parse_token ( token ) end end
Public: Parses a set of Lisp tokens (see #tokenize)
tokens - the array of Lisp tokens to parse
tree - the AST that will be eventually returned (used for recuring)
Public : Parses a set of Lisp tokens ( see #tokenize ) tokens - the array of Lisp tokens to parse tree - the AST that will be eventually returned ( used for recuring )
tokens
<not_specific>
tree
<not_specific>