UNPKG

@fauton/cfg

Version:

A package to work with context free grammars and LL1 parsers

15 lines (14 loc) 547 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isAllTerminal = void 0; /** * Checks if all the letters of a word are terminal * @param terminals Array of terminals * @param word Word that is required to be check * @returns True if all the letters of a word are terminals false otherwise */ function isAllTerminal(terminals, word) { const terminalsSet = new Set(terminals); return word.split(' ').every((letter) => terminalsSet.has(letter)); } exports.isAllTerminal = isAllTerminal;