taf/internal/parser/lexer.go

22 lines
673 B
Go
Raw Permalink Normal View History

2023-08-21 23:56:17 +00:00
package parser
import (
"github.com/alecthomas/participle/v2/lexer"
)
var lex = lexer.MustSimple([]lexer.SimpleRule{
2023-09-24 01:16:18 +00:00
{Name: "header", Pattern: `TAF ?`},
{Name: "Type", Pattern: "AMD|COR"},
{Name: "Remark", Pattern: `RMK[^\n]*`},
2023-08-21 23:56:17 +00:00
{Name: "Number", Pattern: `\d+`},
{Name: "Modifier", Pattern: `[+-]|VC`},
{Name: "Prob", Pattern: "PROB"},
{Name: "Slash", Pattern: `/`},
{Name: "Descriptor", Pattern: `MI|BC|DR|BL|SH|TS|FZ|PR`},
{Name: "Precip", Pattern: `DZ|RA|SN|SG|IC|PL|GR|GS|UP`},
{Name: "Obscur", Pattern: "BR|FG|FU|DU|SA|HZ|PY|VA"},
{Name: "Phenom", Pattern: "PO|SQ|FC|SS|DS"},
{Name: "Ident", Pattern: `[A-Z]+`},
{Name: "WS", Pattern: `[ \t\n\r]+`},
})