I think you just need to remove the parentheses from the root rule.
Also, for the decimal rule you should probably use a +
instead of a *
after the decimal; you'll want at least one number there.
grammar Numerals
rule percentage
decimal "%" {
def to_f
decimal.to_f / 100
end
}
end
rule decimal
sign [0-9]+ '.' [0-9]+ {
def to_f
text_value.to_f
end
}
end
rule sign
('+'/'-')?
end
end