Skip to content

Commit

Permalink
An ellipsis (...) can only be placed at the beginning
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Oct 29, 2020
1 parent 9f3adaf commit bf951c7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tool/ruby_vm/loaders/insns_def.rb
Expand Up @@ -25,10 +25,10 @@
(?<ws> \g<comment> | \s ){0}
(?<ident> [_a-zA-Z] [0-9_a-zA-Z]* ){0}
(?<type> (?: \g<keyword> \g<ws>+ )* \g<ident> ){0}
(?<arg> \g<type> \g<ws>+ \g<ident> | \.\.\. ){0}
(?<arg> \g<type> \g<ws>+ \g<ident> ){0}
(?<argv> (?# empty ) |
void |
\g<arg> (?: \g<ws>* , \g<ws>* \g<arg> \g<ws>* )* ){0}
(?: \.\.\. | \g<arg>) (?: \g<ws>* , \g<ws>* \g<arg> \g<ws>* )* ){0}
(?<pragma> \g<ws>* // \s* attr \g<ws>+
(?<pragma:type> \g<type> ) \g<ws>+
(?<pragma:name> \g<ident> ) \g<ws>*
Expand Down Expand Up @@ -57,6 +57,10 @@
ope = split.(scanner["insn:opes"])
pop = split.(scanner["insn:pops"])
ret = split.(scanner["insn:rets"])
if ope.include?("...")
raise sprintf("parse error at %s:%d:%s: operands cannot be variadic",
scanner.__FILE__, scanner.__LINE__, name)
end

attrs = []
while l2 = scanner.scan(/\G#{grammar}\g<pragma>/o) do
Expand Down

0 comments on commit bf951c7

Please sign in to comment.