Struct Parser
struct Parser<'a> {
arena: &'a Arena,
declarations: Vec<(&'a Name, usize)>,
depth: usize,
doc: DocBlock<'a>,
lexer: Lexer<'a>,
line_breaks: usize,
peeked: Option<Token<'a>>,
references: Vec<(&'a Name, usize)>,
}parse only.Expand description
Recursive descent parser for interface definitions.
Fields§
§arena: &'a Arena§declarations: Vec<(&'a Name, usize)>Names of the declarations with their offsets, to locate errors.
depth: usizeNesting level of the type being parsed.
doc: DocBlock<'a>§lexer: Lexer<'a>§line_breaks: usizeLine breaks since the last comment line or token.
peeked: Option<Token<'a>>§references: Vec<(&'a Name, usize)>References to types with their offsets, to locate errors.
Implementations§
§impl<'a> Parser<'a>
impl<'a> Parser<'a>
fn composite(&mut self) -> Result<Composite<'a>, ParseError>
fn enum_rest(
&mut self,
first: &'a FieldName,
first_doc: Option<&'a Doc>,
) -> Result<&'a [Variant<'a>], ParseError>
fn enum_rest( &mut self, first: &'a FieldName, first_doc: Option<&'a Doc>, ) -> Result<&'a [Variant<'a>], ParseError>
Parses the variants of an enum after the first one.
fn struct_rest(
&mut self,
first: &'a FieldName,
first_doc: Option<&'a Doc>,
) -> Result<&'a [Field<'a>], ParseError>
fn struct_rest( &mut self, first: &'a FieldName, first_doc: Option<&'a Doc>, ) -> Result<&'a [Field<'a>], ParseError>
Parses the fields of a struct after the type of the first one.
fn expect( &mut self, kind: Kind<'_>, expected: Expected, ) -> Result<(), ParseError>
fn field_name(&mut self) -> Result<&'a FieldName, ParseError>
fn fields(&mut self) -> Result<&'a [Field<'a>], ParseError>
fn fields(&mut self) -> Result<&'a [Field<'a>], ParseError>
Parses fields between parentheses, where an enum isn’t allowed.
fn interface(self) -> Result<Interface<'a>, ParseError>
fn list_continues(&mut self) -> Result<bool, ParseError>
fn list_continues(&mut self) -> Result<bool, ParseError>
Consumes a , and returns true, or consumes a ) and returns
false.
fn locate(&self, error: ValidationError<'_>) -> ParseError
fn locate(&self, error: ValidationError<'_>) -> ParseError
Turns a rule violation into an error at the name it refers to.
A duplicate declaration points at its second occurrence, an invalid reference at its first one.
fn member_name(&mut self) -> Result<&'a Name, ParseError>
fn member_name(&mut self) -> Result<&'a Name, ParseError>
Parses the name of a declaration and records where it is.
fn error_def( &mut self, doc: Option<&'a Doc>, ) -> Result<ErrorDef<'a>, ParseError>
fn method(&mut self, doc: Option<&'a Doc>) -> Result<Method<'a>, ParseError>
fn next_significant(&mut self) -> Option<Token<'a>>
fn next_significant(&mut self) -> Option<Token<'a>>
Returns the next token that isn’t a comment or a line break.
Comments and line breaks on the way update the doc block.
fn kind(&mut self) -> Result<TypeKind<'a>, ParseError>
fn kind(&mut self) -> Result<TypeKind<'a>, ParseError>
Parses the kind of a type.