UNPKG

@mistlog/typetype

Version:

A programming language designed for typescript type generation

52 lines (51 loc) 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Digit = exports.NonDigit = exports.IdentifierNonDigit = exports.Identifier = void 0; const react_peg_1 = require("react-peg"); function Identifier() { const head = (react_peg_1.ReactPeg.createChunk(IdentifierNonDigit, null)); const tail = (react_peg_1.ReactPeg.createChunk("repeat", { type: "*" }, react_peg_1.ReactPeg.createChunk("or", null, react_peg_1.ReactPeg.createChunk(Identifier, null), react_peg_1.ReactPeg.createChunk(Digit, null)))); const action = ({ globalFunction }) => { const name = globalFunction.text().trim(); return { kind: "Identifier", name }; }; return (react_peg_1.ReactPeg.createChunk("pattern", { action: action }, head, tail)); } exports.Identifier = Identifier; /** * identifier-nondigit: nondigit universal-character-name other implementation-defined characters */ function IdentifierNonDigit() { return (react_peg_1.ReactPeg.createChunk(NonDigit, null)); } exports.IdentifierNonDigit = IdentifierNonDigit; /** * nondigit: one of a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _ */ function NonDigit() { return (react_peg_1.ReactPeg.createChunk("set", { label: "nonDigit" }, "a-zA-Z_")); } exports.NonDigit = NonDigit; /** * one of 0 1 2 3 4 5 6 7 8 9 */ function Digit() { return (react_peg_1.ReactPeg.createChunk("set", { label: "digit" }, "0-9")); } exports.Digit = Digit;