Class: Synthra::Parser::AST::ProgramNode

Inherits:
Node
  • Object
show all
Defined in:
lib/synthra/parser/ast.rb

Overview

Program node - root of the AST

Contains all top-level definitions: schemas and APIs. This is the entry point for the parsed DSL.

Examples:

DSL

schema User:
  id: uuid

api GET /users:
  scenario Success:
    @status 200

AST

ProgramNode.new(
  schemas: [SchemaDefinitionNode.new(...)],
  apis: [ApiDefinitionNode.new(...)]
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schemas: [], apis: [], legacy_schemas: [], line: nil) ⇒ ProgramNode

Create a new ProgramNode

Parameters:

  • schemas (Array<SchemaDefinitionNode>) (defaults to: [])

    schema definitions

  • apis (Array<ApiDefinitionNode>) (defaults to: [])

    API definitions

  • legacy_schemas (Array<SchemaNode>) (defaults to: [])

    legacy schema definitions

  • line (Integer, nil) (defaults to: nil)

    source line number



748
749
750
751
752
753
# File 'lib/synthra/parser/ast.rb', line 748

def initialize(schemas: [], apis: [], legacy_schemas: [], line: nil)
  super(line: line)
  @schemas = schemas
  @apis = apis
  @legacy_schemas = legacy_schemas
end

Instance Attribute Details

#apisObject (readonly)

Returns the value of attribute apis.



732
733
734
# File 'lib/synthra/parser/ast.rb', line 732

def apis
  @apis
end

#legacy_schemasObject (readonly)

Returns the value of attribute legacy_schemas.



738
739
740
# File 'lib/synthra/parser/ast.rb', line 738

def legacy_schemas
  @legacy_schemas
end

#schemasObject (readonly)

Returns the value of attribute schemas.



726
727
728
# File 'lib/synthra/parser/ast.rb', line 726

def schemas
  @schemas
end

Instance Method Details

#all_schemasArray<SchemaDefinitionNode, SchemaNode>

Get all schema nodes (both new and legacy)

Returns:



760
761
762
# File 'lib/synthra/parser/ast.rb', line 760

def all_schemas
  schemas + legacy_schemas
end