Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add one_expression parser rule

  • Loading branch information...
commit 7803cdccba4485b329372e99c843efc5848ca608 1 parent 15e092c
@vito authored
View
1  lib/atomy/atomy.kpeg
@@ -84,6 +84,7 @@
delim(c) = (wsp "," wsp) | (sp "\n" sp)+ &{ current_column >= c }
expression = level4
+ one_expression = wsp expression:e wsp !. { e }
expressions = { current_column }:c expression:x (delim(c) expression)*:xs delim(c)?
{ [x] + Array(xs) }
View
42 lib/atomy/atomy.kpeg.rb
@@ -1107,6 +1107,47 @@ def _expression
return _tmp
end
+ # one_expression = wsp expression:e wsp !. { e }
+ def _one_expression
+
+ _save = self.pos
+ while true # sequence
+ _tmp = apply(:_wsp)
+ unless _tmp
+ self.pos = _save
+ break
+ end
+ _tmp = apply(:_expression)
+ e = @result
+ unless _tmp
+ self.pos = _save
+ break
+ end
+ _tmp = apply(:_wsp)
+ unless _tmp
+ self.pos = _save
+ break
+ end
+ _save1 = self.pos
+ _tmp = get_byte
+ _tmp = _tmp ? nil : true
+ self.pos = _save1
+ unless _tmp
+ self.pos = _save
+ break
+ end
+ @result = begin; e ; end
+ _tmp = true
+ unless _tmp
+ self.pos = _save
+ end
+ break
+ end # end sequence
+
+ set_failed_rule :_one_expression unless _tmp
+ return _tmp
+ end
+
# expressions = { current_column }:c expression:x (delim(c) expression)*:xs delim(c)? { [x] + Array(xs) }
def _expressions
@@ -3949,6 +3990,7 @@ def _root
Rules[:_in_multi] = rule_info("in_multi", "(/[^\\-\\{\\}]*/ \"-}\" | /[^\\-\\{\\}]*/ \"{-\" in_multi /[^\\-\\{\\}]*/ \"-}\" | /[^\\-\\{\\}]*/ /[-{}]/ in_multi)")
Rules[:_delim] = rule_info("delim", "(wsp \",\" wsp | (sp \"\\n\" sp)+ &{ current_column >= c })")
Rules[:_expression] = rule_info("expression", "level4")
+ Rules[:_one_expression] = rule_info("one_expression", "wsp expression:e wsp !. { e }")
Rules[:_expressions] = rule_info("expressions", "{ current_column }:c expression:x (delim(c) expression)*:xs delim(c)? { [x] + Array(xs) }")
Rules[:_level0] = rule_info("level0", "(number | quote | quasi_quote | splice | unquote | string | constant | word | block | list | prefix)")
Rules[:_level1] = rule_info("level1", "(call | grouped | level0)")
View
2  lib/atomy/parser.rb
@@ -6,7 +6,7 @@ module Atomy
class Parser
def self.parse_node(source)
p = new(source)
- p.raise_error unless p.parse("expression")
+ p.raise_error unless p.parse("one_expression")
p.result
end
Please sign in to comment.
Something went wrong with that request. Please try again.