Skip to content

A CLI tool and library intended to dynamically parse C++ style ternary, mathematical, and boolean expressions used for Gettext Plural-Forms header.

License

Notifications You must be signed in to change notification settings

taylor-s-dean/plurals-parser-boost

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C/C++ CI

plurals-parser

A CLI tool and library intended to dynamically parse C++ style ternary, mathematical, and boolean expressions used for Gettext Plural-Forms header.

Building

git clone https://github.com/taylor-s-dean/plurals-parser-boost.git
cd plurals-parser-bison
make

Usage

$ plurals-parser --help
plurals-parser is a CLI tool that computes the result of a Gettext plural-forms ternary.
Usage: ./plurals-parser [OPTIONS] [SUBCOMMAND]

Options:
  -h,--help                   Print this help message and exit

Subcommands:
  eval                        Evaluate a plural-forms ternary.
  test                        Run test suite.
$ plurals-parser eval --help
Evaluate a plural-forms ternary.
Usage: ./plurals-parser eval [OPTIONS] plural-forms

Positionals:
  plural-forms TEXT REQUIRED  A Gettext plural-forms ternary.

Options:
  -h,--help                   Print this help message and exit
  -n,--n UINT REQUIRED        The value of n.
  -v,--verbose                Be verbose.
$ plurals-parser test --help
Run test suite.
Usage: ./plurals-parser test [OPTIONS]

Options:
  -h,--help                   Print this help message and exit
  -v,--verbose                Be verbose.

Example

$ plurals-parser test --verbose eval "(n % 100 == 1) ? 0 : ((n % 100 == 2) ? 1 : ((n % 100 == 3 || n % 100 == 4) ? 2 : 3))" --n=5 --verbose
All tests passed.
Program:    (((n % 100) == 1) ? 0 : (((n % 100) == 2) ? 1 : ((((n % 100) == 3) || ((n % 100) == 4)) ? 2 : 3)))
Expression: "(n % 100 == 1) ? 0 : ((n % 100 == 2) ? 1 : ((n % 100 == 3 || n % 100 == 4) ? 2 : 3))"
Result: 3
3

About

A CLI tool and library intended to dynamically parse C++ style ternary, mathematical, and boolean expressions used for Gettext Plural-Forms header.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published