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, require_eof) ⇒ Object
- ._parse_signature(buffer, end_pos) ⇒ Object
- ._parse_type(buffer, start_pos, end_pos, variables, require_eof) ⇒ Object
- .buffer(source) ⇒ Object
- .parse_method_type(source, range: 0, variables: [], require_eof: false) ⇒ Object
- .parse_signature(source) ⇒ Object
- .parse_type(source, range: 0, variables: [], require_eof: false) ⇒ Object
Class Method Details
._parse_method_type(buffer, start_pos, end_pos, variables, require_eof) ⇒ Object
2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 |
# File 'ext/rbs_extension/parser.c', line 2757
static VALUE
rbsparser_parse_method_type(VALUE self, VALUE buffer, VALUE start_pos, VALUE end_pos, VALUE variables, VALUE require_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 (RB_TEST(require_eof)) {
parser_advance_assert(parser, pEOF);
}
free_parser(parser);
return method_type;
}
|
._parse_signature(buffer, end_pos) ⇒ Object
2777 2778 2779 2780 2781 2782 2783 2784 2785 |
# File 'ext/rbs_extension/parser.c', line 2777
static VALUE
rbsparser_parse_signature(VALUE self, VALUE buffer, VALUE end_pos)
{
parserstate *parser = alloc_parser(buffer, 0, FIX2INT(end_pos), Qnil);
VALUE pair = parse_signature(parser);
free_parser(parser);
return pair;
}
|
._parse_type(buffer, start_pos, end_pos, variables, require_eof) ⇒ Object
2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 |
# File 'ext/rbs_extension/parser.c', line 2737
static VALUE
rbsparser_parse_type(VALUE self, VALUE buffer, VALUE start_pos, VALUE end_pos, VALUE variables, VALUE require_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 (RB_TEST(require_eof)) {
parser_advance_assert(parser, pEOF);
}
free_parser(parser);
return type;
}
|
.buffer(source) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/rbs/parser_aux.rb', line 22 def self.buffer(source) case source when String Buffer.new(content: source, name: "a.rbs") when Buffer source end end |
.parse_method_type(source, range: 0, variables: [], require_eof: false) ⇒ Object
10 11 12 13 |
# File 'lib/rbs/parser_aux.rb', line 10 def self.parse_method_type(source, range: 0..., variables: [], require_eof: false) buf = buffer(source) _parse_method_type(buf, range.begin || 0, range.end || buf.last_position, variables, require_eof) end |
.parse_signature(source) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/rbs/parser_aux.rb', line 15 def self.parse_signature(source) buf = buffer(source) dirs, decls = _parse_signature(buf, buf.last_position) [buf, dirs, decls] end |
.parse_type(source, range: 0, variables: [], require_eof: false) ⇒ Object
5 6 7 8 |
# File 'lib/rbs/parser_aux.rb', line 5 def self.parse_type(source, range: 0..., variables: [], require_eof: false) buf = buffer(source) _parse_type(buf, range.begin || 0, range.end || buf.last_position, variables, require_eof) end |