Parser

Struct Parser 

Source
pub struct Parser<'a> {
    pub filename: &'a str,
    pub source: &'a str,
    pub diagnostics: Vec<Diagnostic<()>>,
    /* private fields */
}
Expand description

A Parser struct that takes an input string, tokenizes it and parses it into a more or less readable AST tree.

Fields§

§filename: &'a str

The name of the input file that is being parsed. This property helps make more precise diagnostic messages, by providing the name of the file that the diagnostic originated from.

§source: &'a str

The string of Flycatcher input that is tokenized and parsed by the parser. The source is also used to emit code snippets in diagnostic messages.

§diagnostics: Vec<Diagnostic<()>>

A list of diagnostics that were created during parsing. These are not logged to the console by the parser, so they can be used to recieve information for IDEs and such.

Implementations§

Source§

impl<'a> Parser<'a>

Source

pub fn new(filename: &'a str, source: &'a str) -> Self

Allocates a new parser object. This does not start the parsing process, it only initializes a lexer and parser and returns the parser.

§Arguments
  • filename: The absolute file path to the file being parsed, if any. If you don’t have an actual file to put here, put @anonymous.
  • source: The string that will be tokenized and parsed by the parser that is allocated by this function.
Source

pub fn parse_expression(&mut self) -> Result<AstMeta, ErrorKind>

Parses a single expression from the lexer, returning a single AST object that represents it, or an ErrorKind enum object describing how it ended. If Err(ErrorKind::EndOfFile) was returned, that only means that there was no expression left, not that an actual error occurred.

Source

pub fn parse(&mut self) -> Result<Vec<AstMeta>, ErrorKind>

Iterates through all tokens until there is no tokens left to read. This will return all of the AST items found while parsing, if no errors occur.

Auto Trait Implementations§

§

impl<'a> Freeze for Parser<'a>

§

impl<'a> RefUnwindSafe for Parser<'a>

§

impl<'a> Send for Parser<'a>

§

impl<'a> Sync for Parser<'a>

§

impl<'a> Unpin for Parser<'a>

§

impl<'a> UnwindSafe for Parser<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.