The interface Words is used to provide efficient access to a Gobstones words definition given by an instance of WordsDef with efficiency and readability. It is an auxiliary class for Gobstones lexer. It solves the problem of abstracting away the concrete words recognized by the Gobstones lexer to build tokens while simplifying the access to the definition of those words, given by a WordsDef.

Particular implementations must receive a words definition during creation, to guide the operations in the interface.

interface Words {
    get languagePragmaALLOWRECURSION(): string;
    get languagePragmaDESTRUCTURINGFOREACH(): string;
    get pragmaATTRIBUTE(): string;
    get pragmaBEGINREGION(): string;
    get pragmaENDREGION(): string;
    get pragmaEXTRASYMBOLS(): string;
    get pragmaLANGUAGEDOMAIN(): string;
    get pragmaLANGUAGELOCALE(): string;
    get pragmaLANGUAGEMOD(): string;
    get pragmaLANGUAGEVARIANT(): string;
    get pragmaLANGUAGEVERSION(): string;
    get sigilPragmaCloser(): string;
    get sigilPragmaOpener(): string;
    get sigilPragmaSeparator(): string;
    get sigilsLineCommentOpener(): string[];
    get sigilsParCommentCloser(): string[];
    get sigilsParCommentOpener(): string[];
    get valueLanguageDomain(): string;
    get valueLanguageLocale(): string;
    get valueLanguageVariant(): string;
    get valueLanguageVersion(): string;
    abstractOperatorForIdOperator(op): string;
    abstractOperatorForOperatorAtLevel(op, level): string;
    abstractWordForConcreteKeyword(word): symbol;
    abstractWordForConcretePrimitive(word): symbol;
    abstractWordForConcreteSymbolicKeyword(word): symbol;
    abstractWordIsKeyword(word): boolean;
    abstractWordIsPrimitive(word): boolean;
    abstractWordIsSymbolicKeyword(word): boolean;
    charIsDigit(ch): boolean;
    charIsLineSeparator(ch): boolean;
    charIsLowercaseSigil(ch): boolean;
    charIsPunctuation(ch): boolean;
    charIsRegular(ch): boolean;
    charIsStringDelimiter(ch): boolean;
    charIsStringEscape(ch): boolean;
    charIsStringEscapeSigil(ch): boolean;
    charIsUppercaseSigil(ch): boolean;
    charIsWhitespace(ch): boolean;
    concreteWordForAbstractKeyword(word): string;
    concreteWordForAbstractPrimitive(word): string;
    concreteWordForAbstractSymbolicKeyword(word): string;
    concreteWordForTokenTag(tag): string;
    concreteWordIsFirstAt(word, source): boolean;
    concreteWordIsIdOperator(word): boolean;
    concreteWordIsKeyword(word): boolean;
    concreteWordIsPrimitive(word): boolean;
    concreteWordIsSymbolicKeyword(word): boolean;
    concreteWordIsValidNumber(word): boolean;
    fixityOfLevel(level): Fixity;
    indexOfFirstAt(words, source): number;
    lineSeparatorChars(): string;
    maxFixityLevel(): number;
    pairOfSigilsAtFrom(source, openers, closers): string[];
    punctuationKeywords(): string[];
    someConcreteWordOfIsFirstAt(words, source): boolean;
    tokenIsOperatorAtLevel(token, level): boolean;
}

Implemented by

API: Language identification elements

  • get valueLanguageDomain(): string
  • The concrete string for the Language Domain according to the words definition given at creation.

    Returns string

  • get valueLanguageLocale(): string
  • The concrete string for the Language Locale option according to the words definition given at creation.

    Returns string

  • get valueLanguageVariant(): string
  • The concrete string for the Language Variant name according to the words definition given at creation.

    Returns string

  • get valueLanguageVersion(): string
  • The concrete string for the Language Version name according to the words definition given at creation.

    Returns string

API: Operators operations

  • The abstract word used for the op identifier operator.

    PRECONDITION:

    • op is one of the declared identifier operators

    Parameters

    • op: string

    Returns string

  • The symbol of the operator op at the given level.

    PRECONDITION:

    • the operator op is one of the operators at the given level

    Parameters

    • op: string
    • level: number

    Returns string

  • The fixity of the given fixity level in the language words definition.

    Parameters

    • level: number

    Returns Fixity

  • The number of the last fixity level in the language words definition.

    Returns number

  • The fixity of the given fixity level in the language words definition.

    Parameters

    • token: Token
    • level: number

    Returns boolean

API: Pragmas

  • get languagePragmaALLOWRECURSION(): string
  • The concrete string for the ALLOWRECURSION language pragma according to the words definition given at creation.

    Returns string

  • get languagePragmaDESTRUCTURINGFOREACH(): string
  • The concrete string for the DESTRUCTURINGFOREACH language pragma according to the words definition given at creation.

    Returns string

  • get pragmaATTRIBUTE(): string
  • The concrete string for the ATTRIBUTE pragma according to the words definition given at creation.

    Returns string

  • get pragmaBEGINREGION(): string
  • The concrete string for the BEGINREGION pragma according to the words definition given at creation.

    Returns string

  • get pragmaENDREGION(): string
  • The concrete string for the ENDREGION pragma according to the words definition given at creation.

    Returns string

  • get pragmaEXTRASYMBOLS(): string
  • The concrete string for the EXTRASYMBOLS pragma according to the words definition given at creation.

    Returns string

  • get pragmaLANGUAGEDOMAIN(): string
  • The concrete string for the LANGUAGEDOMAIN pragma according to the words definition given at creation.

    Returns string

  • get pragmaLANGUAGELOCALE(): string
  • The concrete string for the LANGUAGELOCALE pragma according to the words definition given at creation.

    Returns string

  • get pragmaLANGUAGEMOD(): string
  • The concrete string for the LANGUAGEMOD pragma according to the words definition given at creation.

    Returns string

  • get pragmaLANGUAGEVARIANT(): string
  • The concrete string for the LANGUAGEVARIANT pragma according to the words definition given at creation.

    Returns string

  • get pragmaLANGUAGEVERSION(): string
  • The concrete string for the LANGUAGEVERSION pragma according to the words definition given at creation.

    Returns string

