iedc-go/vendor/github.com/xuri/nfp
2023-03-03 03:12:15 +08:00
..
CODE_OF_CONDUCT.md 重新索引 2023-03-03 03:12:15 +08:00
go.mod 重新索引 2023-03-03 03:12:15 +08:00
LICENSE 重新索引 2023-03-03 03:12:15 +08:00
nfp.go 重新索引 2023-03-03 03:12:15 +08:00
PULL_REQUEST_TEMPLATE.md 重新索引 2023-03-03 03:12:15 +08:00
README.md 重新索引 2023-03-03 03:12:15 +08:00
SECURITY.md 重新索引 2023-03-03 03:12:15 +08:00

NFP (Number Format Parser)

Build Status Code Coverage Go Report Card go.dev Licenses

Using NFP (Number Format Parser) you can get an Abstract Syntax Tree (AST) from Excel number format expression.

Installation

go get github.com/xuri/nfp

Example

package main

import "github.com/xuri/nfp"

func main() {
    ps := nfp.NumberFormatParser()
    tokens := ps.Parse("_(* #,##0.00_);_(* (#,##0.00);_(* \"-\"??_);_(@_)")
    println(p.PrettyPrint())
}

Get AST

<Positive>
      <RepeatsChar>
    # <HashPlaceHolder>
    <ThousandsSeparator>
    ## <HashPlaceHolder>
    0 <ZeroPlaceHolder>
    . <DecimalPoint>
    00 <ZeroPlaceHolder>
<Negative>
      <RepeatsChar>
    ( <Literal>
    # <HashPlaceHolder>
    , <ThousandsSeparator>
    ## <HashPlaceHolder>
    0 <ZeroPlaceHolder>
    . <DecimalPoint>
    00 <ZeroPlaceHolder>
    ) <Literal>
<Zero>
      <RepeatsChar>
    - <Literal>
    ?? <DigitalPlaceHolder>
<Text>
    @ <TextPlaceHolder>

Contributing

Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature or change.

Licenses

This program is under the terms of the BSD 3-Clause License. See https://opensource.org/licenses/BSD-3-Clause.