Class: RBS::Parser
- Inherits:
-
Object
- Object
- RBS::Parser
- 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
- ._parse_method_type(buffer, start_pos, end_pos, variables, requires_eof) ⇒ Object
- ._parse_signature(buffer, end_pos) ⇒ Object
- ._parse_type(buffer, start_pos, end_pos, variables, requires_eof) ⇒ Object
- .buffer(source) ⇒ Object
- .parse_method_type(source, line: nil, column: nil, range: nil, variables: []) ⇒ Object
- .parse_signature(source, line: nil, column: nil) ⇒ Object
- .parse_type(source, line: nil, column: nil, range: nil, variables: []) ⇒ Object
Class Method Details
._parse_method_type(buffer, start_pos, end_pos, variables, requires_eof) ⇒ Object
2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 |
# 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) ⇒ Object
2544 2545 2546 2547 2548 2549 2550 2551 2552 |
# 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) ⇒ Object
2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 |
# 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) ⇒ Object
20 21 22 23 24 25 26 27 |
# 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: []) ⇒ Object
10 11 12 13 |
# 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) ⇒ Object
15 16 17 18 |
# 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: []) ⇒ Object
5 6 7 8 |
# 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 |