Class: Kumi::Parser::SyntaxValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/kumi/parser/syntax_validator.rb

Overview

Validates Kumi DSL syntax using new parser

Instance Method Summary collapse

Instance Method Details

#first_error(text, source_file: '<input>') ⇒ Object



15
16
17
18
# File 'lib/kumi/parser/syntax_validator.rb', line 15

def first_error(text, source_file: '<input>')
  diagnostics = validate(text, source_file: source_file)
  diagnostics.empty? ? nil : diagnostics.first[:message]
end

#valid?(text, source_file: '<input>') ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/kumi/parser/syntax_validator.rb', line 11

def valid?(text, source_file: '<input>')
  validate(text, source_file: source_file).empty?
end

#validate(text, source_file: '<input>') ⇒ Object



7
8
9
# File 'lib/kumi/parser/syntax_validator.rb', line 7

def validate(text, source_file: '<input>')
  Kumi::Parser::Base.validate(text, source_file: source_file)
end