123456789_123456789_123456789_123456789_123456789_

Class: RBS::Parser

Relationships & Source Files
Namespace Children
Classes:
Inherits: Object
Defined in: lib/rbs/parser_aux.rb,
ext/rbs_extension/parser.c

Constant Summary

Class Method Summary

Class Method Details

._parse_method_type(buffer, start_pos, end_pos, variables, requires_eof)

[ GitHub ]

  
# File 'ext/rbs_extension/parser.c', line 2524

static VALUE
rbsparser_parse_method_type(VALUE self, VALUE buffer, VALUE start_pos, VALUE end_pos, VALUE variables, VALUE requires_eof)
{
  parserstate *parser = alloc_parser(buffer, FIX2INT(start_pos), FIX2INT(end_pos), variables);

  if (parser->next_token.type == pEOF) {
    return Qnil;
  }

  VALUE method_type = parse_method_type(parser);

  if (RTEST(requires_eof)) {
    parser_advance_assert(parser, pEOF);
  }

  free_parser(parser);

  return method_type;
}

._parse_signature(buffer, end_pos)

[ GitHub ]

  
# File 'ext/rbs_extension/parser.c', line 2544

static VALUE
rbsparser_parse_signature(VALUE self, VALUE buffer, VALUE end_pos)
{
  parserstate *parser = alloc_parser(buffer, 0, FIX2INT(end_pos), Qnil);
  VALUE signature = parse_signature(parser);
  free_parser(parser);

  return signature;
}

._parse_type(buffer, start_pos, end_pos, variables, requires_eof)

[ GitHub ]

  
# File 'ext/rbs_extension/parser.c', line 2504

static VALUE
rbsparser_parse_type(VALUE self, VALUE buffer, VALUE start_pos, VALUE end_pos, VALUE variables, VALUE requires_eof)
{
  parserstate *parser = alloc_parser(buffer, FIX2INT(start_pos), FIX2INT(end_pos), variables);

  if (parser->next_token.type == pEOF) {
    return Qnil;
  }

  VALUE type = parse_type(parser);

  if (RTEST(requires_eof)) {
    parser_advance_assert(parser, pEOF);
  }

  free_parser(parser);

  return type;
}

.buffer(source)

[ GitHub ]

  
# File 'lib/rbs/parser_aux.rb', line 20

def self.buffer(source)
  case source
  when String
    Buffer.new(content: source, name: "a.rbs")
  when Buffer
    source
  end
end

.parse_method_type(source, line: nil, column: nil, range: nil, variables: [])

[ GitHub ]

  
# File 'lib/rbs/parser_aux.rb', line 10

def self.parse_method_type(source, line: nil, column: nil, range: nil, variables: [])
  buf = buffer(source)
  _parse_method_type(buf, range&.begin || 0, range&.end || buf.last_position, variables, range.nil?)
end

.parse_signature(source, line: nil, column: nil)

[ GitHub ]

  
# File 'lib/rbs/parser_aux.rb', line 15

def self.parse_signature(source, line: nil, column: nil)
  buf = buffer(source)
  _parse_signature(buf, buf.last_position)
end

.parse_type(source, line: nil, column: nil, range: nil, variables: [])

[ GitHub ]

  
# File 'lib/rbs/parser_aux.rb', line 5

def self.parse_type(source, line: nil, column: nil, range: nil, variables: [])
  buf = buffer(source)
  _parse_type(buf, range&.begin || 0, range&.end || buf.last_position, variables, range.nil?)
end