Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/toml_parser/src/decoder/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 2 kB image not shown  

Quelle  ws.rs

  Sprache: Rust
 

use core::ops::RangeInclusive;

use winnow::stream::ContainsToken as _;

use crate::lexer::COMMENT_START_SYMBOL;
use crate::ErrorSink;
use crate::Expected;
use crate::ParseError;
use crate::Raw;
use crate::Span;

/// Parse comment
///
/// ```bnf
/// ;; Comment
///
/// comment-start-symbol = %x23 ; #
/// non-ascii = %x80-D7FF / %xE000-10FFFF
/// non-eol = %x09 / %x20-7F / non-ascii
///
/// comment = comment-start-symbol *non-eol
/// ```
pub(cratefn decode_comment(raw: Raw<'_>, error: &mut dyn ErrorSink) {
    let s = raw.as_bytes();

    if s.first() != Some(&COMMENT_START_SYMBOL) {
        error.report_error(
            ParseError::new("missing comment start")
                .with_context(Span::new_unchecked(0, raw.len()))
                .with_expected(&[Expected::Literal("#")])
                .with_unexpected(Span::new_unchecked(00)),
        );
    }

    for (i, b) in s.iter().copied().enumerate() {
        if !NON_EOL.contains_token(b) {
            error.report_error(
                ParseError::new("invalid comment character")
                    .with_context(Span::new_unchecked(0, raw.len()))
                    .with_expected(&[Expected::Description("printable characters")])
                    .with_unexpected(Span::new_unchecked(i, i)),
            );
        }
    }
}

// non-ascii = %x80-D7FF / %xE000-10FFFF
// - ASCII is 0xxxxxxx
// - First byte for UTF-8 is 11xxxxxx
// - Subsequent UTF-8 bytes are 10xxxxxx
pub(crateconst NON_ASCII: RangeInclusive<u8> = 0x80..=0xff;

// non-eol = %x09 / %x20-7E / non-ascii
pub(crateconst NON_EOL: (u8, RangeInclusive<u8>, RangeInclusive<u8>) =
    (0x09, 0x20..=0x7E, NON_ASCII);

/// Parse newline
///
/// ```bnf
///;; Newline
///
/// newline =  %x0A     ; LF
/// newline =/ %x0D.0A  ; CRLF
/// ```
pub(cratefn decode_newline(raw: Raw<'_>, error: &mut dyn ErrorSink) {
    let s = raw.as_str();

    if s == "\r" {
        error.report_error(
            ParseError::new("carriage return must be followed by newline")
                .with_context(Span::new_unchecked(0, raw.len()))
                .with_expected(&[Expected::Literal("\n")])
                .with_unexpected(Span::new_unchecked(raw.len(), raw.len())),
        );
    }
}

Messung V0.5 in Prozent
C=69 H=100 G=85

¤ Dauer der Verarbeitung: 0.24 Sekunden  (vorverarbeitet am  2026-08-25) ¤

*© 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.