Forlan Manual


The Str Module


Synopsis

signature STR
structure Str :> STR

This module provides operations on Forlan strings, i.e., lists of Forlan symbols.


Interface

type str = Sym.sym list
val possBeginsWithStr : (int * Lex.tok) list -> bool
val inputFromLabToks : (int * Lex.tok) list -> str * (int * Lex.tok) list
val fromString : string -> str
val input : string -> str
val toPP : str -> PP.pp
val toString : str -> string
val output : string * str -> unit
val last : str -> Sym.sym
val allButLast : str -> str
val compare : str Sort.total_ordering
val equal : str * str -> bool
val alphabet : str -> Sym.sym Set.set
val renameAlphabet : str * SymRel.sym_rel -> str
val prefix : str * str -> bool
val suffix : str * str -> bool
val substr : str * str -> bool
val power : str * int -> str
val removePrefix : str * str -> str option
val removeSuffix : str * str -> str option
val jforlanValidate : string -> unit
val jforlanPretty : string -> unit

Description

type str = Sym.sym list
The type of Forlan strings, i.e., lists of Forlan symbols.

In the concrete syntax for strings, the empty string is written as %, and a nonempty string [a1, ... an] is written as a1 ... an.

possBeginsWithStr lts
tests whether lts begins with a symbol or % (Lex.Perc), making it possible that a Forlan string could be parsed from lts.

inputFromLabToks lts
tries to input a Forlan string from lts, consuming as much of lts as possible, and returning the pair of that string and the rest of lts. Issues an error message if this can't be done.

fromString s
inputs a Forlan string from s.

input fil
inputs a Forlan string from the file named by fil.

toPP x
returns a pretty-printing expression for x.

toString x
pretty-prints x to a string.

output(fil, x)
pretty-prints x to the file named by fil.

last x
returns the last element of x. Raises Empty if x is empty.

allButLast x
returns all but the last element of x. Raises Empty if x is empty.

compare
is defined by:
  val compare = Set.compareList Sym.compare
This ordering first uses the length of strings (shorter is smaller), and then uses the lexicographic ordering on equal length strings.

equal(x, y)
tests whether x and y are equal.

alphabet x
returns the alphabet of x.

renameAlphabet(x, rel)
renames the alphabet of x using the bijection rel. Issues an error message if rel is not a bijection from a superset of the alphabet of x to some set.

prefix(x, y)
tests whether x is a prefix of y.

suffix(x, y)
tests whether x is a suffix of y.

substr(x, y)
tests whether x is a substring of y.

power(x, n)
raises x to the power n. Issues an error message if n is negative.

removePrefix(x, y)
If x is a prefix of y, then removePrefix returns SOME z, where z is the result of removing x from the beginning of y. Otherwise, removePrefix returns NONE.

removeSuffix(x, y)
If x is a suffix of y, then removeSuffix returns SOME z, where z is the result of removing x from the end of y. Otherwise, removeSuffix returns NONE.

jforlanValidate
is a low-level function used by JForlan. See the code for more information.

jforlanPretty
is a low-level function used by JForlan. See the code for more information.


[ Top | Parent | Root | Contents | Index ]

Forlan Version 4.15
Copyright © 2022 Alley Stoughton