class Gettext::PluralForm::Parser
- Gettext::PluralForm::Parser
- Reference
- Object
Overview
Parser for generating plural-form expression ASTs out of an array of tokens
Based on this parser from crafting interpreters
Defined in:
backend/gettext/plural-forms/parser.crConstructors
-
.new(tokens)
Creates a new parser instance with the array of tokens from the
PluralForm::Scanner
as input.
Instance Method Summary
-
#parse
Parse an array of tokens into abstract syntax trees that represents a plural-form expression (C)
Constructor Detail
def self.new(tokens)
#
Creates a new parser instance with the array of tokens from the PluralForm::Scanner
as input.
plural_form_scanner = Gettext::PluralForm::Scanner.new("nplurals=2; plural=(n > 1);")
tokens = plural_form_scanner.scan
plural_form_parser = Gettext::PluralForm::Parser.new(tokens)
Instance Method Detail
def parse
#
Parse an array of tokens into abstract syntax trees that represents a plural-form expression (C)
plural_form_scanner = Gettext::PluralForm::Scanner.new("nplurals=2; plural=(n > 1);")
tokens = plural_form_scanner.scan
plural_form_parser = Gettext::PluralForm::Parser.new(tokens)
plural_form_parser.parse # => Array(Expressions)