grammar Sexp

rule body
  (expression / variable / identifier / string / space)* {
    def value
      elements.delete_if do |e|
        !e.respond_to? :value
      end
      elements.map{|e| e.value}
    end
  }
end

rule expression
  space? '{' body '}' space? {
    def value
      body.elements.delete_if do |e|
        !e.respond_to? :value
      end
      body.elements.map{|e| e.value}
    end
  }
end

rule variable
  '$' identifier {
    def value
      Aster::Variable.new identifier.text_value.to_sym
    end
  }
end

rule identifier
  [^\n|\s|"|\}]+ {
    def value
      text_value
    end
  }
end

rule string
  '"' ([^"\\] / "\\" . )* '"' {
    def value
      text_value
    end
  }
end

rule space
  [\s]+ 
end

end