lexer.go 23 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
  1. /**
  2. * Copyright 2014 Paul Querna
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. /* Portions of this file are on derived from yajl: <https://github.com/lloyd/yajl> */
  18. /*
  19. * Copyright (c) 2007-2014, Lloyd Hilaiel <me@lloyd.io>
  20. *
  21. * Permission to use, copy, modify, and/or distribute this software for any
  22. * purpose with or without fee is hereby granted, provided that the above
  23. * copyright notice and this permission notice appear in all copies.
  24. *
  25. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  26. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  27. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  28. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  29. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  30. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  31. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  32. */
  33. package v1
  34. import (
  35. "errors"
  36. "fmt"
  37. "io"
  38. )
  39. type FFParseState int
  40. const (
  41. FFParse_map_start FFParseState = iota
  42. FFParse_want_key
  43. FFParse_want_colon
  44. FFParse_want_value
  45. FFParse_after_value
  46. )
  47. type FFTok int
  48. const (
  49. FFTok_init FFTok = iota
  50. FFTok_bool FFTok = iota
  51. FFTok_colon FFTok = iota
  52. FFTok_comma FFTok = iota
  53. FFTok_eof FFTok = iota
  54. FFTok_error FFTok = iota
  55. FFTok_left_brace FFTok = iota
  56. FFTok_left_bracket FFTok = iota
  57. FFTok_null FFTok = iota
  58. FFTok_right_brace FFTok = iota
  59. FFTok_right_bracket FFTok = iota
  60. /* we differentiate between integers and doubles to allow the
  61. * parser to interpret the number without re-scanning */
  62. FFTok_integer FFTok = iota
  63. FFTok_double FFTok = iota
  64. FFTok_string FFTok = iota
  65. /* comment tokens are not currently returned to the parser, ever */
  66. FFTok_comment FFTok = iota
  67. )
  68. type FFErr int
  69. const (
  70. FFErr_e_ok FFErr = iota
  71. FFErr_io FFErr = iota
  72. FFErr_string_invalid_utf8 FFErr = iota
  73. FFErr_string_invalid_escaped_char FFErr = iota
  74. FFErr_string_invalid_json_char FFErr = iota
  75. FFErr_string_invalid_hex_char FFErr = iota
  76. FFErr_invalid_char FFErr = iota
  77. FFErr_invalid_string FFErr = iota
  78. FFErr_missing_integer_after_decimal FFErr = iota
  79. FFErr_missing_integer_after_exponent FFErr = iota
  80. FFErr_missing_integer_after_minus FFErr = iota
  81. FFErr_unallowed_comment FFErr = iota
  82. FFErr_incomplete_comment FFErr = iota
  83. FFErr_unexpected_token_type FFErr = iota // TODO: improve this error
  84. )
  85. type FFLexer struct {
  86. reader *ffReader
  87. Output DecodingBuffer
  88. Token FFTok
  89. Error FFErr
  90. BigError error
  91. // TODO: convert all of this to an interface
  92. lastCurrentChar int
  93. captureAll bool
  94. buf Buffer
  95. }
  96. func NewFFLexer(input []byte) *FFLexer {
  97. fl := &FFLexer{
  98. Token: FFTok_init,
  99. Error: FFErr_e_ok,
  100. reader: newffReader(input),
  101. Output: &Buffer{},
  102. }
  103. // TODO: guess size?
  104. //fl.Output.Grow(64)
  105. return fl
  106. }
  107. type LexerError struct {
  108. offset int
  109. line int
  110. char int
  111. err error
  112. }
  113. // Reset the Lexer and add new input.
  114. func (ffl *FFLexer) Reset(input []byte) {
  115. ffl.Token = FFTok_init
  116. ffl.Error = FFErr_e_ok
  117. ffl.BigError = nil
  118. ffl.reader.Reset(input)
  119. ffl.lastCurrentChar = 0
  120. ffl.Output.Reset()
  121. }
  122. func (le *LexerError) Error() string {
  123. return fmt.Sprintf(`ffjson error: (%T)%s offset=%d line=%d char=%d`,
  124. le.err, le.err.Error(),
  125. le.offset, le.line, le.char)
  126. }
  127. func (ffl *FFLexer) WrapErr(err error) error {
  128. line, char := ffl.reader.PosWithLine()
  129. // TOOD: calcualte lines/characters based on offset
  130. return &LexerError{
  131. offset: ffl.reader.Pos(),
  132. line: line,
  133. char: char,
  134. err: err,
  135. }
  136. }
  137. func (ffl *FFLexer) scanReadByte() (byte, error) {
  138. var c byte
  139. var err error
  140. if ffl.captureAll {
  141. c, err = ffl.reader.ReadByte()
  142. } else {
  143. c, err = ffl.reader.ReadByteNoWS()
  144. }
  145. if err != nil {
  146. ffl.Error = FFErr_io
  147. ffl.BigError = err
  148. return 0, err
  149. }
  150. return c, nil
  151. }
  152. func (ffl *FFLexer) readByte() (byte, error) {
  153. c, err := ffl.reader.ReadByte()
  154. if err != nil {
  155. ffl.Error = FFErr_io
  156. ffl.BigError = err
  157. return 0, err
  158. }
  159. return c, nil
  160. }
  161. func (ffl *FFLexer) unreadByte() {
  162. ffl.reader.UnreadByte()
  163. }
  164. func (ffl *FFLexer) wantBytes(want []byte, iftrue FFTok) FFTok {
  165. startPos := ffl.reader.Pos()
  166. for _, b := range want {
  167. c, err := ffl.readByte()
  168. if err != nil {
  169. return FFTok_error
  170. }
  171. if c != b {
  172. ffl.unreadByte()
  173. // fmt.Printf("wanted bytes: %s\n", string(want))
  174. // TODO(pquerna): thsi is a bad error message
  175. ffl.Error = FFErr_invalid_string
  176. return FFTok_error
  177. }
  178. }
  179. endPos := ffl.reader.Pos()
  180. ffl.Output.Write(ffl.reader.Slice(startPos, endPos))
  181. return iftrue
  182. }
  183. func (ffl *FFLexer) lexComment() FFTok {
  184. c, err := ffl.readByte()
  185. if err != nil {
  186. return FFTok_error
  187. }
  188. if c == '/' {
  189. // a // comment, scan until line ends.
  190. for {
  191. c, err := ffl.readByte()
  192. if err != nil {
  193. return FFTok_error
  194. }
  195. if c == '\n' {
  196. return FFTok_comment
  197. }
  198. }
  199. } else if c == '*' {
  200. // a /* */ comment, scan */
  201. for {
  202. c, err := ffl.readByte()
  203. if err != nil {
  204. return FFTok_error
  205. }
  206. if c == '*' {
  207. c, err := ffl.readByte()
  208. if err != nil {
  209. return FFTok_error
  210. }
  211. if c == '/' {
  212. return FFTok_comment
  213. }
  214. ffl.Error = FFErr_incomplete_comment
  215. return FFTok_error
  216. }
  217. }
  218. } else {
  219. ffl.Error = FFErr_incomplete_comment
  220. return FFTok_error
  221. }
  222. }
  223. func (ffl *FFLexer) lexString() FFTok {
  224. if ffl.captureAll {
  225. ffl.buf.Reset()
  226. err := ffl.reader.SliceString(&ffl.buf)
  227. if err != nil {
  228. ffl.BigError = err
  229. return FFTok_error
  230. }
  231. WriteJson(ffl.Output, ffl.buf.Bytes())
  232. return FFTok_string
  233. } else {
  234. err := ffl.reader.SliceString(ffl.Output)
  235. if err != nil {
  236. ffl.BigError = err
  237. return FFTok_error
  238. }
  239. return FFTok_string
  240. }
  241. }
  242. func (ffl *FFLexer) LexInt64() (int64, error) {
  243. c, err := ffl.readByte()
  244. if err != nil {
  245. return 0, err
  246. }
  247. /* optional leading minus */
  248. if c == '-' {
  249. n, err := ffl.LexUin64()
  250. if err != nil {
  251. return 0, err
  252. }
  253. return -int64(n), nil
  254. } else {
  255. ffl.unreadByte()
  256. n, err := ffl.LexUin64()
  257. if err != nil {
  258. return 0, err
  259. }
  260. return int64(n), nil
  261. }
  262. }
  263. const maxUint64 = (1<<64 - 1)
  264. const cutoff = maxUint64/10 + 1
  265. func (ffl *FFLexer) LexUin64() (uint64, error) {
  266. var n uint64
  267. c, err := ffl.readByte()
  268. if err != nil {
  269. return 0, err
  270. }
  271. /* a single zero, or a series of integers */
  272. if c == '0' {
  273. c, err = ffl.readByte()
  274. if err != nil && err != io.EOF {
  275. return 0, err
  276. }
  277. } else if c >= '1' && c <= '9' {
  278. for c >= '0' && c <= '9' {
  279. var v byte
  280. v = c - '0'
  281. if n >= cutoff {
  282. return 0, errors.New("overflow")
  283. }
  284. n = n * uint64(10) + uint64(v)
  285. c, err = ffl.readByte()
  286. if err != nil && err != io.EOF {
  287. return 0, err
  288. }
  289. }
  290. ffl.unreadByte()
  291. } else {
  292. ffl.unreadByte()
  293. return 0, errors.New("unexpected")
  294. }
  295. return n, nil
  296. }
  297. func (ffl *FFLexer) lexNumber() FFTok {
  298. var numRead int = 0
  299. tok := FFTok_integer
  300. startPos := ffl.reader.Pos()
  301. c, err := ffl.readByte()
  302. if err != nil {
  303. return FFTok_error
  304. }
  305. /* optional leading minus */
  306. if c == '-' {
  307. c, err = ffl.readByte()
  308. if err != nil {
  309. return FFTok_error
  310. }
  311. }
  312. /* a single zero, or a series of integers */
  313. if c == '0' {
  314. c, err = ffl.readByte()
  315. if err != nil {
  316. return FFTok_error
  317. }
  318. } else if c >= '1' && c <= '9' {
  319. for c >= '0' && c <= '9' {
  320. c, err = ffl.readByte()
  321. if err != nil {
  322. return FFTok_error
  323. }
  324. }
  325. } else {
  326. ffl.unreadByte()
  327. ffl.Error = FFErr_missing_integer_after_minus
  328. return FFTok_error
  329. }
  330. if c == '.' {
  331. numRead = 0
  332. c, err = ffl.readByte()
  333. if err != nil {
  334. return FFTok_error
  335. }
  336. for c >= '0' && c <= '9' {
  337. numRead++
  338. c, err = ffl.readByte()
  339. if err != nil {
  340. return FFTok_error
  341. }
  342. }
  343. if numRead == 0 {
  344. ffl.unreadByte()
  345. ffl.Error = FFErr_missing_integer_after_decimal
  346. return FFTok_error
  347. }
  348. tok = FFTok_double
  349. }
  350. /* optional exponent (indicates this is floating point) */
  351. if c == 'e' || c == 'E' {
  352. numRead = 0
  353. c, err = ffl.readByte()
  354. if err != nil {
  355. return FFTok_error
  356. }
  357. /* optional sign */
  358. if c == '+' || c == '-' {
  359. c, err = ffl.readByte()
  360. if err != nil {
  361. return FFTok_error
  362. }
  363. }
  364. for c >= '0' && c <= '9' {
  365. numRead++
  366. c, err = ffl.readByte()
  367. if err != nil {
  368. return FFTok_error
  369. }
  370. }
  371. if numRead == 0 {
  372. ffl.Error = FFErr_missing_integer_after_exponent
  373. return FFTok_error
  374. }
  375. tok = FFTok_double
  376. }
  377. ffl.unreadByte()
  378. endPos := ffl.reader.Pos()
  379. ffl.Output.Write(ffl.reader.Slice(startPos, endPos))
  380. return tok
  381. }
  382. var true_bytes = []byte{'r', 'u', 'e'}
  383. var false_bytes = []byte{'a', 'l', 's', 'e'}
  384. var null_bytes = []byte{'u', 'l', 'l'}
  385. func (ffl *FFLexer) Scan() FFTok {
  386. tok := FFTok_error
  387. if ffl.captureAll == false {
  388. ffl.Output.Reset()
  389. }
  390. ffl.Token = FFTok_init
  391. for {
  392. c, err := ffl.scanReadByte()
  393. if err != nil {
  394. if err == io.EOF {
  395. return FFTok_eof
  396. } else {
  397. return FFTok_error
  398. }
  399. }
  400. switch c {
  401. case '{':
  402. tok = FFTok_left_bracket
  403. if ffl.captureAll {
  404. ffl.Output.WriteByte('{')
  405. }
  406. goto lexed
  407. case '}':
  408. tok = FFTok_right_bracket
  409. if ffl.captureAll {
  410. ffl.Output.WriteByte('}')
  411. }
  412. goto lexed
  413. case '[':
  414. tok = FFTok_left_brace
  415. if ffl.captureAll {
  416. ffl.Output.WriteByte('[')
  417. }
  418. goto lexed
  419. case ']':
  420. tok = FFTok_right_brace
  421. if ffl.captureAll {
  422. ffl.Output.WriteByte(']')
  423. }
  424. goto lexed
  425. case ',':
  426. tok = FFTok_comma
  427. if ffl.captureAll {
  428. ffl.Output.WriteByte(',')
  429. }
  430. goto lexed
  431. case ':':
  432. tok = FFTok_colon
  433. if ffl.captureAll {
  434. ffl.Output.WriteByte(':')
  435. }
  436. goto lexed
  437. case '\t', '\n', '\v', '\f', '\r', ' ':
  438. if ffl.captureAll {
  439. ffl.Output.WriteByte(c)
  440. }
  441. break
  442. case 't':
  443. ffl.Output.WriteByte('t')
  444. tok = ffl.wantBytes(true_bytes, FFTok_bool)
  445. goto lexed
  446. case 'f':
  447. ffl.Output.WriteByte('f')
  448. tok = ffl.wantBytes(false_bytes, FFTok_bool)
  449. goto lexed
  450. case 'n':
  451. ffl.Output.WriteByte('n')
  452. tok = ffl.wantBytes(null_bytes, FFTok_null)
  453. goto lexed
  454. case '"':
  455. tok = ffl.lexString()
  456. goto lexed
  457. case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
  458. ffl.unreadByte()
  459. tok = ffl.lexNumber()
  460. goto lexed
  461. case '/':
  462. tok = ffl.lexComment()
  463. goto lexed
  464. default:
  465. tok = FFTok_error
  466. ffl.Error = FFErr_invalid_char
  467. }
  468. }
  469. lexed:
  470. ffl.Token = tok
  471. return tok
  472. }
  473. func (ffl *FFLexer) scanField(start FFTok, capture bool) ([]byte, error) {
  474. switch start {
  475. case FFTok_left_brace,
  476. FFTok_left_bracket:
  477. {
  478. end := FFTok_right_brace
  479. if start == FFTok_left_bracket {
  480. end = FFTok_right_bracket
  481. if capture {
  482. ffl.Output.WriteByte('{')
  483. }
  484. } else {
  485. if capture {
  486. ffl.Output.WriteByte('[')
  487. }
  488. }
  489. depth := 1
  490. if capture {
  491. ffl.captureAll = true
  492. }
  493. // TODO: work.
  494. scanloop:
  495. for {
  496. tok := ffl.Scan()
  497. //fmt.Printf("capture-token: %v end: %v depth: %v\n", tok, end, depth)
  498. switch tok {
  499. case FFTok_eof:
  500. return nil, errors.New("ffjson: unexpected EOF")
  501. case FFTok_error:
  502. if ffl.BigError != nil {
  503. return nil, ffl.BigError
  504. }
  505. return nil, ffl.Error.ToError()
  506. case end:
  507. depth--
  508. if depth == 0 {
  509. break scanloop
  510. }
  511. case start:
  512. depth++
  513. }
  514. }
  515. if capture {
  516. ffl.captureAll = false
  517. }
  518. if capture {
  519. return ffl.Output.Bytes(), nil
  520. } else {
  521. return nil, nil
  522. }
  523. }
  524. case FFTok_bool,
  525. FFTok_integer,
  526. FFTok_null,
  527. FFTok_double:
  528. // simple value, return it.
  529. if capture {
  530. return ffl.Output.Bytes(), nil
  531. } else {
  532. return nil, nil
  533. }
  534. case FFTok_string:
  535. //TODO(pquerna): so, other users expect this to be a quoted string :(
  536. if capture {
  537. ffl.buf.Reset()
  538. WriteJson(&ffl.buf, ffl.Output.Bytes())
  539. return ffl.buf.Bytes(), nil
  540. } else {
  541. return nil, nil
  542. }
  543. default:
  544. return nil, fmt.Errorf("ffjson: invalid capture type: %v", start)
  545. }
  546. panic("not reached")
  547. }
  548. // Captures an entire field value, including recursive objects,
  549. // and converts them to a []byte suitable to pass to a sub-object's
  550. // UnmarshalJSON
  551. func (ffl *FFLexer) CaptureField(start FFTok) ([]byte, error) {
  552. return ffl.scanField(start, true)
  553. }
  554. func (ffl *FFLexer) SkipField(start FFTok) error {
  555. _, err := ffl.scanField(start, false)
  556. return err
  557. }
  558. // TODO(pquerna): return line number and offset.
  559. func (err FFErr) ToError() error {
  560. switch err {
  561. case FFErr_e_ok:
  562. return nil
  563. case FFErr_io:
  564. return errors.New("ffjson: IO error")
  565. case FFErr_string_invalid_utf8:
  566. return errors.New("ffjson: string with invalid UTF-8 sequence")
  567. case FFErr_string_invalid_escaped_char:
  568. return errors.New("ffjson: string with invalid escaped character")
  569. case FFErr_string_invalid_json_char:
  570. return errors.New("ffjson: string with invalid JSON character")
  571. case FFErr_string_invalid_hex_char:
  572. return errors.New("ffjson: string with invalid hex character")
  573. case FFErr_invalid_char:
  574. return errors.New("ffjson: invalid character")
  575. case FFErr_invalid_string:
  576. return errors.New("ffjson: invalid string")
  577. case FFErr_missing_integer_after_decimal:
  578. return errors.New("ffjson: missing integer after decimal")
  579. case FFErr_missing_integer_after_exponent:
  580. return errors.New("ffjson: missing integer after exponent")
  581. case FFErr_missing_integer_after_minus:
  582. return errors.New("ffjson: missing integer after minus")
  583. case FFErr_unallowed_comment:
  584. return errors.New("ffjson: unallowed comment")
  585. case FFErr_incomplete_comment:
  586. return errors.New("ffjson: incomplete comment")
  587. case FFErr_unexpected_token_type:
  588. return errors.New("ffjson: unexpected token sequence")
  589. }
  590. panic(fmt.Sprintf("unknown error type: %v ", err))
  591. }
  592. func (state FFParseState) String() string {
  593. switch state {
  594. case FFParse_map_start:
  595. return "map:start"
  596. case FFParse_want_key:
  597. return "want_key"
  598. case FFParse_want_colon:
  599. return "want_colon"
  600. case FFParse_want_value:
  601. return "want_value"
  602. case FFParse_after_value:
  603. return "after_value"
  604. }
  605. panic(fmt.Sprintf("unknown parse state: %d", int(state)))
  606. }
  607. func (tok FFTok) String() string {
  608. switch tok {
  609. case FFTok_init:
  610. return "tok:init"
  611. case FFTok_bool:
  612. return "tok:bool"
  613. case FFTok_colon:
  614. return "tok:colon"
  615. case FFTok_comma:
  616. return "tok:comma"
  617. case FFTok_eof:
  618. return "tok:eof"
  619. case FFTok_error:
  620. return "tok:error"
  621. case FFTok_left_brace:
  622. return "tok:left_brace"
  623. case FFTok_left_bracket:
  624. return "tok:left_bracket"
  625. case FFTok_null:
  626. return "tok:null"
  627. case FFTok_right_brace:
  628. return "tok:right_brace"
  629. case FFTok_right_bracket:
  630. return "tok:right_bracket"
  631. case FFTok_integer:
  632. return "tok:integer"
  633. case FFTok_double:
  634. return "tok:double"
  635. case FFTok_string:
  636. return "tok:string"
  637. case FFTok_comment:
  638. return "comment"
  639. }
  640. panic(fmt.Sprintf("unknown token: %d", int(tok)))
  641. }
  642. /* a lookup table which lets us quickly determine three things:
  643. * cVEC - valid escaped control char
  644. * note. the solidus '/' may be escaped or not.
  645. * cIJC - invalid json char
  646. * cVHC - valid hex char
  647. * cNFP - needs further processing (from a string scanning perspective)
  648. * cNUC - needs utf8 checking when enabled (from a string scanning perspective)
  649. */
  650. const (
  651. cVEC int8 = 0x01
  652. cIJC int8 = 0x02
  653. cVHC int8 = 0x04
  654. cNFP int8 = 0x08
  655. cNUC int8 = 0x10
  656. )
  657. var byteLookupTable [256]int8 = [256]int8{
  658. cIJC, /* 0 */
  659. cIJC, /* 1 */
  660. cIJC, /* 2 */
  661. cIJC, /* 3 */
  662. cIJC, /* 4 */
  663. cIJC, /* 5 */
  664. cIJC, /* 6 */
  665. cIJC, /* 7 */
  666. cIJC, /* 8 */
  667. cIJC, /* 9 */
  668. cIJC, /* 10 */
  669. cIJC, /* 11 */
  670. cIJC, /* 12 */
  671. cIJC, /* 13 */
  672. cIJC, /* 14 */
  673. cIJC, /* 15 */
  674. cIJC, /* 16 */
  675. cIJC, /* 17 */
  676. cIJC, /* 18 */
  677. cIJC, /* 19 */
  678. cIJC, /* 20 */
  679. cIJC, /* 21 */
  680. cIJC, /* 22 */
  681. cIJC, /* 23 */
  682. cIJC, /* 24 */
  683. cIJC, /* 25 */
  684. cIJC, /* 26 */
  685. cIJC, /* 27 */
  686. cIJC, /* 28 */
  687. cIJC, /* 29 */
  688. cIJC, /* 30 */
  689. cIJC, /* 31 */
  690. 0, /* 32 */
  691. 0, /* 33 */
  692. cVEC | cIJC | cNFP, /* 34 */
  693. 0, /* 35 */
  694. 0, /* 36 */
  695. 0, /* 37 */
  696. 0, /* 38 */
  697. 0, /* 39 */
  698. 0, /* 40 */
  699. 0, /* 41 */
  700. 0, /* 42 */
  701. 0, /* 43 */
  702. 0, /* 44 */
  703. 0, /* 45 */
  704. 0, /* 46 */
  705. cVEC, /* 47 */
  706. cVHC, /* 48 */
  707. cVHC, /* 49 */
  708. cVHC, /* 50 */
  709. cVHC, /* 51 */
  710. cVHC, /* 52 */
  711. cVHC, /* 53 */
  712. cVHC, /* 54 */
  713. cVHC, /* 55 */
  714. cVHC, /* 56 */
  715. cVHC, /* 57 */
  716. 0, /* 58 */
  717. 0, /* 59 */
  718. 0, /* 60 */
  719. 0, /* 61 */
  720. 0, /* 62 */
  721. 0, /* 63 */
  722. 0, /* 64 */
  723. cVHC, /* 65 */
  724. cVHC, /* 66 */
  725. cVHC, /* 67 */
  726. cVHC, /* 68 */
  727. cVHC, /* 69 */
  728. cVHC, /* 70 */
  729. 0, /* 71 */
  730. 0, /* 72 */
  731. 0, /* 73 */
  732. 0, /* 74 */
  733. 0, /* 75 */
  734. 0, /* 76 */
  735. 0, /* 77 */
  736. 0, /* 78 */
  737. 0, /* 79 */
  738. 0, /* 80 */
  739. 0, /* 81 */
  740. 0, /* 82 */
  741. 0, /* 83 */
  742. 0, /* 84 */
  743. 0, /* 85 */
  744. 0, /* 86 */
  745. 0, /* 87 */
  746. 0, /* 88 */
  747. 0, /* 89 */
  748. 0, /* 90 */
  749. 0, /* 91 */
  750. cVEC | cIJC | cNFP, /* 92 */
  751. 0, /* 93 */
  752. 0, /* 94 */
  753. 0, /* 95 */
  754. 0, /* 96 */
  755. cVHC, /* 97 */
  756. cVEC | cVHC, /* 98 */
  757. cVHC, /* 99 */
  758. cVHC, /* 100 */
  759. cVHC, /* 101 */
  760. cVEC | cVHC, /* 102 */
  761. 0, /* 103 */
  762. 0, /* 104 */
  763. 0, /* 105 */
  764. 0, /* 106 */
  765. 0, /* 107 */
  766. 0, /* 108 */
  767. 0, /* 109 */
  768. cVEC, /* 110 */
  769. 0, /* 111 */
  770. 0, /* 112 */
  771. 0, /* 113 */
  772. cVEC, /* 114 */
  773. 0, /* 115 */
  774. cVEC, /* 116 */
  775. 0, /* 117 */
  776. 0, /* 118 */
  777. 0, /* 119 */
  778. 0, /* 120 */
  779. 0, /* 121 */
  780. 0, /* 122 */
  781. 0, /* 123 */
  782. 0, /* 124 */
  783. 0, /* 125 */
  784. 0, /* 126 */
  785. 0, /* 127 */
  786. cNUC, /* 128 */
  787. cNUC, /* 129 */
  788. cNUC, /* 130 */
  789. cNUC, /* 131 */
  790. cNUC, /* 132 */
  791. cNUC, /* 133 */
  792. cNUC, /* 134 */
  793. cNUC, /* 135 */
  794. cNUC, /* 136 */
  795. cNUC, /* 137 */
  796. cNUC, /* 138 */
  797. cNUC, /* 139 */
  798. cNUC, /* 140 */
  799. cNUC, /* 141 */
  800. cNUC, /* 142 */
  801. cNUC, /* 143 */
  802. cNUC, /* 144 */
  803. cNUC, /* 145 */
  804. cNUC, /* 146 */
  805. cNUC, /* 147 */
  806. cNUC, /* 148 */
  807. cNUC, /* 149 */
  808. cNUC, /* 150 */
  809. cNUC, /* 151 */
  810. cNUC, /* 152 */
  811. cNUC, /* 153 */
  812. cNUC, /* 154 */
  813. cNUC, /* 155 */
  814. cNUC, /* 156 */
  815. cNUC, /* 157 */
  816. cNUC, /* 158 */
  817. cNUC, /* 159 */
  818. cNUC, /* 160 */
  819. cNUC, /* 161 */
  820. cNUC, /* 162 */
  821. cNUC, /* 163 */
  822. cNUC, /* 164 */
  823. cNUC, /* 165 */
  824. cNUC, /* 166 */
  825. cNUC, /* 167 */
  826. cNUC, /* 168 */
  827. cNUC, /* 169 */
  828. cNUC, /* 170 */
  829. cNUC, /* 171 */
  830. cNUC, /* 172 */
  831. cNUC, /* 173 */
  832. cNUC, /* 174 */
  833. cNUC, /* 175 */
  834. cNUC, /* 176 */
  835. cNUC, /* 177 */
  836. cNUC, /* 178 */
  837. cNUC, /* 179 */
  838. cNUC, /* 180 */
  839. cNUC, /* 181 */
  840. cNUC, /* 182 */
  841. cNUC, /* 183 */
  842. cNUC, /* 184 */
  843. cNUC, /* 185 */
  844. cNUC, /* 186 */
  845. cNUC, /* 187 */
  846. cNUC, /* 188 */
  847. cNUC, /* 189 */
  848. cNUC, /* 190 */
  849. cNUC, /* 191 */
  850. cNUC, /* 192 */
  851. cNUC, /* 193 */
  852. cNUC, /* 194 */
  853. cNUC, /* 195 */
  854. cNUC, /* 196 */
  855. cNUC, /* 197 */
  856. cNUC, /* 198 */
  857. cNUC, /* 199 */
  858. cNUC, /* 200 */
  859. cNUC, /* 201 */
  860. cNUC, /* 202 */
  861. cNUC, /* 203 */
  862. cNUC, /* 204 */
  863. cNUC, /* 205 */
  864. cNUC, /* 206 */
  865. cNUC, /* 207 */
  866. cNUC, /* 208 */
  867. cNUC, /* 209 */
  868. cNUC, /* 210 */
  869. cNUC, /* 211 */
  870. cNUC, /* 212 */
  871. cNUC, /* 213 */
  872. cNUC, /* 214 */
  873. cNUC, /* 215 */
  874. cNUC, /* 216 */
  875. cNUC, /* 217 */
  876. cNUC, /* 218 */
  877. cNUC, /* 219 */
  878. cNUC, /* 220 */
  879. cNUC, /* 221 */
  880. cNUC, /* 222 */
  881. cNUC, /* 223 */
  882. cNUC, /* 224 */
  883. cNUC, /* 225 */
  884. cNUC, /* 226 */
  885. cNUC, /* 227 */
  886. cNUC, /* 228 */
  887. cNUC, /* 229 */
  888. cNUC, /* 230 */
  889. cNUC, /* 231 */
  890. cNUC, /* 232 */
  891. cNUC, /* 233 */
  892. cNUC, /* 234 */
  893. cNUC, /* 235 */
  894. cNUC, /* 236 */
  895. cNUC, /* 237 */
  896. cNUC, /* 238 */
  897. cNUC, /* 239 */
  898. cNUC, /* 240 */
  899. cNUC, /* 241 */
  900. cNUC, /* 242 */
  901. cNUC, /* 243 */
  902. cNUC, /* 244 */
  903. cNUC, /* 245 */
  904. cNUC, /* 246 */
  905. cNUC, /* 247 */
  906. cNUC, /* 248 */
  907. cNUC, /* 249 */
  908. cNUC, /* 250 */
  909. cNUC, /* 251 */
  910. cNUC, /* 252 */
  911. cNUC, /* 253 */
  912. cNUC, /* 254 */
  913. cNUC, /* 255 */
  914. }