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

Instance methods inherited from class Lens::Base::Parser(Gettext::PluralForm::Token, Gettext::PluralForm::TokenTypes, Gettext::PluralForm::Scanner)

parse parse

Constructor methods inherited from class Lens::Base::Parser(Gettext::PluralForm::Token, Gettext::PluralForm::TokenTypes, Gettext::PluralForm::Scanner)

new(source : String) new

Constructor Detail

def self.new(source : String) #

Creates a new parser instance from the given array of 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]