Skip to main content

parse_file

Function parse_file 

Source
pub fn parse_file(
    text: &str,
    experimental: Experimental,
) -> (SourceKind, Result<Parsed, SyntaxError>)
Expand description

Classifies a file by its first token and parses it with the matching grammar.

A types file always starts with enum or const and a values file starts with one only as a part of a qualifier, as in const::Circle. A file with no tokens is treated as a types file, which is how it was handled before values files were supported. The kind is returned even when parsing fails.