lib/antelope/ace/scanner/second.rb in antelope-0.1.0 vs lib/antelope/ace/scanner/second.rb in antelope-0.1.1

- old
+ new

@@ -41,11 +41,11 @@ # @return [Boolean] if it matched # @see #scan_second_rule_label # @see #scan_second_rule_body # @see #error! def scan_second_rule - if @scanner.check(/([a-z]+):/) + if @scanner.check(/([a-z._-]+):/) scan_second_rule_label or error! scan_second_rule_body true end end @@ -53,11 +53,11 @@ # Scans the label for a rule. It should contain only lower # case letters and a colon. # # @return [Boolean] if it matched. def scan_second_rule_label - if @scanner.scan(/([a-z]+): ?/) + if @scanner.scan(/([a-z._-]+): ?/) tokens << [:label, @scanner[1]] end end # The body can contain parts, ors, precs, or blocks (or @@ -84,11 +84,11 @@ # alphabetical characters that are not followed by a # colon. # # @return [Boolean] if it matched. def scan_second_rule_part - if @scanner.scan(/([A-Za-z]+)(?!\:)/) + if @scanner.scan(/([A-Za-z._-]+)(?!\:)/) tokens << [:part, @scanner[1]] end end # Attempts to scan an "or". It's just a vertical bar. @@ -103,10 +103,10 @@ # Attempts to scan a precedence definition. A precedence # definition is "%prec " followed by a terminal or nonterminal. # # @return [Boolean] if it matched. def scan_second_rule_prec - if @scanner.scan(/%prec ([A-Za-z]+)/) + if @scanner.scan(/%prec ([A-Za-z._-]+)/) tokens << [:prec, @scanner[1]] end end # Attempts to scan a block. This correctly balances brackets;