class Gettext::PluralForm::Parser

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.cr

Constructors

Instance Method Summary

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)

[View source]

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)

[View source]