Skip to main content

Parser

Struct Parser 

Source
pub struct Parser<'a, S: TokenSource> {
    pub function_call_count: usize,
    pub deref_count: usize,
    /* private fields */
}
Expand description

パーサー

汎用のトークンソースからC言語をパースする。 STokenSource トレイトを実装する任意の型。

Fields§

§function_call_count: usize

パース中に検出した関数呼び出しの数

§deref_count: usize

パース中に検出したポインタデリファレンスの数

Implementations§

Source§

impl<'a> Parser<'a, Preprocessor>

Preprocessor 専用の後方互換コンストラクタ

Source

pub fn new(pp: &'a mut Preprocessor) -> Result<Self>

新しいパーサーを作成(Preprocessor専用)

Source

pub fn parse_each<F>(&mut self, callback: F) -> Result<()>

ストリーミング形式でパース

各宣言をパースするたびにコールバックを呼び出す。 パースエラーが発生した場合はコールバックを呼ばずにエラーを返す。 コールバックが ControlFlow::Break(()) を返した場合はループを終了。

Source

pub fn parse_each_with_pp<F>(&mut self, callback: F) -> Result<()>

ストリーミング形式でパース(Preprocessor アクセス付き)

parse_each と同様だが、コールバックに Preprocessor への可変参照も渡す。 マクロ呼び出しコールバック(MacroCallWatcher など)にアクセスする場合に使用。 パースエラーが発生した場合はコールバックを呼ばずにエラーを返す。

Source§

impl<'a, S: TokenSource> Parser<'a, S>

汎用のトークンソースに対するパーサー実装

Source

pub fn from_source(source: &'a mut S) -> Result<Self>

トークンソースからパーサーを作成

Source

pub fn from_source_with_typedefs( source: &'a mut S, typedefs: HashSet<InternedStr>, ) -> Result<Self>

トークンソースからパーサーを作成(既存のtypedef情報を引き継ぐ)

Source

pub fn set_handle_macro_markers(&mut self, enabled: bool) -> Result<()>

マクロマーカー処理を有効にする

Note: 既に current にマーカートークンがある場合はスキップする

Source

pub fn interner(&self) -> &StringInterner

StringInterner への参照を取得

Source

pub fn typedefs(&self) -> &HashSet<InternedStr>

typedef名のセットを取得

Source

pub fn parse(&mut self) -> Result<TranslationUnit>

翻訳単位をパース

Source

pub fn parse_expr_only(&mut self) -> Result<Expr>

式のみをパース

マクロ本体など、式だけをパースしたい場合に使用

Source

pub fn parse_stmt_allow_missing_semi(&mut self) -> Result<Stmt>

文をパース(末尾セミコロン省略可能)

マクロ body のパースなど、do-while の末尾セミコロンが 省略されている場合に使用する。

Source

pub fn parse_type_name(&mut self) -> Result<TypeName>

型名をパース

Source

pub fn make_node_info(&self, loc: SourceLocation) -> NodeInfo

現在のマクロコンテキストから NodeInfo を作成

Source

pub fn is_in_macro(&self) -> bool

現在マクロ展開中かどうか

Source

pub fn macro_depth(&self) -> usize

マクロ展開の深さ

Auto Trait Implementations§

§

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

§

impl<'a, S> RefUnwindSafe for Parser<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> Send for Parser<'a, S>
where S: Send,

§

impl<'a, S> Sync for Parser<'a, S>
where S: Sync,

§

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

§

impl<'a, S> UnsafeUnpin for Parser<'a, S>

§

impl<'a, S> !UnwindSafe for Parser<'a, S>

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.