Require documentation on reader public items.
This commit is contained in:
@@ -8,13 +8,16 @@ use std::result;
|
|||||||
/// The location of a `Token` or `Error`.
|
/// The location of a `Token` or `Error`.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||||
pub struct Location {
|
pub struct Location {
|
||||||
|
/// Line number, starting from 1.
|
||||||
pub line_number: usize,
|
pub line_number: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A parse error is returned when the parse failed.
|
/// A parse error is returned when the parse failed.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Error {
|
pub struct Error {
|
||||||
|
/// Location of the error.
|
||||||
pub location: Location,
|
pub location: Location,
|
||||||
|
/// Error message.
|
||||||
pub message: String,
|
pub message: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,6 +27,7 @@ impl fmt::Display for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Result of a parser operation. The `Error` variant includes a location.
|
||||||
pub type Result<T> = result::Result<T, Error>;
|
pub type Result<T> = result::Result<T, Error>;
|
||||||
|
|
||||||
// Create an `Err` variant of `Result<X>` from a location and `format!` args.
|
// Create an `Err` variant of `Result<X>` from a location and `format!` args.
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
//! The cton_reader library supports reading .cton files. This functionality is needed for testing
|
//! The cton_reader library supports reading .cton files. This functionality is needed for testing
|
||||||
//! Cretonne, but is not essential for a JIT compiler.
|
//! Cretonne, but is not essential for a JIT compiler.
|
||||||
|
|
||||||
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
extern crate cretonne;
|
extern crate cretonne;
|
||||||
|
|
||||||
pub use error::{Location, Result, Error};
|
pub use error::{Location, Result, Error};
|
||||||
|
|||||||
@@ -14,19 +14,27 @@
|
|||||||
|
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
|
|
||||||
|
/// A command appearing in a test file.
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct TestCommand<'a> {
|
pub struct TestCommand<'a> {
|
||||||
|
/// The command name as a string.
|
||||||
pub command: &'a str,
|
pub command: &'a str,
|
||||||
|
/// The options following the command name.
|
||||||
pub options: Vec<TestOption<'a>>,
|
pub options: Vec<TestOption<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An option on a test command.
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub enum TestOption<'a> {
|
pub enum TestOption<'a> {
|
||||||
|
/// Single identifier flag: `foo`.
|
||||||
Flag(&'a str),
|
Flag(&'a str),
|
||||||
|
/// A value assigned to an identifier: `foo=bar`.
|
||||||
Value(&'a str, &'a str),
|
Value(&'a str, &'a str),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TestCommand<'a> {
|
impl<'a> TestCommand<'a> {
|
||||||
|
/// Create a new TestCommand by parsing `s`.
|
||||||
|
/// The returned command contains references into `s`.
|
||||||
pub fn new(s: &'a str) -> TestCommand<'a> {
|
pub fn new(s: &'a str) -> TestCommand<'a> {
|
||||||
let mut parts = s.split_whitespace();
|
let mut parts = s.split_whitespace();
|
||||||
let cmd = parts.next().unwrap_or("");
|
let cmd = parts.next().unwrap_or("");
|
||||||
@@ -48,6 +56,8 @@ impl<'a> Display for TestCommand<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TestOption<'a> {
|
impl<'a> TestOption<'a> {
|
||||||
|
/// Create a new TestOption by parsing `s`.
|
||||||
|
/// The returned option contains references into `s`.
|
||||||
pub fn new(s: &'a str) -> TestOption<'a> {
|
pub fn new(s: &'a str) -> TestOption<'a> {
|
||||||
match s.find('=') {
|
match s.find('=') {
|
||||||
None => TestOption::Flag(s),
|
None => TestOption::Flag(s),
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ pub struct TestFile<'a> {
|
|||||||
pub commands: Vec<TestCommand<'a>>,
|
pub commands: Vec<TestCommand<'a>>,
|
||||||
/// `isa bar ...` lines.
|
/// `isa bar ...` lines.
|
||||||
pub isa_spec: IsaSpec,
|
pub isa_spec: IsaSpec,
|
||||||
|
/// Parsed functions and additional details about each function.
|
||||||
pub functions: Vec<(Function, Details<'a>)>,
|
pub functions: Vec<(Function, Details<'a>)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,8 +29,12 @@ pub struct TestFile<'a> {
|
|||||||
/// The details to not affect the semantics of the function.
|
/// The details to not affect the semantics of the function.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Details<'a> {
|
pub struct Details<'a> {
|
||||||
|
/// Location of the `function` keyword that begins this function.
|
||||||
pub location: Location,
|
pub location: Location,
|
||||||
|
/// Annotation comments that appeared inside or after the function.
|
||||||
pub comments: Vec<Comment<'a>>,
|
pub comments: Vec<Comment<'a>>,
|
||||||
|
/// Mapping of source entity numbers to parsed entity numbers.
|
||||||
|
/// Source locations of parsed entities.
|
||||||
pub map: SourceMap,
|
pub map: SourceMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user