Documentation
¶
Overview ¶
Package tabnasjsonic is the relaxed-JSON grammar plugin for the tabnas parsing engine (github.com/tabnas/parser/go). The engine ships no grammar; this package supplies the lenient-JSON one and a legacy Jsonic-style API on top of it.
engine.go re-exports the engine's public surface under the historic jsonic names so existing callers (and this package's own grammar and tests) keep compiling unchanged. The single source of truth for the parser, lexer, rule machinery, options and utilities is the tabnas engine — nothing here re-implements it.
Index ¶
- Constants
- Variables
- func Grammar(j *Jsonic, opts map[string]any) (err error)
- func Parse(src string) (any, error)
- type AltAction
- type AltCond
- type AltError
- type AltModListOpts
- type AltModifier
- type AltSpec
- type ColorConfig
- type ColorOptions
- type CommentDef
- type CommentOptions
- type ConfigModifier
- type Context
- type Entry
- type ErrMsgOptions
- type FixedOptions
- type FuncRef
- type GrammarAltListSpec
- type GrammarAltSpec
- type GrammarInjectSpec
- type GrammarRuleSpec
- type GrammarSetting
- type GrammarSettingAlt
- type GrammarSettingRule
- type GrammarSpec
- type InfoOptions
- type Jsonic
- type JsonicError
- type Lex
- type LexCheck
- type LexCheckResult
- type LexConfig
- type LexMatcher
- type LexOptions
- type LexSub
- type LineOptions
- type ListOptions
- type ListRef
- type MakeLexMatcher
- type MapMergeFunc
- type MapOptions
- type MapRef
- type MatchOptions
- type MatchSpec
- type MatchTokenEntry
- type MatchValueEntry
- type MatchValueSpec
- type MatcherEntry
- type ModListOpts
- type NumberOptions
- type Options
- type ParseOptions
- type Parser
- type ParserOptions
- type Plugin
- type Point
- type PropertyOptions
- type ResultOptions
- type Rule
- type RuleDefiner
- type RuleOptions
- type RuleSpec
- type RuleState
- type RuleSub
- type SafeOptions
- type ScanOut
- type ScanSpec
- type SpaceOptions
- type StateAction
- type StringOptions
- type Text
- type TextOptions
- type Tin
- type Token
- type TokenValFunc
- type UtilBag
- type ValModifier
- type ValueDef
- type ValueDefEntry
- type ValueOptions
Constants ¶
const ( TinBD = tabnas.TinBD TinZZ = tabnas.TinZZ TinUK = tabnas.TinUK TinAA = tabnas.TinAA TinSP = tabnas.TinSP TinLN = tabnas.TinLN TinCM = tabnas.TinCM TinNR = tabnas.TinNR TinST = tabnas.TinST TinTX = tabnas.TinTX TinVL = tabnas.TinVL TinOB = tabnas.TinOB TinCB = tabnas.TinCB TinOS = tabnas.TinOS TinCS = tabnas.TinCS TinCL = tabnas.TinCL TinCA = tabnas.TinCA TinMAX = tabnas.TinMAX // Rule states. OPEN = tabnas.OPEN CLOSE = tabnas.CLOSE )
Token identification numbers (Tin) for the standard tokens.
const Version = "0.2.0"
Version is the current version of the jsonic Go module.
Variables ¶
var ( // Undefined is the sentinel for "no value" (distinct from nil). Undefined = tabnas.Undefined // NoToken / NoRule are the zero sentinels used in rule actions. NoToken = tabnas.NoToken NoRule = tabnas.NoRule // Skip is the deep-merge skip sentinel. Skip = tabnas.Skip // FixedTokens is the global fixed-token table (src → Tin). FixedTokens = tabnas.FixedTokens // TinSetVAL / TinSetKEY are the default value and key token sets. TinSetVAL = tabnas.TinSetVAL TinSetKEY = tabnas.TinSetKEY // BuiltinRefs is the engine's standard `$`-builtin library // (@object$/@array$/@reset$/@key$/@setval$/@push$/@value$, plus the // tree/probe builtins). jsonic merges these into its local funcref map // so its code-built alts can reference them by name (the engine merges // them automatically only for a declarative GrammarSpec, not for alts // resolved directly via ResolveGrammarAltStatic). BuiltinRefs = tabnas.BUILTIN_REFS )
var ( Deep = tabnas.Deep IsUndefined = tabnas.IsUndefined UnwrapUndefined = tabnas.UnwrapUndefined MakeRule = tabnas.MakeRule MakeRuleCond = tabnas.MakeRuleCond MakeToken = tabnas.MakeToken MapToOptions = tabnas.MapToOptions NewLex = tabnas.NewLex NewParser = tabnas.NewParser ParseAlts = tabnas.ParseAlts ResolveFuncRefs = tabnas.ResolveFuncRefs ResolveGrammarAltStatic = tabnas.ResolveGrammarAltStatic Str = tabnas.Str Snip = tabnas.Snip StrInject = tabnas.StrInject Keys = tabnas.Keys Values = tabnas.Values Entries = tabnas.Entries Omap = tabnas.Omap ValidateGroupTags = tabnas.ValidateGroupTags Scan = tabnas.Scan BuildCharRunSpec = tabnas.BuildCharRunSpec BuildLineRunSpec = tabnas.BuildLineRunSpec BuildStringBodySpec = tabnas.BuildStringBodySpec NormAlt = tabnas.NormAlt NormAlts = tabnas.NormAlts ModList = tabnas.ModList LookupRef = tabnas.LookupRef RequireRef = tabnas.RequireRef IsFuncRef = tabnas.IsFuncRef IsSkip = tabnas.IsSkip RegisterTextParser = tabnas.RegisterTextParser DefaultLexConfig = tabnas.DefaultLexConfig CEq = tabnas.CEq CGt = tabnas.CGt CGte = tabnas.CGte CLt = tabnas.CLt CLte = tabnas.CLte CNe = tabnas.CNe )
Functions ¶
func Grammar ¶
Grammar is the idiomatic tabnas grammar plugin: it applies jsonic's option defaults and registers the relaxed-JSON grammar (the val / map / list / pair / elem rules) on the engine instance. Use it the standard way, and `use` it before any plugin that builds on jsonic's rules:
j := tabnas.Make()
j.Use(jsonic.Grammar)
j.Use(csv) // builds on jsonic's value/map/list rules
out, _ := j.Parse("a:1,b:[x,y,z]")
The Jsonic-style helpers (Make, Parse, MakeJSON) are a legacy compatibility layer that installs this same plugin.
Types ¶
type AltModListOpts ¶
type AltModListOpts = tabnas.AltModListOpts
type AltModifier ¶
type AltModifier = tabnas.AltModifier
type ColorConfig ¶
type ColorConfig = tabnas.ColorConfig
type ColorOptions ¶
type ColorOptions = tabnas.ColorOptions
type CommentDef ¶
type CommentDef = tabnas.CommentDef
type CommentOptions ¶
type CommentOptions = tabnas.CommentOptions
type ConfigModifier ¶
type ConfigModifier = tabnas.ConfigModifier
type ErrMsgOptions ¶
type ErrMsgOptions = tabnas.ErrMsgOptions
type FixedOptions ¶
type FixedOptions = tabnas.FixedOptions
type GrammarAltListSpec ¶
type GrammarAltListSpec = tabnas.GrammarAltListSpec
type GrammarAltSpec ¶
type GrammarAltSpec = tabnas.GrammarAltSpec
type GrammarInjectSpec ¶
type GrammarInjectSpec = tabnas.GrammarInjectSpec
type GrammarRuleSpec ¶
type GrammarRuleSpec = tabnas.GrammarRuleSpec
type GrammarSetting ¶
type GrammarSetting = tabnas.GrammarSetting
type GrammarSettingAlt ¶
type GrammarSettingAlt = tabnas.GrammarSettingAlt
type GrammarSettingRule ¶
type GrammarSettingRule = tabnas.GrammarSettingRule
type GrammarSpec ¶
type GrammarSpec = tabnas.GrammarSpec
type InfoOptions ¶
type InfoOptions = tabnas.InfoOptions
type Jsonic ¶
Jsonic is a configured parser instance. It is the tabnas engine type; the relaxed-JSON grammar is installed onto it by Make / the Grammar plugin. Kept under the historic name for backward compatibility.
func Empty ¶
Empty creates a parser instance with the jsonic configuration but no grammar rules, for building a grammar from scratch. Matches the historic jsonic.empty().
func Make ¶
Make creates a relaxed-JSON parser instance: a tabnas engine with the jsonic grammar plugin installed, plus any caller options on top. Equivalent to the historic jsonic.make().
func MakeJSON ¶
func MakeJSON() *Jsonic
MakeJSON creates an instance configured to accept strict JSON only. Mirrors the TypeScript Jsonic.make('json'): it installs the full jsonic grammar, then restricts it to the json-tagged alternates and disables the lenient lexer features. Rejects unquoted keys/values, comments, hex/octal/binary numbers, trailing commas, leading-zero numbers, single-quoted or backtick strings, and empty input.
type JsonicError ¶
type JsonicError = tabnas.TabnasError
JsonicError is the structured error returned by Parse on failure. It is the engine's error type; the [jsonic/<code>] tag comes from the errmsg.name option that the grammar plugin sets to "jsonic".
type LexCheckResult ¶
type LexCheckResult = tabnas.LexCheckResult
type LexMatcher ¶
type LexMatcher = tabnas.LexMatcher
type LexOptions ¶
type LexOptions = tabnas.LexOptions
type LineOptions ¶
type LineOptions = tabnas.LineOptions
type ListOptions ¶
type ListOptions = tabnas.ListOptions
type MakeLexMatcher ¶
type MakeLexMatcher = tabnas.MakeLexMatcher
type MapMergeFunc ¶
type MapMergeFunc = tabnas.MapMergeFunc
type MapOptions ¶
type MapOptions = tabnas.MapOptions
type MatchOptions ¶
type MatchOptions = tabnas.MatchOptions
type MatchTokenEntry ¶
type MatchTokenEntry = tabnas.MatchTokenEntry
type MatchValueEntry ¶
type MatchValueEntry = tabnas.MatchValueEntry
type MatchValueSpec ¶
type MatchValueSpec = tabnas.MatchValueSpec
type MatcherEntry ¶
type MatcherEntry = tabnas.MatcherEntry
type ModListOpts ¶
type ModListOpts = tabnas.ModListOpts
type NumberOptions ¶
type NumberOptions = tabnas.NumberOptions
type ParseOptions ¶
type ParseOptions = tabnas.ParseOptions
type ParserOptions ¶
type ParserOptions = tabnas.ParserOptions
type Plugin ¶
Plugin is a function that configures a parser instance. It is the engine's plugin type; jsonic's own grammar (see Grammar) is one.
type PropertyOptions ¶
type PropertyOptions = tabnas.PropertyOptions
type ResultOptions ¶
type ResultOptions = tabnas.ResultOptions
type RuleDefiner ¶
type RuleDefiner = tabnas.RuleDefiner
type RuleOptions ¶
type RuleOptions = tabnas.RuleOptions
type SafeOptions ¶
type SafeOptions = tabnas.SafeOptions
type SpaceOptions ¶
type SpaceOptions = tabnas.SpaceOptions
type StateAction ¶
type StateAction = tabnas.StateAction
type StringOptions ¶
type StringOptions = tabnas.StringOptions
type TextOptions ¶
type TextOptions = tabnas.TextOptions
type TokenValFunc ¶
type TokenValFunc = tabnas.TokenValFunc
type ValModifier ¶
type ValModifier = tabnas.ValModifier
type ValueDefEntry ¶
type ValueDefEntry = tabnas.ValueDefEntry
type ValueOptions ¶
type ValueOptions = tabnas.ValueOptions