Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  wat.rs

  Sprache: Rust
 

use crate::component::Component;
use crate::core::{Module, ModuleField, ModuleKind};
use crate::kw;
use crate::parser::{Parse, Parser, Result};
use crate::token::Span;

/// A `*.wat` file parser, or a parser for one parenthesized module.
///
/// This is the top-level type which you'll frequently parse when working with
/// this crate. A `*.wat` file is either one `module` s-expression or a sequence
/// of s-expressions that are module fields.
#[derive(Debug)]
#[allow(missing_docs)]
pub enum Wat<'a> {
    Module(Module<'a>),
    Component(Component<'a>),
}

impl Wat<'_> {
    /// Encodes this `Wat` to binary form. This calls either [`Module::encode`]
    /// or [`Component::encode`].
    pub fn encode(&mut self) -> std::result::Result<Vec<u8>, crate::Error> {
        crate::core::EncodeOptions::default().encode_wat(self)
    }

    /// Returns the defining span of this file.
    pub fn span(&self) -> Span {
        match self {
            Wat::Module(m) => m.span,
            Wat::Component(c) => c.span,
        }
    }
}

impl<'a> Parse<'a> for Wat<'a> {
    fn parse(parser: Parser<'a>) -> Result<Self> {
        if !parser.has_meaningful_tokens() {
            return Err(parser.error("expected at least one module field"));
        }

        parser.with_standard_annotations_registered(|parser| {
            let wat = if parser.peek2::<kw::module>()? {
                Wat::Module(parser.parens(|parser| parser.parse())?)
            } else if parser.peek2::<kw::component>()? {
                Wat::Component(parser.parens(|parser| parser.parse())?)
            } else {
                let fields = ModuleField::parse_remaining(parser)?;
                Wat::Module(Module {
                    span: Span { offset: 0 },
                    id: None,
                    name: None,
                    kind: ModuleKind::Text(fields),
                })
            };
            Ok(wat)
        })
    }
}

Messung V0.5 in Prozent
C=84 H=95 G=89

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002