1 // This file is generated from format_fsm.rl. DO NOT EDIT.
3 # (except you are actually in scan_tokens.rl here, so edit away!)
14 "github.com/zclconf/go-cty/cty"
21 func formatFSM(format string, a []cty.Value) (string, error) {
24 nextArg := 1 // arg numbers are 1-based
46 return buf.String(), fmt.Errorf("invalid format string starting at offset %d", p)
50 // We'll try to slurp a whole UTF-8 sequence here, to give the user
52 r, _ := utf8.DecodeRuneInString(data[p:])
53 return buf.String(), fmt.Errorf("unrecognized format character %q at offset %d", r, p)
76 verb.ArgNum = (10 * verb.ArgNum) + (int(fc) - '0')
86 verb.Width = (10 * verb.Width) + (int(fc) - '0')
96 verb.Prec = (10 * verb.Prec) + (int(fc) - '0')
102 verb.Raw = data[ts:te]
105 err := formatAppend(&verb, &buf, a)
107 return buf.String(), err
109 nextArg = verb.ArgNum + 1
112 # a number that isn't zero and doesn't have a leading zero
124 '[' (num $argidx_num) ']'
128 ( num $width_num ) >width_reset %has_width
132 ('.' ( digit* $prec_num )) >prec_reset %has_prec
135 # We accept any letter here, but will be more picky in formatAppend
136 mode = ('a'..'z' | 'A'..'Z') @mode;
151 )* @/finish_err %/finish_ok $!err_char;
156 p := 0 // "Pointer" into data
157 pe := len(data) // End-of-data "pointer"
158 cs := 0 // current state (will be initialized by ragel-generated code)
163 // Keep Go compiler happy even if generated code doesn't use these
173 // If we fall out here without being in a final state then we've
174 // encountered something that the scanner can't match, which should
175 // be impossible (the scanner matches all bytes _somehow_) but we'll
176 // flag it anyway rather than just losing data from the end.
177 if cs < formatfsm_first_final {
178 return buf.String(), fmt.Errorf("extraneous characters beginning at offset %i", p)
181 return buf.String(), nil