FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    number_expression

    module · ferroui-controls · v0.5.0

    module number_expression
    

    The arithmetic expressions of WinUI's NumberBox (NumberBoxParser, controls/dev/NumberBox/NumberBoxParser.cpp of microsoft-ui-xaml, commit 7e4b0c2096be402f51cc8f7d203ebf67cff183d0; MIT, Copyright (c) Microsoft Corporation, see NOTICE.md), shared by the number editors of the crate: NumberBox evaluates them with f64, and the evaluator is generic over the number type so that an editor of Decimal values evaluates them exactly.

    The grammar is WinUI's: numbers, the binary operators +, -, *, / and ^, and parentheses. ^ binds tighter than * and /, which bind tighter than + and -, and every operator, ^ included, associates from left to right (2 ^ 3 ^ 2 is 64). A number is the longest run of characters that are not operators, parentheses or white space, optionally after a minus sign, and the caller's parser reads it (the number formatter of the editor); a minus sign before a parenthesis is not part of the grammar. Spaces separate tokens; other white space is an error.

    Deviation (docs/porting/winui-controls.md, Input): WinUI's parser has no bounds and returns null for every error; this one rejects an input longer than 64 KiB or with more than 4096 tokens, never recurses, and reports what is wrong and where.

    View source

    Contents

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.