github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library@v0.2.0/JSON_Utils_Cursors/JSON_Utils_Cursors.go (about) 1 // Package JSON_Utils_Cursors 2 // Dafny module JSON_Utils_Cursors compiled into Go 3 4 package JSON_Utils_Cursors 5 6 import ( 7 os "os" 8 9 m_Actions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Actions" 10 m_Base64 "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64" 11 m_Base64Lemmas "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64Lemmas" 12 m_BoundedInts "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/BoundedInts" 13 m_DivInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternals" 14 m_DivInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternalsNonlinear" 15 m_DivMod "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivMod" 16 m_FileIO "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FileIO" 17 m_FloatCompare "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FloatCompare" 18 m_Functions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Functions" 19 m_GeneralInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GeneralInternals" 20 m_GetOpt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GetOpt" 21 m_HexStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/HexStrings" 22 m_JSON_Utils_Lexers_Core "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/JSON_Utils_Lexers_Core" 23 m_JSON_Utils_Lexers_Strings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/JSON_Utils_Lexers_Strings" 24 m_JSON_Utils_Views_Core "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/JSON_Utils_Views_Core" 25 m_JSON_Utils_Views_Writers "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/JSON_Utils_Views_Writers" 26 m_Logarithm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Logarithm" 27 m__Math "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Math_" 28 m_ModInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternals" 29 m_ModInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternalsNonlinear" 30 m_Mul "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Mul" 31 m_MulInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternals" 32 m_MulInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternalsNonlinear" 33 m_Power "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Power" 34 m_Relations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Relations" 35 m_Seq "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq" 36 m_Seq_MergeSort "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq_MergeSort" 37 m_Sorting "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Sorting" 38 m_StandardLibrary "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary" 39 m_StandardLibraryInterop "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibraryInterop" 40 m_StandardLibrary_Sequence "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_Sequence" 41 m_StandardLibrary_String "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_String" 42 m_StandardLibrary_UInt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_UInt" 43 m_Streams "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Streams" 44 m_UnicodeStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/UnicodeStrings" 45 m__Unicode "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Unicode_" 46 m_Utf16EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf16EncodingForm" 47 m_Utf8EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf8EncodingForm" 48 m_Wrappers "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Wrappers" 49 m__System "github.com/dafny-lang/DafnyRuntimeGo/v4/System_" 50 _dafny "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny" 51 ) 52 53 var _ = os.Args 54 var _ _dafny.Dummy__ 55 var _ m__System.Dummy__ 56 var _ m_Wrappers.Dummy__ 57 var _ m_Relations.Dummy__ 58 var _ m_Seq_MergeSort.Dummy__ 59 var _ m__Math.Dummy__ 60 var _ m_Seq.Dummy__ 61 var _ m_BoundedInts.Dummy__ 62 var _ m__Unicode.Dummy__ 63 var _ m_Functions.Dummy__ 64 var _ m_Utf8EncodingForm.Dummy__ 65 var _ m_Utf16EncodingForm.Dummy__ 66 var _ m_UnicodeStrings.Dummy__ 67 var _ m_FileIO.Dummy__ 68 var _ m_GeneralInternals.Dummy__ 69 var _ m_MulInternalsNonlinear.Dummy__ 70 var _ m_MulInternals.Dummy__ 71 var _ m_Mul.Dummy__ 72 var _ m_ModInternalsNonlinear.Dummy__ 73 var _ m_DivInternalsNonlinear.Dummy__ 74 var _ m_ModInternals.Dummy__ 75 var _ m_DivInternals.Dummy__ 76 var _ m_DivMod.Dummy__ 77 var _ m_Power.Dummy__ 78 var _ m_Logarithm.Dummy__ 79 var _ m_StandardLibraryInterop.Dummy__ 80 var _ m_StandardLibrary_UInt.Dummy__ 81 var _ m_StandardLibrary_Sequence.Dummy__ 82 var _ m_StandardLibrary_String.Dummy__ 83 var _ m_StandardLibrary.Dummy__ 84 var _ m_Streams.Dummy__ 85 var _ m_Sorting.Dummy__ 86 var _ m_HexStrings.Dummy__ 87 var _ m_GetOpt.Dummy__ 88 var _ m_FloatCompare.Dummy__ 89 var _ m_Base64.Dummy__ 90 var _ m_Base64Lemmas.Dummy__ 91 var _ m_Actions.Dummy__ 92 var _ m_JSON_Utils_Views_Core.Dummy__ 93 var _ m_JSON_Utils_Views_Writers.Dummy__ 94 var _ m_JSON_Utils_Lexers_Core.Dummy__ 95 var _ m_JSON_Utils_Lexers_Strings.Dummy__ 96 97 type Dummy__ struct{} 98 99 // Definition of datatype Split 100 type Split struct { 101 Data_Split_ 102 } 103 104 func (_this Split) Get_() Data_Split_ { 105 return _this.Data_Split_ 106 } 107 108 type Data_Split_ interface { 109 isSplit() 110 } 111 112 type CompanionStruct_Split_ struct { 113 } 114 115 var Companion_Split_ = CompanionStruct_Split_{} 116 117 type Split_SP struct { 118 T interface{} 119 Cs Cursor__ 120 } 121 122 func (Split_SP) isSplit() {} 123 124 func (CompanionStruct_Split_) Create_SP_(T interface{}, Cs Cursor__) Split { 125 return Split{Split_SP{T, Cs}} 126 } 127 128 func (_this Split) Is_SP() bool { 129 _, ok := _this.Get_().(Split_SP) 130 return ok 131 } 132 133 func (CompanionStruct_Split_) Default(_default_T interface{}) Split { 134 return Companion_Split_.Create_SP_(_default_T, Companion_FreshCursor_.Witness()) 135 } 136 137 func (_this Split) Dtor_t() interface{} { 138 return _this.Get_().(Split_SP).T 139 } 140 141 func (_this Split) Dtor_cs() Cursor__ { 142 return _this.Get_().(Split_SP).Cs 143 } 144 145 func (_this Split) String() string { 146 switch data := _this.Get_().(type) { 147 case nil: 148 return "null" 149 case Split_SP: 150 { 151 return "Cursors.Split.SP" + "(" + _dafny.String(data.T) + ", " + _dafny.String(data.Cs) + ")" 152 } 153 default: 154 { 155 return "<unexpected>" 156 } 157 } 158 } 159 160 func (_this Split) Equals(other Split) bool { 161 switch data1 := _this.Get_().(type) { 162 case Split_SP: 163 { 164 data2, ok := other.Get_().(Split_SP) 165 return ok && _dafny.AreEqual(data1.T, data2.T) && data1.Cs.Equals(data2.Cs) 166 } 167 default: 168 { 169 return false // unexpected 170 } 171 } 172 } 173 174 func (_this Split) EqualsGeneric(other interface{}) bool { 175 typed, ok := other.(Split) 176 return ok && _this.Equals(typed) 177 } 178 179 func Type_Split_(Type_T_ _dafny.TypeDescriptor) _dafny.TypeDescriptor { 180 return type_Split_{Type_T_} 181 } 182 183 type type_Split_ struct { 184 Type_T_ _dafny.TypeDescriptor 185 } 186 187 func (_this type_Split_) Default() interface{} { 188 Type_T_ := _this.Type_T_ 189 _ = Type_T_ 190 return Companion_Split_.Default(Type_T_.Default()) 191 } 192 193 func (_this type_Split_) String() string { 194 return "JSON_Utils_Cursors.Split" 195 } 196 func (_this Split) ParentTraits_() []*_dafny.TraitID { 197 return [](*_dafny.TraitID){} 198 } 199 200 var _ _dafny.TraitOffspring = Split{} 201 202 // End of datatype Split 203 204 // Definition of class Cursor 205 type Cursor struct { 206 } 207 208 func New_Cursor_() *Cursor { 209 _this := Cursor{} 210 211 return &_this 212 } 213 214 type CompanionStruct_Cursor_ struct { 215 } 216 217 var Companion_Cursor_ = CompanionStruct_Cursor_{} 218 219 func (*Cursor) String() string { 220 return "JSON_Utils_Cursors.Cursor" 221 } 222 func (_this *CompanionStruct_Cursor_) Witness() Cursor__ { 223 return Companion_Cursor___.Create_Cursor_(_dafny.SeqOf(), uint32(0), uint32(0), uint32(0)) 224 } 225 226 // End of class Cursor 227 228 func Type_Cursor_() _dafny.TypeDescriptor { 229 return type_Cursor_{} 230 } 231 232 type type_Cursor_ struct { 233 } 234 235 func (_this type_Cursor_) Default() interface{} { 236 return Companion_Cursor_.Witness() 237 } 238 239 func (_this type_Cursor_) String() string { 240 return "JSON_Utils_Cursors.Cursor" 241 } 242 243 // Definition of class FreshCursor 244 type FreshCursor struct { 245 } 246 247 func New_FreshCursor_() *FreshCursor { 248 _this := FreshCursor{} 249 250 return &_this 251 } 252 253 type CompanionStruct_FreshCursor_ struct { 254 } 255 256 var Companion_FreshCursor_ = CompanionStruct_FreshCursor_{} 257 258 func (*FreshCursor) String() string { 259 return "JSON_Utils_Cursors.FreshCursor" 260 } 261 func (_this *CompanionStruct_FreshCursor_) Witness() Cursor__ { 262 return Companion_Cursor___.Create_Cursor_(_dafny.SeqOf(), uint32(0), uint32(0), uint32(0)) 263 } 264 265 // End of class FreshCursor 266 267 func Type_FreshCursor_() _dafny.TypeDescriptor { 268 return type_FreshCursor_{} 269 } 270 271 type type_FreshCursor_ struct { 272 } 273 274 func (_this type_FreshCursor_) Default() interface{} { 275 return Companion_FreshCursor_.Witness() 276 } 277 278 func (_this type_FreshCursor_) String() string { 279 return "JSON_Utils_Cursors.FreshCursor" 280 } 281 282 // Definition of datatype CursorError 283 type CursorError struct { 284 Data_CursorError_ 285 } 286 287 func (_this CursorError) Get_() Data_CursorError_ { 288 return _this.Data_CursorError_ 289 } 290 291 type Data_CursorError_ interface { 292 isCursorError() 293 } 294 295 type CompanionStruct_CursorError_ struct { 296 } 297 298 var Companion_CursorError_ = CompanionStruct_CursorError_{} 299 300 type CursorError_EOF struct { 301 } 302 303 func (CursorError_EOF) isCursorError() {} 304 305 func (CompanionStruct_CursorError_) Create_EOF_() CursorError { 306 return CursorError{CursorError_EOF{}} 307 } 308 309 func (_this CursorError) Is_EOF() bool { 310 _, ok := _this.Get_().(CursorError_EOF) 311 return ok 312 } 313 314 type CursorError_ExpectingByte struct { 315 Expected uint8 316 B int16 317 } 318 319 func (CursorError_ExpectingByte) isCursorError() {} 320 321 func (CompanionStruct_CursorError_) Create_ExpectingByte_(Expected uint8, B int16) CursorError { 322 return CursorError{CursorError_ExpectingByte{Expected, B}} 323 } 324 325 func (_this CursorError) Is_ExpectingByte() bool { 326 _, ok := _this.Get_().(CursorError_ExpectingByte) 327 return ok 328 } 329 330 type CursorError_ExpectingAnyByte struct { 331 Expected__sq _dafny.Sequence 332 B int16 333 } 334 335 func (CursorError_ExpectingAnyByte) isCursorError() {} 336 337 func (CompanionStruct_CursorError_) Create_ExpectingAnyByte_(Expected__sq _dafny.Sequence, B int16) CursorError { 338 return CursorError{CursorError_ExpectingAnyByte{Expected__sq, B}} 339 } 340 341 func (_this CursorError) Is_ExpectingAnyByte() bool { 342 _, ok := _this.Get_().(CursorError_ExpectingAnyByte) 343 return ok 344 } 345 346 type CursorError_OtherError struct { 347 Err interface{} 348 } 349 350 func (CursorError_OtherError) isCursorError() {} 351 352 func (CompanionStruct_CursorError_) Create_OtherError_(Err interface{}) CursorError { 353 return CursorError{CursorError_OtherError{Err}} 354 } 355 356 func (_this CursorError) Is_OtherError() bool { 357 _, ok := _this.Get_().(CursorError_OtherError) 358 return ok 359 } 360 361 func (CompanionStruct_CursorError_) Default() CursorError { 362 return Companion_CursorError_.Create_EOF_() 363 } 364 365 func (_this CursorError) Dtor_expected() uint8 { 366 return _this.Get_().(CursorError_ExpectingByte).Expected 367 } 368 369 func (_this CursorError) Dtor_b() int16 { 370 switch data := _this.Get_().(type) { 371 case CursorError_ExpectingByte: 372 return data.B 373 default: 374 return data.(CursorError_ExpectingAnyByte).B 375 } 376 } 377 378 func (_this CursorError) Dtor_expected__sq() _dafny.Sequence { 379 return _this.Get_().(CursorError_ExpectingAnyByte).Expected__sq 380 } 381 382 func (_this CursorError) Dtor_err() interface{} { 383 return _this.Get_().(CursorError_OtherError).Err 384 } 385 386 func (_this CursorError) String() string { 387 switch data := _this.Get_().(type) { 388 case nil: 389 return "null" 390 case CursorError_EOF: 391 { 392 return "Cursors.CursorError.EOF" 393 } 394 case CursorError_ExpectingByte: 395 { 396 return "Cursors.CursorError.ExpectingByte" + "(" + _dafny.String(data.Expected) + ", " + _dafny.String(data.B) + ")" 397 } 398 case CursorError_ExpectingAnyByte: 399 { 400 return "Cursors.CursorError.ExpectingAnyByte" + "(" + _dafny.String(data.Expected__sq) + ", " + _dafny.String(data.B) + ")" 401 } 402 case CursorError_OtherError: 403 { 404 return "Cursors.CursorError.OtherError" + "(" + _dafny.String(data.Err) + ")" 405 } 406 default: 407 { 408 return "<unexpected>" 409 } 410 } 411 } 412 413 func (_this CursorError) Equals(other CursorError) bool { 414 switch data1 := _this.Get_().(type) { 415 case CursorError_EOF: 416 { 417 _, ok := other.Get_().(CursorError_EOF) 418 return ok 419 } 420 case CursorError_ExpectingByte: 421 { 422 data2, ok := other.Get_().(CursorError_ExpectingByte) 423 return ok && data1.Expected == data2.Expected && data1.B == data2.B 424 } 425 case CursorError_ExpectingAnyByte: 426 { 427 data2, ok := other.Get_().(CursorError_ExpectingAnyByte) 428 return ok && data1.Expected__sq.Equals(data2.Expected__sq) && data1.B == data2.B 429 } 430 case CursorError_OtherError: 431 { 432 data2, ok := other.Get_().(CursorError_OtherError) 433 return ok && _dafny.AreEqual(data1.Err, data2.Err) 434 } 435 default: 436 { 437 return false // unexpected 438 } 439 } 440 } 441 442 func (_this CursorError) EqualsGeneric(other interface{}) bool { 443 typed, ok := other.(CursorError) 444 return ok && _this.Equals(typed) 445 } 446 447 func Type_CursorError_() _dafny.TypeDescriptor { 448 return type_CursorError_{} 449 } 450 451 type type_CursorError_ struct { 452 } 453 454 func (_this type_CursorError_) Default() interface{} { 455 return Companion_CursorError_.Default() 456 } 457 458 func (_this type_CursorError_) String() string { 459 return "JSON_Utils_Cursors.CursorError" 460 } 461 func (_this CursorError) ParentTraits_() []*_dafny.TraitID { 462 return [](*_dafny.TraitID){} 463 } 464 465 var _ _dafny.TraitOffspring = CursorError{} 466 467 func (_this CursorError) ToString(pr func(interface{}) _dafny.Sequence) _dafny.Sequence { 468 { 469 var _source0 CursorError = _this 470 _ = _source0 471 { 472 if _source0.Is_EOF() { 473 return _dafny.SeqOfString("Reached EOF") 474 } 475 } 476 { 477 if _source0.Is_ExpectingByte() { 478 var _0_b0 uint8 = _source0.Get_().(CursorError_ExpectingByte).Expected 479 _ = _0_b0 480 var _1_b int16 = _source0.Get_().(CursorError_ExpectingByte).B 481 _ = _1_b 482 var _2_c _dafny.Sequence = (func() _dafny.Sequence { 483 if (_1_b) > (int16(0)) { 484 return _dafny.Companion_Sequence_.Concatenate(_dafny.Companion_Sequence_.Concatenate(_dafny.SeqOfString("'"), _dafny.SeqOfChars(_dafny.Char((_1_b)))), _dafny.SeqOfString("'")) 485 } 486 return _dafny.SeqOfString("EOF") 487 })() 488 _ = _2_c 489 return _dafny.Companion_Sequence_.Concatenate(_dafny.Companion_Sequence_.Concatenate(_dafny.Companion_Sequence_.Concatenate(_dafny.SeqOfString("Expecting '"), _dafny.SeqOfChars(_dafny.Char((_0_b0)))), _dafny.SeqOfString("', read ")), _2_c) 490 } 491 } 492 { 493 if _source0.Is_ExpectingAnyByte() { 494 var _3_bs0 _dafny.Sequence = _source0.Get_().(CursorError_ExpectingAnyByte).Expected__sq 495 _ = _3_bs0 496 var _4_b int16 = _source0.Get_().(CursorError_ExpectingAnyByte).B 497 _ = _4_b 498 var _5_c _dafny.Sequence = (func() _dafny.Sequence { 499 if (_4_b) > (int16(0)) { 500 return _dafny.Companion_Sequence_.Concatenate(_dafny.Companion_Sequence_.Concatenate(_dafny.SeqOfString("'"), _dafny.SeqOfChars(_dafny.Char((_4_b)))), _dafny.SeqOfString("'")) 501 } 502 return _dafny.SeqOfString("EOF") 503 })() 504 _ = _5_c 505 var _6_c0s _dafny.Sequence = _dafny.SeqCreate((_dafny.IntOfUint32((_3_bs0).Cardinality())).Uint32(), func(coer32 func(_dafny.Int) _dafny.Char) func(_dafny.Int) interface{} { 506 return func(arg36 _dafny.Int) interface{} { 507 return coer32(arg36) 508 } 509 }((func(_7_bs0 _dafny.Sequence) func(_dafny.Int) _dafny.Char { 510 return func(_8_idx _dafny.Int) _dafny.Char { 511 return _dafny.Char(((_7_bs0).Select((_8_idx).Uint32()).(uint8))) 512 } 513 })(_3_bs0))).SetString() 514 _ = _6_c0s 515 return _dafny.Companion_Sequence_.Concatenate(_dafny.Companion_Sequence_.Concatenate(_dafny.Companion_Sequence_.Concatenate(_dafny.SeqOfString("Expecting one of '"), _6_c0s), _dafny.SeqOfString("', read ")), _5_c) 516 } 517 } 518 { 519 var _9_err interface{} = _source0.Get_().(CursorError_OtherError).Err 520 _ = _9_err 521 return (pr)(_9_err) 522 } 523 } 524 } 525 526 // End of datatype CursorError 527 528 // Definition of datatype Cursor__ 529 type Cursor__ struct { 530 Data_Cursor___ 531 } 532 533 func (_this Cursor__) Get_() Data_Cursor___ { 534 return _this.Data_Cursor___ 535 } 536 537 type Data_Cursor___ interface { 538 isCursor__() 539 } 540 541 type CompanionStruct_Cursor___ struct { 542 } 543 544 var Companion_Cursor___ = CompanionStruct_Cursor___{} 545 546 type Cursor___Cursor struct { 547 S _dafny.Sequence 548 Beg uint32 549 Point uint32 550 End uint32 551 } 552 553 func (Cursor___Cursor) isCursor__() {} 554 555 func (CompanionStruct_Cursor___) Create_Cursor_(S _dafny.Sequence, Beg uint32, Point uint32, End uint32) Cursor__ { 556 return Cursor__{Cursor___Cursor{S, Beg, Point, End}} 557 } 558 559 func (_this Cursor__) Is_Cursor() bool { 560 _, ok := _this.Get_().(Cursor___Cursor) 561 return ok 562 } 563 564 func (CompanionStruct_Cursor___) Default() Cursor__ { 565 return Companion_Cursor___.Create_Cursor_(_dafny.EmptySeq, uint32(0), uint32(0), uint32(0)) 566 } 567 568 func (_this Cursor__) Dtor_s() _dafny.Sequence { 569 return _this.Get_().(Cursor___Cursor).S 570 } 571 572 func (_this Cursor__) Dtor_beg() uint32 { 573 return _this.Get_().(Cursor___Cursor).Beg 574 } 575 576 func (_this Cursor__) Dtor_point() uint32 { 577 return _this.Get_().(Cursor___Cursor).Point 578 } 579 580 func (_this Cursor__) Dtor_end() uint32 { 581 return _this.Get_().(Cursor___Cursor).End 582 } 583 584 func (_this Cursor__) String() string { 585 switch data := _this.Get_().(type) { 586 case nil: 587 return "null" 588 case Cursor___Cursor: 589 { 590 return "Cursors.Cursor_.Cursor" + "(" + _dafny.String(data.S) + ", " + _dafny.String(data.Beg) + ", " + _dafny.String(data.Point) + ", " + _dafny.String(data.End) + ")" 591 } 592 default: 593 { 594 return "<unexpected>" 595 } 596 } 597 } 598 599 func (_this Cursor__) Equals(other Cursor__) bool { 600 switch data1 := _this.Get_().(type) { 601 case Cursor___Cursor: 602 { 603 data2, ok := other.Get_().(Cursor___Cursor) 604 return ok && data1.S.Equals(data2.S) && data1.Beg == data2.Beg && data1.Point == data2.Point && data1.End == data2.End 605 } 606 default: 607 { 608 return false // unexpected 609 } 610 } 611 } 612 613 func (_this Cursor__) EqualsGeneric(other interface{}) bool { 614 typed, ok := other.(Cursor__) 615 return ok && _this.Equals(typed) 616 } 617 618 func Type_Cursor___() _dafny.TypeDescriptor { 619 return type_Cursor___{} 620 } 621 622 type type_Cursor___ struct { 623 } 624 625 func (_this type_Cursor___) Default() interface{} { 626 return Companion_Cursor___.Default() 627 } 628 629 func (_this type_Cursor___) String() string { 630 return "JSON_Utils_Cursors.Cursor__" 631 } 632 func (_this Cursor__) ParentTraits_() []*_dafny.TraitID { 633 return [](*_dafny.TraitID){} 634 } 635 636 var _ _dafny.TraitOffspring = Cursor__{} 637 638 func (_static CompanionStruct_Cursor___) OfView(v m_JSON_Utils_Views_Core.View__) Cursor__ { 639 return Companion_Cursor___.Create_Cursor_((v).Dtor_s(), (v).Dtor_beg(), (v).Dtor_beg(), (v).Dtor_end()) 640 } 641 func (_static CompanionStruct_Cursor___) OfBytes(bs _dafny.Sequence) Cursor__ { 642 return Companion_Cursor___.Create_Cursor_(bs, uint32(0), uint32(0), uint32((bs).Cardinality())) 643 } 644 func (_this Cursor__) Bytes() _dafny.Sequence { 645 { 646 return ((_this).Dtor_s()).Subsequence(uint32((_this).Dtor_beg()), uint32((_this).Dtor_end())) 647 } 648 } 649 func (_this Cursor__) Prefix() m_JSON_Utils_Views_Core.View__ { 650 { 651 return m_JSON_Utils_Views_Core.Companion_View___.Create_View_((_this).Dtor_s(), (_this).Dtor_beg(), (_this).Dtor_point()) 652 } 653 } 654 func (_this Cursor__) Suffix() Cursor__ { 655 { 656 var _0_dt__update__tmp_h0 Cursor__ = _this 657 _ = _0_dt__update__tmp_h0 658 var _1_dt__update_hbeg_h0 uint32 = (_this).Dtor_point() 659 _ = _1_dt__update_hbeg_h0 660 return Companion_Cursor___.Create_Cursor_((_0_dt__update__tmp_h0).Dtor_s(), _1_dt__update_hbeg_h0, (_0_dt__update__tmp_h0).Dtor_point(), (_0_dt__update__tmp_h0).Dtor_end()) 661 } 662 } 663 func (_this Cursor__) Split() Split { 664 { 665 return Companion_Split_.Create_SP_((_this).Prefix(), (_this).Suffix()) 666 } 667 } 668 func (_this Cursor__) PrefixLength() uint32 { 669 { 670 return ((_this).Dtor_point()) - (func() uint32 { return ((_this).Dtor_beg()) })() 671 } 672 } 673 func (_this Cursor__) SuffixLength() uint32 { 674 { 675 return ((_this).Dtor_end()) - (func() uint32 { return ((_this).Dtor_point()) })() 676 } 677 } 678 func (_this Cursor__) Length() uint32 { 679 { 680 return ((_this).Dtor_end()) - (func() uint32 { return ((_this).Dtor_beg()) })() 681 } 682 } 683 func (_this Cursor__) At(idx uint32) uint8 { 684 { 685 return ((_this).Dtor_s()).Select(uint32(((_this).Dtor_beg()) + (idx))).(uint8) 686 } 687 } 688 func (_this Cursor__) SuffixAt(idx uint32) uint8 { 689 { 690 return ((_this).Dtor_s()).Select(uint32(((_this).Dtor_point()) + (idx))).(uint8) 691 } 692 } 693 func (_this Cursor__) Peek() int16 { 694 { 695 if (_this).EOF_q() { 696 return int16(-1) 697 } else { 698 return int16((_this).SuffixAt(uint32(0))) 699 } 700 } 701 } 702 func (_this Cursor__) LookingAt(c _dafny.Char) bool { 703 { 704 return ((_this).Peek()) == (int16(c)) 705 } 706 } 707 func (_this Cursor__) Skip(n uint32) Cursor__ { 708 { 709 var _0_dt__update__tmp_h0 Cursor__ = _this 710 _ = _0_dt__update__tmp_h0 711 var _1_dt__update_hpoint_h0 uint32 = ((_this).Dtor_point()) + (n) 712 _ = _1_dt__update_hpoint_h0 713 return Companion_Cursor___.Create_Cursor_((_0_dt__update__tmp_h0).Dtor_s(), (_0_dt__update__tmp_h0).Dtor_beg(), _1_dt__update_hpoint_h0, (_0_dt__update__tmp_h0).Dtor_end()) 714 } 715 } 716 func (_this Cursor__) Unskip(n uint32) Cursor__ { 717 { 718 var _0_dt__update__tmp_h0 Cursor__ = _this 719 _ = _0_dt__update__tmp_h0 720 var _1_dt__update_hpoint_h0 uint32 = ((_this).Dtor_point()) - (func() uint32 { return (n) })() 721 _ = _1_dt__update_hpoint_h0 722 return Companion_Cursor___.Create_Cursor_((_0_dt__update__tmp_h0).Dtor_s(), (_0_dt__update__tmp_h0).Dtor_beg(), _1_dt__update_hpoint_h0, (_0_dt__update__tmp_h0).Dtor_end()) 723 } 724 } 725 func (_this Cursor__) Get(err interface{}) m_Wrappers.Result { 726 { 727 if (_this).EOF_q() { 728 return m_Wrappers.Companion_Result_.Create_Failure_(Companion_CursorError_.Create_OtherError_(err)) 729 } else { 730 return m_Wrappers.Companion_Result_.Create_Success_((_this).Skip(uint32(1))) 731 } 732 } 733 } 734 func (_this Cursor__) AssertByte(b uint8) m_Wrappers.Result { 735 { 736 var _0_nxt int16 = (_this).Peek() 737 _ = _0_nxt 738 if (_0_nxt) == (int16(b)) { 739 return m_Wrappers.Companion_Result_.Create_Success_((_this).Skip(uint32(1))) 740 } else { 741 return m_Wrappers.Companion_Result_.Create_Failure_(Companion_CursorError_.Create_ExpectingByte_(b, _0_nxt)) 742 } 743 } 744 } 745 func (_this Cursor__) AssertBytes(bs _dafny.Sequence, offset uint32) m_Wrappers.Result { 746 { 747 goto TAIL_CALL_START 748 TAIL_CALL_START: 749 if (offset) == (uint32((bs).Cardinality())) { 750 return m_Wrappers.Companion_Result_.Create_Success_(_this) 751 } else { 752 var _0_valueOrError0 m_Wrappers.Result = (_this).AssertByte((bs).Select(uint32(offset)).(uint8)) 753 _ = _0_valueOrError0 754 if (_0_valueOrError0).IsFailure() { 755 return (_0_valueOrError0).PropagateFailure() 756 } else { 757 var _1_ps Cursor__ = (_0_valueOrError0).Extract().(Cursor__) 758 _ = _1_ps 759 var _in0 Cursor__ = _1_ps 760 _ = _in0 761 var _in1 _dafny.Sequence = bs 762 _ = _in1 763 var _in2 uint32 = (offset) + (uint32(1)) 764 _ = _in2 765 _this = _in0 766 767 bs = _in1 768 offset = _in2 769 goto TAIL_CALL_START 770 } 771 } 772 } 773 } 774 func (_this Cursor__) AssertChar(c0 _dafny.Char) m_Wrappers.Result { 775 { 776 return (_this).AssertByte(uint8(c0)) 777 } 778 } 779 func (_this Cursor__) SkipByte() Cursor__ { 780 { 781 if (_this).EOF_q() { 782 return _this 783 } else { 784 return (_this).Skip(uint32(1)) 785 } 786 } 787 } 788 func (_this Cursor__) SkipIf(p func(uint8) bool) Cursor__ { 789 { 790 if ((_this).EOF_q()) || (!((p)((_this).SuffixAt(uint32(0))))) { 791 return _this 792 } else { 793 return (_this).Skip(uint32(1)) 794 } 795 } 796 } 797 func (_this Cursor__) SkipWhile(p func(uint8) bool) Cursor__ { 798 { 799 var ps Cursor__ = Companion_Cursor_.Witness() 800 _ = ps 801 var _0_point_k uint32 802 _ = _0_point_k 803 _0_point_k = (_this).Dtor_point() 804 var _1_end uint32 805 _ = _1_end 806 _1_end = (_this).Dtor_end() 807 for ((_0_point_k) < (_1_end)) && ((p)(((_this).Dtor_s()).Select(uint32(_0_point_k)).(uint8))) { 808 _0_point_k = (_0_point_k) + (uint32(1)) 809 } 810 ps = Companion_Cursor___.Create_Cursor_((_this).Dtor_s(), (_this).Dtor_beg(), _0_point_k, (_this).Dtor_end()) 811 return ps 812 return ps 813 } 814 } 815 func (_this Cursor__) SkipWhileLexer(step func(interface{}, int16) m_JSON_Utils_Lexers_Core.LexerResult, st interface{}) m_Wrappers.Result { 816 { 817 var pr m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(Companion_Cursor_.Witness()) 818 _ = pr 819 var _0_point_k uint32 820 _ = _0_point_k 821 _0_point_k = (_this).Dtor_point() 822 var _1_end uint32 823 _ = _1_end 824 _1_end = (_this).Dtor_end() 825 var _2_st_k interface{} 826 _ = _2_st_k 827 _2_st_k = st 828 for true { 829 var _3_eof bool 830 _ = _3_eof 831 _3_eof = (_0_point_k) == (_1_end) 832 var _4_minusone int16 833 _ = _4_minusone 834 _4_minusone = int16(-1) 835 var _5_c int16 836 _ = _5_c 837 if _3_eof { 838 _5_c = _4_minusone 839 } else { 840 _5_c = int16(((_this).Dtor_s()).Select(uint32(_0_point_k)).(uint8)) 841 } 842 var _source0 m_JSON_Utils_Lexers_Core.LexerResult = (step)(_2_st_k, _5_c) 843 _ = _source0 844 { 845 { 846 if _source0.Is_Accept() { 847 pr = m_Wrappers.Companion_Result_.Create_Success_(Companion_Cursor___.Create_Cursor_((_this).Dtor_s(), (_this).Dtor_beg(), _0_point_k, (_this).Dtor_end())) 848 return pr 849 goto Lmatch0 850 } 851 } 852 { 853 if _source0.Is_Reject() { 854 var _6_err interface{} = _source0.Get_().(m_JSON_Utils_Lexers_Core.LexerResult_Reject).Err 855 _ = _6_err 856 pr = m_Wrappers.Companion_Result_.Create_Failure_(Companion_CursorError_.Create_OtherError_(_6_err)) 857 return pr 858 goto Lmatch0 859 } 860 } 861 { 862 var _7_st_k_k interface{} = _source0.Get_().(m_JSON_Utils_Lexers_Core.LexerResult_Partial).St 863 _ = _7_st_k_k 864 if _3_eof { 865 pr = m_Wrappers.Companion_Result_.Create_Failure_(Companion_CursorError_.Create_EOF_()) 866 return pr 867 } else { 868 _2_st_k = _7_st_k_k 869 _0_point_k = (_0_point_k) + (uint32(1)) 870 } 871 } 872 goto Lmatch0 873 } 874 Lmatch0: 875 } 876 return pr 877 } 878 } 879 func (_this Cursor__) BOF_q() bool { 880 { 881 return ((_this).Dtor_point()) == ((_this).Dtor_beg()) 882 } 883 } 884 func (_this Cursor__) EOF_q() bool { 885 { 886 return ((_this).Dtor_point()) == ((_this).Dtor_end()) 887 } 888 } 889 890 // End of datatype Cursor__