urn.peg.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  1. package main
  2. //go:generate peg -switch -inline urn.peg
  3. import (
  4. "fmt"
  5. "math"
  6. "sort"
  7. "strconv"
  8. )
  9. const endSymbol rune = 1114112
  10. /* The rule types inferred from the grammar are below. */
  11. type pegRule uint8
  12. const (
  13. ruleUnknown pegRule = iota
  14. ruleURN
  15. ruleURN_PREFIX
  16. ruleNID
  17. ruleNSS
  18. ruleLET_NUM
  19. ruleLET_NUM_HYP
  20. ruleCHARS
  21. ruleTRANS
  22. ruleHEX
  23. ruleOTHER
  24. ruleRESERVED
  25. rulecolon
  26. ruleeot
  27. ruleupper
  28. rulelower
  29. rulenumber
  30. rulehyp
  31. ruleperc
  32. )
  33. var rul3s = [...]string{
  34. "Unknown",
  35. "URN",
  36. "URN_PREFIX",
  37. "NID",
  38. "NSS",
  39. "LET_NUM",
  40. "LET_NUM_HYP",
  41. "CHARS",
  42. "TRANS",
  43. "HEX",
  44. "OTHER",
  45. "RESERVED",
  46. "colon",
  47. "eot",
  48. "upper",
  49. "lower",
  50. "number",
  51. "hyp",
  52. "perc",
  53. }
  54. type token32 struct {
  55. pegRule
  56. begin, end uint32
  57. }
  58. func (t *token32) String() string {
  59. return fmt.Sprintf("\x1B[34m%v\x1B[m %v %v", rul3s[t.pegRule], t.begin, t.end)
  60. }
  61. type node32 struct {
  62. token32
  63. up, next *node32
  64. }
  65. func (node *node32) print(pretty bool, buffer string) {
  66. var print func(node *node32, depth int)
  67. print = func(node *node32, depth int) {
  68. for node != nil {
  69. for c := 0; c < depth; c++ {
  70. fmt.Printf(" ")
  71. }
  72. rule := rul3s[node.pegRule]
  73. quote := strconv.Quote(string(([]rune(buffer)[node.begin:node.end])))
  74. if !pretty {
  75. fmt.Printf("%v %v\n", rule, quote)
  76. } else {
  77. fmt.Printf("\x1B[34m%v\x1B[m %v\n", rule, quote)
  78. }
  79. if node.up != nil {
  80. print(node.up, depth+1)
  81. }
  82. node = node.next
  83. }
  84. }
  85. print(node, 0)
  86. }
  87. func (node *node32) Print(buffer string) {
  88. node.print(false, buffer)
  89. }
  90. func (node *node32) PrettyPrint(buffer string) {
  91. node.print(true, buffer)
  92. }
  93. type tokens32 struct {
  94. tree []token32
  95. }
  96. func (t *tokens32) Trim(length uint32) {
  97. t.tree = t.tree[:length]
  98. }
  99. func (t *tokens32) Print() {
  100. for _, token := range t.tree {
  101. fmt.Println(token.String())
  102. }
  103. }
  104. func (t *tokens32) AST() *node32 {
  105. type element struct {
  106. node *node32
  107. down *element
  108. }
  109. tokens := t.Tokens()
  110. var stack *element
  111. for _, token := range tokens {
  112. if token.begin == token.end {
  113. continue
  114. }
  115. node := &node32{token32: token}
  116. for stack != nil && stack.node.begin >= token.begin && stack.node.end <= token.end {
  117. stack.node.next = node.up
  118. node.up = stack.node
  119. stack = stack.down
  120. }
  121. stack = &element{node: node, down: stack}
  122. }
  123. if stack != nil {
  124. return stack.node
  125. }
  126. return nil
  127. }
  128. func (t *tokens32) PrintSyntaxTree(buffer string) {
  129. t.AST().Print(buffer)
  130. }
  131. func (t *tokens32) PrettyPrintSyntaxTree(buffer string) {
  132. t.AST().PrettyPrint(buffer)
  133. }
  134. func (t *tokens32) Add(rule pegRule, begin, end, index uint32) {
  135. if tree := t.tree; int(index) >= len(tree) {
  136. expanded := make([]token32, 2*len(tree))
  137. copy(expanded, tree)
  138. t.tree = expanded
  139. }
  140. t.tree[index] = token32{
  141. pegRule: rule,
  142. begin: begin,
  143. end: end,
  144. }
  145. }
  146. func (t *tokens32) Tokens() []token32 {
  147. return t.tree
  148. }
  149. type URN struct {
  150. Buffer string
  151. buffer []rune
  152. rules [19]func() bool
  153. parse func(rule ...int) error
  154. reset func()
  155. Pretty bool
  156. tokens32
  157. }
  158. func (p *URN) Parse(rule ...int) error {
  159. return p.parse(rule...)
  160. }
  161. func (p *URN) Reset() {
  162. p.reset()
  163. }
  164. type textPosition struct {
  165. line, symbol int
  166. }
  167. type textPositionMap map[int]textPosition
  168. func translatePositions(buffer []rune, positions []int) textPositionMap {
  169. length, translations, j, line, symbol := len(positions), make(textPositionMap, len(positions)), 0, 1, 0
  170. sort.Ints(positions)
  171. search:
  172. for i, c := range buffer {
  173. if c == '\n' {
  174. line, symbol = line+1, 0
  175. } else {
  176. symbol++
  177. }
  178. if i == positions[j] {
  179. translations[positions[j]] = textPosition{line, symbol}
  180. for j++; j < length; j++ {
  181. if i != positions[j] {
  182. continue search
  183. }
  184. }
  185. break search
  186. }
  187. }
  188. return translations
  189. }
  190. type parseError struct {
  191. p *URN
  192. max token32
  193. }
  194. func (e *parseError) Error() string {
  195. tokens, error := []token32{e.max}, "\n"
  196. positions, p := make([]int, 2*len(tokens)), 0
  197. for _, token := range tokens {
  198. positions[p], p = int(token.begin), p+1
  199. positions[p], p = int(token.end), p+1
  200. }
  201. translations := translatePositions(e.p.buffer, positions)
  202. format := "parse error near %v (line %v symbol %v - line %v symbol %v):\n%v\n"
  203. if e.p.Pretty {
  204. format = "parse error near \x1B[34m%v\x1B[m (line %v symbol %v - line %v symbol %v):\n%v\n"
  205. }
  206. for _, token := range tokens {
  207. begin, end := int(token.begin), int(token.end)
  208. error += fmt.Sprintf(format,
  209. rul3s[token.pegRule],
  210. translations[begin].line, translations[begin].symbol,
  211. translations[end].line, translations[end].symbol,
  212. strconv.Quote(string(e.p.buffer[begin:end])))
  213. }
  214. return error
  215. }
  216. func (p *URN) PrintSyntaxTree() {
  217. if p.Pretty {
  218. p.tokens32.PrettyPrintSyntaxTree(p.Buffer)
  219. } else {
  220. p.tokens32.PrintSyntaxTree(p.Buffer)
  221. }
  222. }
  223. func (p *URN) Init() {
  224. var (
  225. max token32
  226. position, tokenIndex uint32
  227. buffer []rune
  228. )
  229. p.reset = func() {
  230. max = token32{}
  231. position, tokenIndex = 0, 0
  232. p.buffer = []rune(p.Buffer)
  233. if len(p.buffer) == 0 || p.buffer[len(p.buffer)-1] != endSymbol {
  234. p.buffer = append(p.buffer, endSymbol)
  235. }
  236. buffer = p.buffer
  237. }
  238. p.reset()
  239. _rules := p.rules
  240. tree := tokens32{tree: make([]token32, math.MaxInt16)}
  241. p.parse = func(rule ...int) error {
  242. r := 1
  243. if len(rule) > 0 {
  244. r = rule[0]
  245. }
  246. matches := p.rules[r]()
  247. p.tokens32 = tree
  248. if matches {
  249. p.Trim(tokenIndex)
  250. return nil
  251. }
  252. return &parseError{p, max}
  253. }
  254. add := func(rule pegRule, begin uint32) {
  255. tree.Add(rule, begin, position, tokenIndex)
  256. tokenIndex++
  257. if begin != position && position > max.end {
  258. max = token32{rule, begin, position}
  259. }
  260. }
  261. matchDot := func() bool {
  262. if buffer[position] != endSymbol {
  263. position++
  264. return true
  265. }
  266. return false
  267. }
  268. /*matchChar := func(c byte) bool {
  269. if buffer[position] == c {
  270. position++
  271. return true
  272. }
  273. return false
  274. }*/
  275. /*matchRange := func(lower byte, upper byte) bool {
  276. if c := buffer[position]; c >= lower && c <= upper {
  277. position++
  278. return true
  279. }
  280. return false
  281. }*/
  282. _rules = [...]func() bool{
  283. nil,
  284. /* 0 URN <- <(URN_PREFIX NID colon NSS eot)> */
  285. func() bool {
  286. position0, tokenIndex0 := position, tokenIndex
  287. {
  288. position1 := position
  289. {
  290. position2 := position
  291. {
  292. position3, tokenIndex3 := position, tokenIndex
  293. if buffer[position] != rune('u') {
  294. goto l4
  295. }
  296. position++
  297. goto l3
  298. l4:
  299. position, tokenIndex = position3, tokenIndex3
  300. if buffer[position] != rune('U') {
  301. goto l0
  302. }
  303. position++
  304. }
  305. l3:
  306. {
  307. position5, tokenIndex5 := position, tokenIndex
  308. if buffer[position] != rune('r') {
  309. goto l6
  310. }
  311. position++
  312. goto l5
  313. l6:
  314. position, tokenIndex = position5, tokenIndex5
  315. if buffer[position] != rune('R') {
  316. goto l0
  317. }
  318. position++
  319. }
  320. l5:
  321. {
  322. position7, tokenIndex7 := position, tokenIndex
  323. if buffer[position] != rune('n') {
  324. goto l8
  325. }
  326. position++
  327. goto l7
  328. l8:
  329. position, tokenIndex = position7, tokenIndex7
  330. if buffer[position] != rune('N') {
  331. goto l0
  332. }
  333. position++
  334. }
  335. l7:
  336. if !_rules[rulecolon]() {
  337. goto l0
  338. }
  339. add(ruleURN_PREFIX, position2)
  340. }
  341. {
  342. position9 := position
  343. if !_rules[ruleLET_NUM]() {
  344. goto l0
  345. }
  346. {
  347. position10, tokenIndex10 := position, tokenIndex
  348. {
  349. position12 := position
  350. {
  351. position13, tokenIndex13 := position, tokenIndex
  352. if !_rules[ruleLET_NUM]() {
  353. goto l14
  354. }
  355. goto l13
  356. l14:
  357. position, tokenIndex = position13, tokenIndex13
  358. if !_rules[rulehyp]() {
  359. goto l10
  360. }
  361. }
  362. l13:
  363. add(ruleLET_NUM_HYP, position12)
  364. }
  365. goto l11
  366. l10:
  367. position, tokenIndex = position10, tokenIndex10
  368. }
  369. l11:
  370. add(ruleNID, position9)
  371. }
  372. if !_rules[rulecolon]() {
  373. goto l0
  374. }
  375. {
  376. position15 := position
  377. {
  378. position18 := position
  379. {
  380. position19, tokenIndex19 := position, tokenIndex
  381. {
  382. position21 := position
  383. {
  384. switch buffer[position] {
  385. case '#', '%', '/', '?':
  386. {
  387. position23 := position
  388. {
  389. switch buffer[position] {
  390. case '#':
  391. if buffer[position] != rune('#') {
  392. goto l20
  393. }
  394. position++
  395. break
  396. case '?':
  397. if buffer[position] != rune('?') {
  398. goto l20
  399. }
  400. position++
  401. break
  402. case '/':
  403. if buffer[position] != rune('/') {
  404. goto l20
  405. }
  406. position++
  407. break
  408. default:
  409. if !_rules[ruleperc]() {
  410. goto l20
  411. }
  412. break
  413. }
  414. }
  415. add(ruleRESERVED, position23)
  416. }
  417. break
  418. case '!', '$', '\'', '(', ')', '*', '+', ',', '-', '.', ':', ';', '=', '@', '_':
  419. {
  420. position25 := position
  421. {
  422. switch buffer[position] {
  423. case '\'':
  424. if buffer[position] != rune('\'') {
  425. goto l20
  426. }
  427. position++
  428. break
  429. case '*':
  430. if buffer[position] != rune('*') {
  431. goto l20
  432. }
  433. position++
  434. break
  435. case '!':
  436. if buffer[position] != rune('!') {
  437. goto l20
  438. }
  439. position++
  440. break
  441. case '_':
  442. if buffer[position] != rune('_') {
  443. goto l20
  444. }
  445. position++
  446. break
  447. case '$':
  448. if buffer[position] != rune('$') {
  449. goto l20
  450. }
  451. position++
  452. break
  453. case ';':
  454. if buffer[position] != rune(';') {
  455. goto l20
  456. }
  457. position++
  458. break
  459. case '@':
  460. if buffer[position] != rune('@') {
  461. goto l20
  462. }
  463. position++
  464. break
  465. case '=':
  466. if buffer[position] != rune('=') {
  467. goto l20
  468. }
  469. position++
  470. break
  471. case ':':
  472. if !_rules[rulecolon]() {
  473. goto l20
  474. }
  475. break
  476. case '.':
  477. if buffer[position] != rune('.') {
  478. goto l20
  479. }
  480. position++
  481. break
  482. case '-':
  483. if !_rules[rulehyp]() {
  484. goto l20
  485. }
  486. break
  487. case ',':
  488. if buffer[position] != rune(',') {
  489. goto l20
  490. }
  491. position++
  492. break
  493. case '+':
  494. if buffer[position] != rune('+') {
  495. goto l20
  496. }
  497. position++
  498. break
  499. case ')':
  500. if buffer[position] != rune(')') {
  501. goto l20
  502. }
  503. position++
  504. break
  505. default:
  506. if buffer[position] != rune('(') {
  507. goto l20
  508. }
  509. position++
  510. break
  511. }
  512. }
  513. add(ruleOTHER, position25)
  514. }
  515. break
  516. default:
  517. if !_rules[ruleLET_NUM]() {
  518. goto l20
  519. }
  520. break
  521. }
  522. }
  523. add(ruleTRANS, position21)
  524. }
  525. goto l19
  526. l20:
  527. position, tokenIndex = position19, tokenIndex19
  528. if !_rules[ruleperc]() {
  529. goto l0
  530. }
  531. if !_rules[ruleHEX]() {
  532. goto l0
  533. }
  534. if !_rules[ruleHEX]() {
  535. goto l0
  536. }
  537. }
  538. l19:
  539. add(ruleCHARS, position18)
  540. }
  541. l16:
  542. {
  543. position17, tokenIndex17 := position, tokenIndex
  544. {
  545. position27 := position
  546. {
  547. position28, tokenIndex28 := position, tokenIndex
  548. {
  549. position30 := position
  550. {
  551. switch buffer[position] {
  552. case '#', '%', '/', '?':
  553. {
  554. position32 := position
  555. {
  556. switch buffer[position] {
  557. case '#':
  558. if buffer[position] != rune('#') {
  559. goto l29
  560. }
  561. position++
  562. break
  563. case '?':
  564. if buffer[position] != rune('?') {
  565. goto l29
  566. }
  567. position++
  568. break
  569. case '/':
  570. if buffer[position] != rune('/') {
  571. goto l29
  572. }
  573. position++
  574. break
  575. default:
  576. if !_rules[ruleperc]() {
  577. goto l29
  578. }
  579. break
  580. }
  581. }
  582. add(ruleRESERVED, position32)
  583. }
  584. break
  585. case '!', '$', '\'', '(', ')', '*', '+', ',', '-', '.', ':', ';', '=', '@', '_':
  586. {
  587. position34 := position
  588. {
  589. switch buffer[position] {
  590. case '\'':
  591. if buffer[position] != rune('\'') {
  592. goto l29
  593. }
  594. position++
  595. break
  596. case '*':
  597. if buffer[position] != rune('*') {
  598. goto l29
  599. }
  600. position++
  601. break
  602. case '!':
  603. if buffer[position] != rune('!') {
  604. goto l29
  605. }
  606. position++
  607. break
  608. case '_':
  609. if buffer[position] != rune('_') {
  610. goto l29
  611. }
  612. position++
  613. break
  614. case '$':
  615. if buffer[position] != rune('$') {
  616. goto l29
  617. }
  618. position++
  619. break
  620. case ';':
  621. if buffer[position] != rune(';') {
  622. goto l29
  623. }
  624. position++
  625. break
  626. case '@':
  627. if buffer[position] != rune('@') {
  628. goto l29
  629. }
  630. position++
  631. break
  632. case '=':
  633. if buffer[position] != rune('=') {
  634. goto l29
  635. }
  636. position++
  637. break
  638. case ':':
  639. if !_rules[rulecolon]() {
  640. goto l29
  641. }
  642. break
  643. case '.':
  644. if buffer[position] != rune('.') {
  645. goto l29
  646. }
  647. position++
  648. break
  649. case '-':
  650. if !_rules[rulehyp]() {
  651. goto l29
  652. }
  653. break
  654. case ',':
  655. if buffer[position] != rune(',') {
  656. goto l29
  657. }
  658. position++
  659. break
  660. case '+':
  661. if buffer[position] != rune('+') {
  662. goto l29
  663. }
  664. position++
  665. break
  666. case ')':
  667. if buffer[position] != rune(')') {
  668. goto l29
  669. }
  670. position++
  671. break
  672. default:
  673. if buffer[position] != rune('(') {
  674. goto l29
  675. }
  676. position++
  677. break
  678. }
  679. }
  680. add(ruleOTHER, position34)
  681. }
  682. break
  683. default:
  684. if !_rules[ruleLET_NUM]() {
  685. goto l29
  686. }
  687. break
  688. }
  689. }
  690. add(ruleTRANS, position30)
  691. }
  692. goto l28
  693. l29:
  694. position, tokenIndex = position28, tokenIndex28
  695. if !_rules[ruleperc]() {
  696. goto l17
  697. }
  698. if !_rules[ruleHEX]() {
  699. goto l17
  700. }
  701. if !_rules[ruleHEX]() {
  702. goto l17
  703. }
  704. }
  705. l28:
  706. add(ruleCHARS, position27)
  707. }
  708. goto l16
  709. l17:
  710. position, tokenIndex = position17, tokenIndex17
  711. }
  712. add(ruleNSS, position15)
  713. }
  714. {
  715. position36 := position
  716. {
  717. position37, tokenIndex37 := position, tokenIndex
  718. if !matchDot() {
  719. goto l37
  720. }
  721. goto l0
  722. l37:
  723. position, tokenIndex = position37, tokenIndex37
  724. }
  725. add(ruleeot, position36)
  726. }
  727. add(ruleURN, position1)
  728. }
  729. return true
  730. l0:
  731. position, tokenIndex = position0, tokenIndex0
  732. return false
  733. },
  734. /* 1 URN_PREFIX <- <(('u' / 'U') ('r' / 'R') ('n' / 'N') colon)> */
  735. nil,
  736. /* 2 NID <- <(LET_NUM LET_NUM_HYP?)> */
  737. nil,
  738. /* 3 NSS <- <CHARS+> */
  739. nil,
  740. /* 4 LET_NUM <- <((&('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') number) | (&('a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z') lower) | (&('A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z') upper))> */
  741. func() bool {
  742. position41, tokenIndex41 := position, tokenIndex
  743. {
  744. position42 := position
  745. {
  746. switch buffer[position] {
  747. case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
  748. if !_rules[rulenumber]() {
  749. goto l41
  750. }
  751. break
  752. case 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z':
  753. {
  754. position44 := position
  755. if c := buffer[position]; c < rune('a') || c > rune('z') {
  756. goto l41
  757. }
  758. position++
  759. l45:
  760. {
  761. position46, tokenIndex46 := position, tokenIndex
  762. if c := buffer[position]; c < rune('a') || c > rune('z') {
  763. goto l46
  764. }
  765. position++
  766. goto l45
  767. l46:
  768. position, tokenIndex = position46, tokenIndex46
  769. }
  770. add(rulelower, position44)
  771. }
  772. break
  773. default:
  774. {
  775. position47 := position
  776. if c := buffer[position]; c < rune('A') || c > rune('Z') {
  777. goto l41
  778. }
  779. position++
  780. l48:
  781. {
  782. position49, tokenIndex49 := position, tokenIndex
  783. if c := buffer[position]; c < rune('A') || c > rune('Z') {
  784. goto l49
  785. }
  786. position++
  787. goto l48
  788. l49:
  789. position, tokenIndex = position49, tokenIndex49
  790. }
  791. add(ruleupper, position47)
  792. }
  793. break
  794. }
  795. }
  796. add(ruleLET_NUM, position42)
  797. }
  798. return true
  799. l41:
  800. position, tokenIndex = position41, tokenIndex41
  801. return false
  802. },
  803. /* 5 LET_NUM_HYP <- <(LET_NUM / hyp)> */
  804. nil,
  805. /* 6 CHARS <- <(TRANS / (perc HEX HEX))> */
  806. nil,
  807. /* 7 TRANS <- <((&('#' | '%' | '/' | '?') RESERVED) | (&('!' | '$' | '\'' | '(' | ')' | '*' | '+' | ',' | '-' | '.' | ':' | ';' | '=' | '@' | '_') OTHER) | (&('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z') LET_NUM))> */
  808. nil,
  809. /* 8 HEX <- <((&('a' | 'b' | 'c' | 'd' | 'e' | 'f') [a-f]+) | (&('A' | 'B' | 'C' | 'D' | 'E' | 'F') [A-F]+) | (&('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') number))> */
  810. func() bool {
  811. position53, tokenIndex53 := position, tokenIndex
  812. {
  813. position54 := position
  814. {
  815. switch buffer[position] {
  816. case 'a', 'b', 'c', 'd', 'e', 'f':
  817. if c := buffer[position]; c < rune('a') || c > rune('f') {
  818. goto l53
  819. }
  820. position++
  821. l56:
  822. {
  823. position57, tokenIndex57 := position, tokenIndex
  824. if c := buffer[position]; c < rune('a') || c > rune('f') {
  825. goto l57
  826. }
  827. position++
  828. goto l56
  829. l57:
  830. position, tokenIndex = position57, tokenIndex57
  831. }
  832. break
  833. case 'A', 'B', 'C', 'D', 'E', 'F':
  834. if c := buffer[position]; c < rune('A') || c > rune('F') {
  835. goto l53
  836. }
  837. position++
  838. l58:
  839. {
  840. position59, tokenIndex59 := position, tokenIndex
  841. if c := buffer[position]; c < rune('A') || c > rune('F') {
  842. goto l59
  843. }
  844. position++
  845. goto l58
  846. l59:
  847. position, tokenIndex = position59, tokenIndex59
  848. }
  849. break
  850. default:
  851. if !_rules[rulenumber]() {
  852. goto l53
  853. }
  854. break
  855. }
  856. }
  857. add(ruleHEX, position54)
  858. }
  859. return true
  860. l53:
  861. position, tokenIndex = position53, tokenIndex53
  862. return false
  863. },
  864. /* 9 OTHER <- <((&('\'') '\'') | (&('*') '*') | (&('!') '!') | (&('_') '_') | (&('$') '$') | (&(';') ';') | (&('@') '@') | (&('=') '=') | (&(':') colon) | (&('.') '.') | (&('-') hyp) | (&(',') ',') | (&('+') '+') | (&(')') ')') | (&('(') '('))> */
  865. nil,
  866. /* 10 RESERVED <- <((&('#') '#') | (&('?') '?') | (&('/') '/') | (&('%') perc))> */
  867. nil,
  868. /* 11 colon <- <':'> */
  869. func() bool {
  870. position62, tokenIndex62 := position, tokenIndex
  871. {
  872. position63 := position
  873. if buffer[position] != rune(':') {
  874. goto l62
  875. }
  876. position++
  877. add(rulecolon, position63)
  878. }
  879. return true
  880. l62:
  881. position, tokenIndex = position62, tokenIndex62
  882. return false
  883. },
  884. /* 12 eot <- <!.> */
  885. nil,
  886. /* 13 upper <- <[A-Z]+> */
  887. nil,
  888. /* 14 lower <- <[a-z]+> */
  889. nil,
  890. /* 15 number <- <[0-9]+> */
  891. func() bool {
  892. position67, tokenIndex67 := position, tokenIndex
  893. {
  894. position68 := position
  895. if c := buffer[position]; c < rune('0') || c > rune('9') {
  896. goto l67
  897. }
  898. position++
  899. l69:
  900. {
  901. position70, tokenIndex70 := position, tokenIndex
  902. if c := buffer[position]; c < rune('0') || c > rune('9') {
  903. goto l70
  904. }
  905. position++
  906. goto l69
  907. l70:
  908. position, tokenIndex = position70, tokenIndex70
  909. }
  910. add(rulenumber, position68)
  911. }
  912. return true
  913. l67:
  914. position, tokenIndex = position67, tokenIndex67
  915. return false
  916. },
  917. /* 16 hyp <- <'-'> */
  918. func() bool {
  919. position71, tokenIndex71 := position, tokenIndex
  920. {
  921. position72 := position
  922. if buffer[position] != rune('-') {
  923. goto l71
  924. }
  925. position++
  926. add(rulehyp, position72)
  927. }
  928. return true
  929. l71:
  930. position, tokenIndex = position71, tokenIndex71
  931. return false
  932. },
  933. /* 17 perc <- <'%'> */
  934. func() bool {
  935. position73, tokenIndex73 := position, tokenIndex
  936. {
  937. position74 := position
  938. if buffer[position] != rune('%') {
  939. goto l73
  940. }
  941. position++
  942. add(ruleperc, position74)
  943. }
  944. return true
  945. l73:
  946. position, tokenIndex = position73, tokenIndex73
  947. return false
  948. },
  949. }
  950. p.rules = _rules
  951. }