Functions
The following functions are available globally.
-
Stops the program, indicating that source program uses a feature that has not yet been implemented.
Declaration
Swift
public func UNIMPLEMENTED( _ message: @autoclosure () -> String = "not implemented", file: StaticString = #filePath, line: UInt = #line ) -> Never -
Causes a fatal error reporting an unexpected
n, wherenis a node innodes.Declaration
Swift
public func unexpected<ID: NodeIDProtocol>( _ n: ID, in nodes: AST, file: StaticString = #filePath, line: UInt = #line ) -> Never
-
Returns a parser that consumes an element equal to
sand returns.some(s), or returns.some(nil)if such an element can’t be consumed.Declaration
Swift
private func maybe(_ s: String) -> BuiltinFunctionParser<String?> -
Returns a parser that consumes and returns an element equal to
s.Declaration
Swift
private func exactly(_ s: String) -> BuiltinFunctionParser<String> -
Returns a parser that returns the result of applying
aand thenbornilif eitheraorbreturnsnil.Declaration
Swift
private func ++ <A: Sendable, B: Sendable>( _ a: @escaping BuiltinFunctionParser<A>, _ b: @escaping BuiltinFunctionParser<B> ) -> BuiltinFunctionParser<(A, B)> -
Returns a parser that returns an instance of
Tif it can be built by consuming the next element in the stream.Declaration
Swift
private func take<T: RawRepresentable & SendableMetatype>( _: T.Type ) -> BuiltinFunctionParser<T> where T.RawValue == String -
Returns a built-in type parsed from
stream.Declaration
Swift
@Sendable private func builtinType(_ stream: inout ArraySlice<Substring>) -> BuiltinType? -
Returns the longest sequence of floating-point math flags that can be parsed from
stream.Declaration
Swift
@Sendable private func mathFlags(_ stream: inout ArraySlice<Substring>) -> BuiltinFunction.MathFlags -
Returns an overflow behavior parsed from
streamor.ignoreif none can be parsed.Declaration
Swift
@Sendable private func overflowBehavior( _ stream: inout ArraySlice<Substring> ) -> OverflowBehavior -
Parses the parameters and type of an integer arithmetic instruction with overflow reporting.
Declaration
Swift
private func integerArithmeticWithOverflowTail( _ stream: inout ArraySlice<Substring> ) -> BuiltinType? -
Creates a combinator that parses tokens with the specified kind.
-
Creates a combinator that parses name tokens with the specified value.
Declaration
Swift
private func take(nameTokenWithValue value: String) -> Apply<ParserState, Token> -
Creates a combinator that parses attribute tokens with the specified name.
Declaration
Swift
private func attribute(_ name: String) -> Apply<ParserState, Token> -
Creates a combinator that translates token kinds to instances of type.
Declaration
Swift
private func translate<T: Sendable>( _ table: [Token.Kind: T] ) -> Apply<ParserState, SourceRepresentable<T>> -
Creates a combinator that pushes
contextto the parser state before applying, and pops that context afterward.Declaration
Swift
private func inContext<Base: Combinator>( _ context: ParserState.Context, apply base: Base ) -> WrapInContext<Base> -
Creates a combinator that applies
baseonly if its input is not preceded by whitespaces.Declaration
Swift
private func withoutLeadingWhitespace<Base: Combinator>( _ base: Base ) -> Apply<ParserState, Base.Element> where Base.Context == ParserState -
Creates a combinator that applies
baseonly if its input is not preceded by newlines.Declaration
Swift
private func onSameLine<Base: Combinator>( _ base: Base ) -> Apply<ParserState, Base.Element> where Base.Context == ParserState -
Given a collection of file and directory paths as specified on the hc command line, returns the actual source files to process.
Paths of files in
sourcePathsare unconditionally treated as Hylo source files. Paths of directories are recursively searched for.hylofiles, which are considered Hylo source files; all others are treated as non-source files and are ignored.Declaration
Swift
public func sourceFiles<S>(in sourcePaths: S) throws -> [SourceFile] where S : Sequence, S.Element == URL -
Returns the source source files in
directory.directoryis recursively searched for files with extensione; all others are treated as non-source files and are ignored. Ifdirectoryis a filename, the function returns[].Declaration
Swift
public func sourceFiles(in directory: URL, withExtension e: String) throws -> [SourceFile] -
Creates a type-erased container wrapping the given instance.
Declaration
Swift
public prefix func ^ <T>(base: T) -> AnyTerm where T : TermProtocol -
Creates a constraint, suitable for type inference, requiring
subtypeto be a subtype ofsupertype.Warning
For inference purposes, the result of this function must be used in place of a rawSubtypingConstraintor the type checker will get stuck.Declaration
Swift
private func inferenceConstraint( _ subtype: AnyType, isSubtypeOf supertype: AnyType, origin: ConstraintOrigin ) -> Constraint -
Creates a type-erased container wrapping the given instance.
Declaration
Swift
public prefix func ^ <T>(base: T) -> AnyType where T : TypeProtocol -
Returns
trueifflhsmatches an argument list labeled byrhs.Declaration
Swift
private func accepts<S: Collection>( _ lhs: ArraySlice<CallableTypeParameter>, _ rhs: S ) -> Bool where S.Element == String? -
Just like Swift.precondition, but includes the full file path in the diagnostic.
Declaration
Swift
func precondition( _ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String = String(), file: StaticString = #filePath, line: UInt = #line ) -
Just like Swift.preconditionFailure, but includes the full file path in the diagnostic.
Declaration
Swift
func preconditionFailure( _ message: @autoclosure () -> String = String(), file: StaticString = #filePath, line: UInt = #line ) -> Never -
Just like Swift.fatalError, but includes the full file path in the diagnostic.
Declaration
Swift
func fatalError( _ message: @autoclosure () -> String = String(), file: StaticString = #filePath, line: UInt = #line ) -> Never -
Just like Swift.assert, but includes the full file path in the diagnostic.
Declaration
Swift
func assert( _ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String = String(), file: StaticString = #filePath, line: UInt = #line ) -
Just like Swift.assertionFailure, but includes the full file path in the diagnostic.
Declaration
Swift
func assertionFailure( _ message: @autoclosure () -> String = String(), file: StaticString = #filePath, line: UInt = #line )
View on GitHub
Functions Reference