API: Predicates for chars

  • Indicates if the given character is a digit char according to the words definition given at creation,

    Parameters

    • ch: string

    Returns boolean

  • Indicates if the given character is a line separator char according to the words definition given at creation,

    Parameters

    • ch: string

    Returns boolean

  • Indicates if the given character is an lowercase sigil char according to the words definition given at creation,

    Parameters

    • ch: string

    Returns boolean

  • Indicates if the given character is a punctuation char according to the words definition given at creation,

    Parameters

    • ch: string

    Returns boolean

  • Indicates if the given character is a regular char according to the words definition given at creation,

    Parameters

    • ch: string

    Returns boolean

  • Indicates if the given character is a string delimiter char according to the words definition given at creation,

    Parameters

    • ch: string

    Returns boolean

  • Indicates if the given character is a string escape char according to the words definition given at creation,

    Parameters

    • ch: string

    Returns boolean

  • Indicates if the given character is a string escape sigil char according to the words definition given at creation,

    Parameters

    • ch: string

    Returns boolean

  • Indicates if the given character is an uppercase sigil char according to the words definition given at creation,

    Parameters

    • ch: string

    Returns boolean

  • Indicates if the given character is a whitespace char according to the words definition given at creation,

    Parameters

    • ch: string

    Returns boolean

API: Predicates for words

  • Indicate if the given abstract word is a keyword according to the words definition given at creation.

    Parameters

    • word: symbol

    Returns boolean

  • Indicate if the given abstract word is a language primitive according to the words definition given at creation.

    Parameters

    • word: symbol

    Returns boolean

  • Indicate if the given abstract word is a symbolic keyword according to the words definition given at creation.

    Parameters

    • word: symbol

    Returns boolean

  • Indicate if the given source has as word as its first characters. The word word is supposed to be a concrete one.

    Parameters

    • word: string
    • source: SourceReader

    Returns boolean

  • Indicate if the given concrete word is an identifier operator of the language definition.

    Parameters

    • word: string

    Returns boolean

  • Indicate if the given concrete word is a keyword according to the words definition given at creation.

    Parameters

    • word: string

    Returns boolean

  • Indicate if the given concrete word is a language primitive according to the words definition given at creation.

    Parameters

    • word: string

    Returns boolean

  • Indicate if the given concrete word is a symbolic keyword according to the words definition given at creation.

    Parameters

    • word: string

    Returns boolean

  • Indicates if the given concrete word is a valid number according to the rules of the language.

    Parameters

    • word: string

    Returns boolean

  • Indicate if the given source has as some of the words as its first characters. The words in words are supposed to be a concrete ones.

    Parameters

    • words: string[]
    • source: SourceReader

    Returns boolean

API: Sigils

  • get sigilPragmaCloser(): string
  • The pragma closer sigil according to the words definition given at creation.

    Returns string

  • get sigilPragmaOpener(): string
  • The pragma opener sigil according to the words definition given at creation.

    Returns string

  • get sigilPragmaSeparator(): string
  • The pragma separator sigil according to the words definition given at creation.

    Returns string

  • get sigilsLineCommentOpener(): string[]
  • The line comment opener sigils according to the words definition given at creation.

    Returns string[]

  • get sigilsParCommentCloser(): string[]
  • The paragraph comment closer sigils according to the words definition given at creation.

    Returns string[]

  • get sigilsParCommentOpener(): string[]
  • The paragraph comment opener sigils according to the words definition given at creation.

    Returns string[]

API: Specific elements

  • Return the keyword for the given word according to the words definition given at creation, if the word is a keyword.

    Parameters

    • word: string

    Returns symbol

  • Return the primitive for the given word according to the words definition given at creation, if the word is a language primitive.

    Parameters

    • word: string

    Returns symbol

  • Return the symbolic keyword for the given word according to the words definition given at creation, if the word is a symbolic keyword.

    Parameters

    • word: string

    Returns symbol

  • Return the concrete word in the language words definition for the given abstract keyword.

    Parameters

    • word: symbol

    Returns string

  • Return the concrete word in the language words definition for the given abstract primitive.

    Parameters

    • word: symbol

    Returns string

  • Return the concrete word in the language words definition for the given abstract symbolic keyword.

    Parameters

    • word: symbol

    Returns string

  • Return the concrete word for the given word according to the words definition given at creation, or keep it as it is, if word is not a symbolic keyword, a keyword, or a primitive.

    Parameters

    • tag: symbol

    Returns string

  • Return the index of the string in words that the given source has as its first characters, if there is some, or undefined if it has is none of them.

    Parameters

    • words: string[]
    • source: SourceReader

    Returns number

  • Return the line separator chars according to the words definition given at creation.

    Returns string

  • Determines the pair opener-closer that is initiated in the given source, provided that one of the openers ocurrs at its beginning.

    PRECONDITION:

    • source starts with one of the strings at openers.

    Parameters

    • source: SourceReader
    • openers: string[]
    • closers: string[]

    Returns string[]

    Throws

    GErrors.PreconditionErrorIn when the source does not start with some of the given openers

  • Return the punctuation symbolic keywords according to the words definition given at creation.

    Returns string[]