Class: Tina4::GraphQLParser
- Inherits:
-
Object
- Object
- Tina4::GraphQLParser
- Defined in:
- lib/tina4/graphql.rb
Overview
─── Parser (recursive descent) ──────────────────────────────────────
Defined Under Namespace
Classes: Token
Constant Summary collapse
- KEYWORDS =
%w[query mutation fragment on true false null].freeze
Instance Method Summary collapse
-
#initialize(source) ⇒ GraphQLParser
constructor
A new instance of GraphQLParser.
- #parse ⇒ Object
Constructor Details
#initialize(source) ⇒ GraphQLParser
Returns a new instance of GraphQLParser.
211 212 213 214 215 |
# File 'lib/tina4/graphql.rb', line 211 def initialize(source) @source = source @tokens = tokenize(source) @pos = 0 end |
Instance Method Details
#parse ⇒ Object
217 218 219 220 221 222 223 224 225 |
# File 'lib/tina4/graphql.rb', line 217 def parse document = { kind: :document, definitions: [] } while current skip(:comma) break unless current document[:definitions] << parse_definition end document end |