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



2403
2404
2405
2406
2407
2408
2409
2410
2411
# File 'ext/rbs_extension/parser.c', line 2403

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



2413
2414
2415
2416
2417
2418
2419
2420
2421
# File 'ext/rbs_extension/parser.c', line 2413

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



2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
# File 'ext/rbs_extension/parser.c', line 2390

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