grammar.mjs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980
  1. var grammar = {
  2. Name: {
  3. token: 'Name'
  4. },
  5. String: {
  6. token: 'String'
  7. },
  8. BlockString: {
  9. token: 'BlockString'
  10. },
  11. Document: {
  12. listOfType: 'Definition'
  13. },
  14. Definition: {
  15. peek: [{
  16. ifCondition: {
  17. token: 'Name',
  18. oneOf: ['query', 'mutation', 'subscription']
  19. },
  20. expect: 'OperationDefinition'
  21. }, {
  22. ifCondition: {
  23. token: 'Name',
  24. ofValue: 'fragment'
  25. },
  26. expect: 'FragmentDefinition'
  27. }, {
  28. ifCondition: {
  29. token: 'Name',
  30. oneOf: ['schema', 'scalar', 'type', 'interface', 'union', 'enum', 'input', 'directive']
  31. },
  32. expect: 'TypeSystemDefinition'
  33. }, {
  34. ifCondition: {
  35. token: 'Name',
  36. ofValue: 'extend'
  37. },
  38. expect: 'TypeSystemExtension'
  39. }, {
  40. ifCondition: {
  41. token: '{'
  42. },
  43. expect: 'OperationDefinition'
  44. }, {
  45. ifCondition: 'String',
  46. expect: 'TypeSystemDefinition'
  47. }, {
  48. ifCondition: 'BlockString',
  49. expect: 'TypeSystemDefinition'
  50. }]
  51. },
  52. OperationDefinition: {
  53. peek: [{
  54. ifCondition: {
  55. token: '{'
  56. },
  57. expect: 'SelectionSet'
  58. }, {
  59. ifCondition: {
  60. token: 'Name',
  61. oneOf: ['query', 'mutation', 'subscription']
  62. },
  63. expect: ['OperationType', {
  64. token: 'Name',
  65. optional: true,
  66. tokenName: 'OperationName',
  67. definitionName: true
  68. }, {
  69. ofType: 'VariableDefinitions',
  70. optional: true
  71. }, {
  72. ofType: 'Directives',
  73. optional: true
  74. }, 'SelectionSet']
  75. }]
  76. },
  77. OperationType: {
  78. ofType: 'OperationTypeName'
  79. },
  80. OperationTypeName: {
  81. token: 'Name',
  82. oneOf: ['query', 'mutation', 'subscription'],
  83. definitionName: true
  84. },
  85. SelectionSet: [{
  86. token: '{'
  87. }, {
  88. listOfType: 'Selection'
  89. }, {
  90. token: '}'
  91. }],
  92. Selection: {
  93. peek: [{
  94. ifCondition: {
  95. token: '...'
  96. },
  97. expect: 'Fragment'
  98. }, {
  99. ifCondition: {
  100. token: 'Name'
  101. },
  102. expect: 'Field'
  103. }]
  104. },
  105. Field: [{
  106. ofType: 'Alias',
  107. optional: true,
  108. eatNextOnFail: true,
  109. definitionName: true
  110. }, {
  111. token: 'Name',
  112. tokenName: 'FieldName',
  113. definitionName: true
  114. }, {
  115. ofType: 'Arguments',
  116. optional: true
  117. }, {
  118. ofType: 'Directives',
  119. optional: true
  120. }, {
  121. ofType: 'SelectionSet',
  122. optional: true
  123. }],
  124. Arguments: [{
  125. token: '('
  126. }, {
  127. listOfType: 'Argument'
  128. }, {
  129. token: ')'
  130. }],
  131. Argument: [{
  132. token: 'Name',
  133. tokenName: 'ArgumentName',
  134. definitionName: true
  135. }, {
  136. token: ':'
  137. }, 'Value'],
  138. Alias: [{
  139. token: 'Name',
  140. tokenName: 'AliasName',
  141. definitionName: true
  142. }, {
  143. token: ':'
  144. }],
  145. Fragment: [{
  146. token: '...'
  147. }, {
  148. peek: [{
  149. ifCondition: 'FragmentName',
  150. expect: 'FragmentSpread'
  151. }, {
  152. ifCondition: {
  153. token: 'Name',
  154. ofValue: 'on'
  155. },
  156. expect: 'InlineFragment'
  157. }, {
  158. ifCondition: {
  159. token: '@'
  160. },
  161. expect: 'InlineFragment'
  162. }, {
  163. ifCondition: {
  164. token: '{'
  165. },
  166. expect: 'InlineFragment'
  167. }]
  168. }],
  169. FragmentSpread: ['FragmentName', {
  170. ofType: 'Directives',
  171. optional: true
  172. }],
  173. FragmentDefinition: [{
  174. token: 'Name',
  175. ofValue: 'fragment',
  176. tokenName: 'FragmentDefinitionKeyword'
  177. }, 'FragmentName', 'TypeCondition', {
  178. ofType: 'Directives',
  179. optional: true
  180. }, 'SelectionSet'],
  181. FragmentName: {
  182. token: 'Name',
  183. butNot: {
  184. token: 'Name',
  185. ofValue: 'on'
  186. },
  187. definitionName: true
  188. },
  189. TypeCondition: [{
  190. token: 'Name',
  191. ofValue: 'on',
  192. tokenName: 'OnKeyword'
  193. }, 'TypeName'],
  194. InlineFragment: [{
  195. ofType: 'TypeCondition',
  196. optional: true
  197. }, {
  198. ofType: 'Directives',
  199. optional: true
  200. }, 'SelectionSet'],
  201. Value: {
  202. peek: [{
  203. ifCondition: {
  204. token: '$'
  205. },
  206. expect: 'Variable'
  207. }, {
  208. ifCondition: 'IntValue',
  209. expect: {
  210. ofType: 'IntValue',
  211. tokenName: 'NumberValue'
  212. }
  213. }, {
  214. ifCondition: 'FloatValue',
  215. expect: {
  216. ofType: 'FloatValue',
  217. tokenName: 'NumberValue'
  218. }
  219. }, {
  220. ifCondition: 'BooleanValue',
  221. expect: {
  222. ofType: 'BooleanValue',
  223. tokenName: 'BooleanValue'
  224. }
  225. }, {
  226. ifCondition: 'EnumValue',
  227. expect: {
  228. ofType: 'EnumValue',
  229. tokenName: 'EnumValue'
  230. }
  231. }, {
  232. ifCondition: 'String',
  233. expect: {
  234. ofType: 'String',
  235. tokenName: 'StringValue'
  236. }
  237. }, {
  238. ifCondition: 'BlockString',
  239. expect: {
  240. ofType: 'BlockString',
  241. tokenName: 'StringValue'
  242. }
  243. }, {
  244. ifCondition: 'NullValue',
  245. expect: {
  246. ofType: 'NullValue',
  247. tokenName: 'NullValue'
  248. }
  249. }, {
  250. ifCondition: {
  251. token: '['
  252. },
  253. expect: 'ListValue'
  254. }, {
  255. ifCondition: {
  256. token: '{'
  257. },
  258. expect: 'ObjectValue'
  259. }]
  260. },
  261. ConstValue: {
  262. peek: [{
  263. ifCondition: 'IntValue',
  264. expect: {
  265. ofType: 'IntValue'
  266. }
  267. }, {
  268. ifCondition: 'FloatValue',
  269. expect: {
  270. ofType: 'FloatValue'
  271. }
  272. }, {
  273. ifCondition: 'BooleanValue',
  274. expect: 'BooleanValue'
  275. }, {
  276. ifCondition: 'EnumValue',
  277. expect: 'EnumValue'
  278. }, {
  279. ifCondition: 'String',
  280. expect: {
  281. ofType: 'String',
  282. tokenName: 'StringValue'
  283. }
  284. }, {
  285. ifCondition: 'BlockString',
  286. expect: {
  287. token: 'BlockString',
  288. tokenName: 'StringValue'
  289. }
  290. }, {
  291. ifCondition: 'NullValue',
  292. expect: 'NullValue'
  293. }, {
  294. ifCondition: {
  295. token: '['
  296. },
  297. expect: 'ConstListValue'
  298. }, {
  299. ifCondition: {
  300. token: '{'
  301. },
  302. expect: 'ObjectValue'
  303. }]
  304. },
  305. IntValue: {
  306. token: 'Int'
  307. },
  308. FloatValue: {
  309. token: 'Float'
  310. },
  311. StringValue: {
  312. peek: [{
  313. ifCondition: {
  314. token: 'String'
  315. },
  316. expect: {
  317. token: 'String',
  318. tokenName: 'StringValue'
  319. }
  320. }, {
  321. ifCondition: {
  322. token: 'BlockString'
  323. },
  324. expect: {
  325. token: 'BlockString',
  326. tokenName: 'StringValue'
  327. }
  328. }]
  329. },
  330. BooleanValue: {
  331. token: 'Name',
  332. oneOf: ['true', 'false'],
  333. tokenName: 'BooleanValue'
  334. },
  335. NullValue: {
  336. token: 'Name',
  337. ofValue: 'null',
  338. tokenName: 'NullValue'
  339. },
  340. EnumValue: {
  341. token: 'Name',
  342. butNot: {
  343. token: 'Name',
  344. oneOf: ['null', 'true', 'false']
  345. },
  346. tokenName: 'EnumValue'
  347. },
  348. ListValue: [{
  349. token: '['
  350. }, {
  351. listOfType: 'Value',
  352. optional: true
  353. }, {
  354. token: ']'
  355. }],
  356. ConstListValue: [{
  357. token: '['
  358. }, {
  359. listOfType: 'ConstValue',
  360. optional: true
  361. }, {
  362. token: ']'
  363. }],
  364. ObjectValue: [{
  365. token: '{'
  366. }, {
  367. listOfType: 'ObjectField',
  368. optional: true
  369. }, {
  370. token: '}'
  371. }],
  372. ObjectField: [{
  373. token: 'Name',
  374. tokenName: 'ObjectFieldName'
  375. }, {
  376. token: ':'
  377. }, {
  378. ofType: 'ConstValue'
  379. }],
  380. Variable: [{
  381. token: '$',
  382. tokenName: 'VariableName'
  383. }, {
  384. token: 'Name',
  385. tokenName: 'VariableName'
  386. }],
  387. VariableDefinitions: [{
  388. token: '('
  389. }, {
  390. listOfType: 'VariableDefinition'
  391. }, {
  392. token: ')'
  393. }],
  394. VariableDefinition: ['Variable', {
  395. token: ':'
  396. }, 'Type', {
  397. ofType: 'DefaultValue',
  398. optional: true
  399. }],
  400. DefaultValue: [{
  401. token: '='
  402. }, 'ConstValue'],
  403. TypeName: {
  404. token: 'Name',
  405. tokenName: 'TypeName',
  406. typeName: true
  407. },
  408. Type: {
  409. peek: [{
  410. ifCondition: {
  411. token: 'Name'
  412. },
  413. expect: ['TypeName', {
  414. token: '!',
  415. optional: true
  416. }]
  417. }, {
  418. ifCondition: {
  419. token: '['
  420. },
  421. expect: 'ListType'
  422. }]
  423. },
  424. ListType: [{
  425. token: '['
  426. }, {
  427. listOfType: 'Type'
  428. }, {
  429. token: ']'
  430. }, {
  431. token: '!',
  432. optional: true
  433. }],
  434. Directives: {
  435. listOfType: 'Directive'
  436. },
  437. Directive: [{
  438. token: '@',
  439. tokenName: 'DirectiveName'
  440. }, {
  441. token: 'Name',
  442. tokenName: 'DirectiveName'
  443. }, {
  444. ofType: 'Arguments',
  445. optional: true
  446. }],
  447. TypeSystemDefinition: [{
  448. ofType: 'Description',
  449. optional: true
  450. }, {
  451. peek: [{
  452. ifCondition: {
  453. target: 'Name',
  454. ofValue: 'schema'
  455. },
  456. expect: 'SchemaDefinition'
  457. }, {
  458. ifCondition: {
  459. target: 'Name',
  460. ofValue: 'scalar'
  461. },
  462. expect: 'ScalarTypeDefinition'
  463. }, {
  464. ifCondition: {
  465. target: 'Name',
  466. ofValue: 'type'
  467. },
  468. expect: 'ObjectTypeDefinition'
  469. }, {
  470. ifCondition: {
  471. target: 'Name',
  472. ofValue: 'interface'
  473. },
  474. expect: 'InterfaceTypeDefinition'
  475. }, {
  476. ifCondition: {
  477. target: 'Name',
  478. ofValue: 'union'
  479. },
  480. expect: 'UnionTypeDefinition'
  481. }, {
  482. ifCondition: {
  483. target: 'Name',
  484. ofValue: 'enum'
  485. },
  486. expect: 'EnumTypeDefinition'
  487. }, {
  488. ifCondition: {
  489. target: 'Name',
  490. ofValue: 'input'
  491. },
  492. expect: 'InputObjectTypeDefinition'
  493. }, {
  494. ifCondition: {
  495. target: 'Name',
  496. ofValue: 'directive'
  497. },
  498. expect: 'DirectiveDefinition'
  499. }]
  500. }],
  501. TypeSystemExtension: {
  502. peek: [{
  503. ifCondition: {
  504. target: 'Name',
  505. ofValue: 'schema'
  506. },
  507. expect: 'SchemaExtension'
  508. }, {
  509. ifCondition: {
  510. target: 'Name',
  511. ofValue: 'scalar'
  512. },
  513. expect: 'ScalarTypeExtension'
  514. }, {
  515. ifCondition: {
  516. target: 'Name',
  517. ofValue: 'type'
  518. },
  519. expect: 'ObjectTypeExtension'
  520. }, {
  521. ifCondition: {
  522. target: 'Name',
  523. ofValue: 'interface'
  524. },
  525. expect: 'InterfaceTypeExtension'
  526. }, {
  527. ifCondition: {
  528. target: 'Name',
  529. ofValue: 'union'
  530. },
  531. expect: 'UnionTypeExtension'
  532. }, {
  533. ifCondition: {
  534. target: 'Name',
  535. ofValue: 'enum'
  536. },
  537. expect: 'EnumTypeExtension'
  538. }, {
  539. ifCondition: {
  540. target: 'Name',
  541. ofValue: 'input'
  542. },
  543. expect: 'InputObjectTypeExtension'
  544. }]
  545. },
  546. SchemaDefinition: [{
  547. token: 'Name',
  548. ofValue: 'schema',
  549. tokenName: 'SchemaDefinitionKeyword'
  550. }, {
  551. ofType: 'Directives',
  552. optional: true
  553. }, {
  554. token: '{'
  555. }, {
  556. listOfType: 'RootOperationTypeDefinition'
  557. }, {
  558. token: '}'
  559. }],
  560. RootOperationTypeDefinition: ['OperationType', {
  561. token: ':'
  562. }, {
  563. token: 'Name',
  564. tokenName: 'OperationTypeDefinitionName'
  565. }],
  566. SchemaExtension: [{
  567. token: 'Name',
  568. ofValue: 'extend'
  569. }, {
  570. token: 'Name',
  571. ofValue: 'schema'
  572. }, 'Name', {
  573. peek: [{
  574. ifCondition: {
  575. token: '@'
  576. },
  577. expect: ['Directives', {
  578. ofType: [{
  579. token: '{'
  580. }, {
  581. listOfType: 'RootOperationTypeDefinition'
  582. }, {
  583. token: '}'
  584. }],
  585. optional: true
  586. }]
  587. }, {
  588. ifCondition: {
  589. token: '{'
  590. },
  591. expect: [{
  592. token: '{'
  593. }, {
  594. listOfType: 'RootOperationTypeDefinition'
  595. }, {
  596. token: '}'
  597. }]
  598. }]
  599. }],
  600. Description: 'StringValue',
  601. ScalarTypeDefinition: [{
  602. ofType: 'Description',
  603. optional: true
  604. }, {
  605. token: 'Name',
  606. ofValue: 'scalar',
  607. tokenName: 'ScalarDefinitionKeyword'
  608. }, 'TypeName', {
  609. ofType: 'Directives',
  610. optional: true
  611. }],
  612. ScalarTypeExtension: [{
  613. token: 'Name',
  614. ofValue: 'extend',
  615. tokenName: 'ExtendDefinitionKeyword'
  616. }, {
  617. token: 'Name',
  618. ofValue: 'scalar',
  619. tokenName: 'ScalarDefinitionKeyword'
  620. }, 'TypeName', 'Directives'],
  621. ObjectTypeDefinition: [{
  622. ofType: 'Description',
  623. optional: true
  624. }, {
  625. token: 'Name',
  626. ofValue: 'type',
  627. tokenName: 'TypeDefinitionKeyword'
  628. }, 'TypeName', {
  629. ofType: 'ImplementsInterfaces',
  630. optional: true
  631. }, {
  632. ofType: 'Directives',
  633. optional: true
  634. }, {
  635. ofType: 'FieldsDefinition',
  636. optional: true
  637. }],
  638. ImplementsInterfaces: [{
  639. token: 'Name',
  640. ofValue: 'implements',
  641. tokenName: 'ImplementsKeyword'
  642. }, {
  643. token: '&',
  644. optional: true
  645. }, 'TypeName', {
  646. listOfType: 'ImplementsAdditionalInterfaceName',
  647. optional: true
  648. }],
  649. ImplementsAdditionalInterfaceName: [{
  650. token: '&'
  651. }, 'TypeName'],
  652. FieldsDefinition: [{
  653. token: '{'
  654. }, {
  655. listOfType: 'FieldDefinition'
  656. }, {
  657. token: '}'
  658. }],
  659. FieldDefinition: [{
  660. ofType: 'Description',
  661. optional: true
  662. }, {
  663. token: 'Name',
  664. tokenName: 'AliasName',
  665. definitionName: true
  666. }, {
  667. ofType: 'ArgumentsDefinition',
  668. optional: true
  669. }, {
  670. token: ':'
  671. }, 'Type', {
  672. ofType: 'Directives',
  673. optional: true
  674. }],
  675. ArgumentsDefinition: [{
  676. token: '('
  677. }, {
  678. listOfType: 'InputValueDefinition'
  679. }, {
  680. token: ')'
  681. }],
  682. InputValueDefinition: [{
  683. ofType: 'Description',
  684. optional: true
  685. }, {
  686. token: 'Name',
  687. tokenName: 'ArgumentName'
  688. }, {
  689. token: ':'
  690. }, 'Type', {
  691. ofType: 'DefaultValue',
  692. optional: true
  693. }, {
  694. ofType: 'Directives',
  695. optional: true
  696. }],
  697. ObjectTypeExtension: [{
  698. token: 'Name',
  699. ofValue: 'extend',
  700. tokenName: 'ExtendDefinitionKeyword'
  701. }, {
  702. token: 'Name',
  703. ofValue: 'type',
  704. tokenName: 'TypeDefinitionKeyword'
  705. }, 'TypeName', {
  706. peek: [{
  707. ifCondition: {
  708. token: 'Name',
  709. ofValue: 'interface'
  710. },
  711. expect: ['ImplementsInterfaces', {
  712. peek: [{
  713. ifCondition: {
  714. token: '@'
  715. },
  716. expect: ['Directives', {
  717. ofType: 'FieldsDefinition',
  718. optional: true
  719. }]
  720. }, {
  721. ifCondition: {
  722. token: '{'
  723. },
  724. expect: 'FieldsDefinition'
  725. }],
  726. optional: true
  727. }]
  728. }, {
  729. ifCondition: {
  730. token: '@'
  731. },
  732. expect: ['Directives', {
  733. ofType: 'FieldsDefinition',
  734. optional: true
  735. }]
  736. }, {
  737. ifCondition: {
  738. token: '{'
  739. },
  740. expect: 'FieldsDefinition'
  741. }]
  742. }],
  743. InterfaceTypeDefinition: [{
  744. ofType: 'Description',
  745. optional: true
  746. }, {
  747. token: 'Name',
  748. ofValue: 'interface',
  749. tokenName: 'InterfaceDefinitionKeyword'
  750. }, 'TypeName', {
  751. ofType: 'Directives',
  752. optional: true
  753. }, {
  754. ofType: 'FieldsDefinition',
  755. optional: true
  756. }],
  757. InterfaceTypeExtension: [{
  758. token: 'Name',
  759. ofValue: 'extend',
  760. tokenName: 'ExtendDefinitionKeyword'
  761. }, {
  762. token: 'Name',
  763. ofValue: 'interface',
  764. tokenName: 'InterfaceDefinitionKeyword'
  765. }, 'TypeName', {
  766. peek: [{
  767. ifCondition: {
  768. token: '@'
  769. },
  770. expect: ['Directives', {
  771. ofType: 'FieldsDefinition',
  772. optional: true
  773. }]
  774. }, {
  775. ifCondition: {
  776. token: '{'
  777. },
  778. expect: 'FieldsDefinition'
  779. }]
  780. }],
  781. UnionTypeDefinition: [{
  782. ofType: 'Description',
  783. optional: true
  784. }, {
  785. token: 'Name',
  786. ofValue: 'union',
  787. tokenName: 'UnionDefinitionKeyword'
  788. }, 'TypeName', {
  789. ofType: 'Directives',
  790. optional: true
  791. }, {
  792. ofType: 'UnionMemberTypes',
  793. optional: true
  794. }],
  795. UnionMemberTypes: [{
  796. token: '='
  797. }, {
  798. token: '|',
  799. optional: true
  800. }, 'Name', {
  801. listOfType: 'UnionMemberAdditionalTypeName',
  802. optional: true
  803. }],
  804. UnionMemberAdditionalTypeName: [{
  805. token: '|'
  806. }, 'TypeName'],
  807. UnionTypeExtension: [{
  808. token: 'Name',
  809. ofValue: 'extend',
  810. tokenName: 'ExtendDefinitionKeyword'
  811. }, {
  812. token: 'Name',
  813. ofValue: 'union',
  814. tokenName: 'UnionDefinitionKeyword'
  815. }, 'TypeName', {
  816. peek: [{
  817. ifCondition: {
  818. token: '@'
  819. },
  820. expect: ['Directives', {
  821. ofType: 'UnionMemberTypes',
  822. optional: true
  823. }]
  824. }, {
  825. ifCondition: {
  826. token: '='
  827. },
  828. expect: 'UnionMemberTypes'
  829. }]
  830. }],
  831. EnumTypeDefinition: [{
  832. ofType: 'Description',
  833. optional: true
  834. }, {
  835. token: 'Name',
  836. ofValue: 'enum',
  837. tokenName: 'EnumDefinitionKeyword'
  838. }, 'TypeName', {
  839. ofType: 'Directives',
  840. optional: true
  841. }, {
  842. ofType: 'EnumValuesDefinition',
  843. optional: true
  844. }],
  845. EnumValuesDefinition: [{
  846. token: '{'
  847. }, {
  848. listOfType: 'EnumValueDefinition'
  849. }, {
  850. token: '}'
  851. }],
  852. EnumValueDefinition: [{
  853. ofType: 'Description',
  854. optional: true
  855. }, 'EnumValue', {
  856. ofType: 'Directives',
  857. optional: true
  858. }],
  859. EnumTypeExtension: [{
  860. token: 'Name',
  861. ofValue: 'extend',
  862. tokenName: 'ExtendDefinitionKeyword'
  863. }, {
  864. token: 'Name',
  865. ofValue: 'enum',
  866. tokenName: 'EnumDefinitionKeyword'
  867. }, 'TypeName', {
  868. peek: [{
  869. ifCondition: {
  870. token: '@'
  871. },
  872. expect: ['Directives', {
  873. ofType: 'EnumValuesDefinition',
  874. optional: true
  875. }]
  876. }, {
  877. ifCondition: {
  878. token: '{'
  879. },
  880. expect: 'EnumValuesDefinition'
  881. }]
  882. }],
  883. InputObjectTypeDefinition: [{
  884. ofType: 'Description',
  885. optional: true
  886. }, {
  887. token: 'Name',
  888. ofValue: 'input',
  889. tokenName: 'InputDefinitionKeyword'
  890. }, 'TypeName', {
  891. ofType: 'Directives',
  892. optional: true
  893. }, {
  894. ofType: 'InputFieldsDefinition',
  895. optional: true
  896. }],
  897. InputFieldsDefinition: [{
  898. token: '{'
  899. }, {
  900. listOfType: 'InputValueDefinition'
  901. }, {
  902. token: '}'
  903. }],
  904. InputObjectTypeExtension: [{
  905. token: 'Name',
  906. ofValue: 'extend',
  907. tokenName: 'ExtendDefinitionKeyword'
  908. }, {
  909. token: 'Name',
  910. ofValue: 'input',
  911. tokenName: 'InputDefinitionKeyword'
  912. }, 'TypeName', {
  913. peek: [{
  914. ifCondition: {
  915. token: '@'
  916. },
  917. expect: ['Directives', {
  918. ofType: 'InputFieldsDefinition',
  919. optional: true
  920. }]
  921. }, {
  922. ifCondition: {
  923. token: '{'
  924. },
  925. expect: 'InputFieldsDefinition'
  926. }]
  927. }],
  928. DirectiveDefinition: [{
  929. ofType: 'Description',
  930. optional: true
  931. }, {
  932. token: 'Name',
  933. ofValue: 'directive',
  934. tokenName: 'DirectiveDefinitionKeyword'
  935. }, {
  936. token: '@',
  937. tokenName: 'DirectiveName'
  938. }, {
  939. token: 'Name',
  940. tokenName: 'DirectiveName'
  941. }, {
  942. ofType: 'ArgumentsDefinition',
  943. optional: true
  944. }, {
  945. token: 'Name',
  946. ofValue: 'on',
  947. tokenName: 'OnKeyword'
  948. }, 'DirectiveLocations'],
  949. DirectiveLocations: [{
  950. token: '|',
  951. optional: true
  952. }, 'DirectiveLocation', {
  953. listOfType: 'DirectiveLocationAdditionalName',
  954. optional: true
  955. }],
  956. DirectiveLocationAdditionalName: [{
  957. token: '|'
  958. }, 'DirectiveLocation'],
  959. DirectiveLocation: {
  960. peek: [{
  961. ifCondition: 'ExecutableDirectiveLocation',
  962. expect: 'ExecutableDirectiveLocation'
  963. }, {
  964. ifCondition: 'TypeSystemDirectiveLocation',
  965. expect: 'TypeSystemDirectiveLocation'
  966. }]
  967. },
  968. ExecutableDirectiveLocation: {
  969. token: 'Name',
  970. oneOf: ['QUERY', 'MUTATION', 'SUBSCRIPTION', 'FIELD', 'FRAGMENT_DEFINITION', 'FRAGMENT_SPREAD', 'INLINE_FRAGMENT'],
  971. tokenName: 'EnumValue'
  972. },
  973. TypeSystemDirectiveLocation: {
  974. token: 'Name',
  975. oneOf: ['SCHEMA', 'SCALAR', 'OBJECT', 'FIELD_DEFINITION', 'ARGUMENT_DEFINITION', 'INTERFACE', 'UNION', 'ENUM', 'ENUM_VALUE', 'INPUT_OBJECT', 'INPUT_FIELD_DEFINITION'],
  976. tokenName: 'EnumValue'
  977. } // FIXME: enforce proper typing
  978. };
  979. export default grammar;