Class: RBS::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs/parser_aux.rb,
ext/rbs_extension/parser.c

Defined Under Namespace

Classes: LocatedValue

Constant Summary collapse

KEYWORDS =
%w(
bool
bot
class
instance
interface
nil
self
singleton
top
void
type
unchecked
in
out
end
def
include
extend
prepend
alias
module
attr_reader
attr_writer
attr_accessor
public
private
untyped
true
false
).each_with_object({}) do |keyword, hash|
  hash[keyword] = nil
end
LexerError =
RBS::ParsingError
SyntaxError =
RBS::ParsingError
SemanticsError =
RBS::ParsingError

Class Method Summary collapse

Class Method Details

._parse_method_type(buffer, line, column, variables) ⇒ Object



2479
2480
2481
2482
2483
2484
2485
2486
2487
# File 'ext/rbs_extension/parser.c', line 2479

static VALUE
rbsparser_parse_method_type(VALUE self, VALUE buffer, VALUE line, VALUE column, VALUE variables)
{
  parserstate *parser = alloc_parser(buffer, FIX2INT(line), FIX2INT(column), variables);
  VALUE method_type = parse_method_type(parser);
  free(parser);

  return method_type;
}

._parse_signature(buffer, line, column) ⇒ Object



2489
2490
2491
2492
2493
2494
2495
2496
2497
# File 'ext/rbs_extension/parser.c', line 2489

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

  return signature;
}

._parse_type(buffer, line, column, variables) ⇒ Object



2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
# File 'ext/rbs_extension/parser.c', line 2466

static VALUE
rbsparser_parse_type(VALUE self, VALUE buffer, VALUE line, VALUE column, VALUE variables)
{
  parserstate *parser = alloc_parser(buffer, FIX2INT(line), FIX2INT(column), variables);

  VALUE type = parse_type(parser);
  parser_advance_assert(parser, pEOF);

  free_parser(parser);

  return type;
}

.buffer(source) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/rbs/parser_aux.rb', line 15

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: 1, column: 0, variables: []) ⇒ Object



7
8
9
# File 'lib/rbs/parser_aux.rb', line 7

def self.parse_method_type(source, line: 1, column: 0, variables: [])
  _parse_method_type(buffer(source), line, column, variables)
end

.parse_signature(source, line: 1, column: 0) ⇒ Object



11
12
13
# File 'lib/rbs/parser_aux.rb', line 11

def self.parse_signature(source, line: 1, column: 0)
  _parse_signature(buffer(source), line, column)
end

.parse_type(source, line: 1, column: 0, variables: []) ⇒ Object



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

def self.parse_type(source, line: 1, column: 0, variables: [])
  _parse_type(buffer(source), line, column, variables)
end