diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f0393df..3978aa8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,3 +74,11 @@ jobs: args: release --clean --skip=validate env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish Go module to proxy.golang.org and pkg.go.dev + if: startsWith(github.ref_name, 'v') && !contains(github.ref_name, '-') + timeout-minutes: 5 + run: | + GOPROXY=https://proxy.golang.org go list -m "github.com/timoschenko/dmltools@${GITHUB_REF_NAME}" + curl -fsSL --retry 3 --retry-delay 5 --retry-all-errors -X POST \ + "https://pkg.go.dev/fetch/github.com/timoschenko/dmltools@${GITHUB_REF_NAME}" diff --git a/.gitignore b/.gitignore index 40f01a5..06ef55a 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,6 @@ package.json # go generate {{{ grammar/dml/dml_*.go -pkg/dmlex/tokentype_string.go # }}} build/ diff --git a/Makefile b/Makefile index 3436c98..5ae10b2 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,7 @@ DMLEX_GENERATED_FILES+=./pkg/dmlex/dml_base_listener.go DMLEX_GENERATED_FILES+=./pkg/dmlex/dml_lexer.go DMLEX_GENERATED_FILES+=./pkg/dmlex/dml_listener.go DMLEX_GENERATED_FILES+=./pkg/dmlex/dml_parser_dml_parser.go +DMLEX_GENERATED_FILES+=./pkg/dmlex/tokentype_string.go G4_FORMAT_FLAG:=$(BUILD_ENV_DIR)/g4-format.flag $(G4_FORMAT_FLAG): $(BUILD_ENV_DIR) $(ANTLR_FORMAT_JAR) $(G4_DML) $(WS_FIXER) @@ -125,6 +126,9 @@ $(GO_GENERATED_FLAG): $(BUILD_ENV_DIR) endif $(GO_GENERATED_FLAG): $(GO) generate ./pkg/dmlex/... +ifneq ($(filter-out 0 false FALSE no NO,$(CI)),) + @$(CHECK_GENERATED_CLEAN) +endif $(file > $@,) ifeq ($(filter-out 0 false FALSE no NO,$(SKIP_ANTLR)),) diff --git a/README.md b/README.md index 58e29cb..4533a89 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ # dmltools -[![CI](https://github.com/timoschenko/dmltools/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/timoschenko/dmltools/actions/workflows/pre-commit.yml) -[![Go Reference](https://pkg.go.dev/badge/github.com/timoschenko/dmltools.svg)](https://pkg.go.dev/github.com/timoschenko/dmltools) [![Go Version](https://img.shields.io/github/go-mod/go-version/timoschenko/dmltools?logo=go)](go.mod) +[![Go Reference](https://pkg.go.dev/badge/github.com/timoschenko/dmltools.svg)](https://pkg.go.dev/github.com/timoschenko/dmltools) [![Release](https://img.shields.io/github/v/release/timoschenko/dmltools)](https://github.com/timoschenko/dmltools/releases) +[![Supported DML Versions](https://img.shields.io/badge/dml-1.4-blue)](https://github.com/timoschenko/dmltools/releases) +[![CI](https://github.com/timoschenko/dmltools/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/timoschenko/dmltools/actions/workflows/pre-commit.yml) [![License: GPL-2.0](https://img.shields.io/badge/License-GPL_2.0-blue.svg)](LICENSE) -Tooling and utilities for Device Modeling Language (DML 1.4 & 1.2), including `dmlfmt` (an opinionated deterministic code formatter) and `dmlast` (an AST dumper). +Tooling and utilities for Device Modeling Language (DML 1.4), +including `dmlfmt` (an opinionated deterministic code formatter). ## Installation @@ -24,7 +26,9 @@ go install github.com/timoschenko/dmltools/cmd/dmlast@latest ### Prebuilt Binaries -Precompiled binaries for Linux (`amd64`, `arm64`) and Windows (`amd64`) are available on the [GitHub Releases](https://github.com/timoschenko/dmltools/releases) page. +Precompiled binaries for Linux (`amd64`, `arm64`) and Windows (`amd64`) +are available on the +[GitHub Releases](https://github.com/timoschenko/dmltools/releases) page. ## Building from Sources diff --git a/pkg/dmlex/tokentype_string.go b/pkg/dmlex/tokentype_string.go new file mode 100644 index 0000000..6a1f4f4 --- /dev/null +++ b/pkg/dmlex/tokentype_string.go @@ -0,0 +1,212 @@ +// Code generated by "stringer -type=TokenType"; DO NOT EDIT. + +package dmlex + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[TokenUnknown-0] + _ = x[TokenEOF - -1] + _ = x[TokenT__0-1] + _ = x[TokenAfter-2] + _ = x[TokenAs-3] + _ = x[TokenAssert-4] + _ = x[TokenAsync-5] + _ = x[TokenAttribute-6] + _ = x[TokenAuto-7] + _ = x[TokenAwait-8] + _ = x[TokenBank-9] + _ = x[TokenBitfields-10] + _ = x[TokenBitorder-11] + _ = x[TokenBreak-12] + _ = x[TokenCall-13] + _ = x[TokenCase-14] + _ = x[TokenCast-15] + _ = x[TokenCatch-16] + _ = x[TokenChar-17] + _ = x[TokenClass-18] + _ = x[TokenConnect-19] + _ = x[TokenConst-20] + _ = x[TokenConstant-21] + _ = x[TokenContinue-22] + _ = x[TokenCritical-23] + _ = x[TokenData-24] + _ = x[TokenDefault-25] + _ = x[TokenDefaultNew-26] + _ = x[TokenDefined-27] + _ = x[TokenDelete-28] + _ = x[TokenDevice-29] + _ = x[TokenDml-30] + _ = x[TokenDo-31] + _ = x[TokenDouble-32] + _ = x[TokenEach-33] + _ = x[TokenElse-34] + _ = x[TokenEndian-35] + _ = x[TokenEnum-36] + _ = x[TokenError-37] + _ = x[TokenEvent-38] + _ = x[TokenExport-39] + _ = x[TokenExtern-40] + _ = x[TokenField-41] + _ = x[TokenFloat-42] + _ = x[TokenFooter-43] + _ = x[TokenFor-44] + _ = x[TokenForeach-45] + _ = x[TokenGoto-46] + _ = x[TokenGroup-47] + _ = x[TokenHashElse-48] + _ = x[TokenHashForeach-49] + _ = x[TokenHashIf-50] + _ = x[TokenHashSelect-51] + _ = x[TokenHeader-52] + _ = x[TokenHeader2-53] + _ = x[TokenHook-54] + _ = x[TokenIf-55] + _ = x[TokenImplement-56] + _ = x[TokenImport-57] + _ = x[TokenIn-58] + _ = x[TokenIndependent-59] + _ = x[TokenInfo-60] + _ = x[TokenInline-61] + _ = x[TokenInt-62] + _ = x[TokenInterface-63] + _ = x[TokenIs-64] + _ = x[TokenLayout-65] + _ = x[TokenLocal-66] + _ = x[TokenLog-67] + _ = x[TokenLoggroup-68] + _ = x[TokenLong-69] + _ = x[TokenMemoized-70] + _ = x[TokenMethod-71] + _ = x[TokenNamespace-72] + _ = x[TokenNew-73] + _ = x[TokenNothrow-74] + _ = x[TokenParam-75] + _ = x[TokenPort-76] + _ = x[TokenPrivate-77] + _ = x[TokenProtected-78] + _ = x[TokenProvisional-79] + _ = x[TokenPublic-80] + _ = x[TokenRegister-81] + _ = x[TokenRestrict-82] + _ = x[TokenReturn-83] + _ = x[TokenSaved-84] + _ = x[TokenSelect-85] + _ = x[TokenSequence-86] + _ = x[TokenSession-87] + _ = x[TokenShared-88] + _ = x[TokenShort-89] + _ = x[TokenSigned-90] + _ = x[TokenSize-91] + _ = x[TokenSizeof-92] + _ = x[TokenSizeoftype-93] + _ = x[TokenSpecViol-94] + _ = x[TokenStartup-95] + _ = x[TokenStatic-96] + _ = x[TokenStringify-97] + _ = x[TokenStruct-98] + _ = x[TokenSubdevice-99] + _ = x[TokenSwitch-100] + _ = x[TokenTemplate-101] + _ = x[TokenThen-102] + _ = x[TokenThis-103] + _ = x[TokenThrow-104] + _ = x[TokenThrows-105] + _ = x[TokenTry-106] + _ = x[TokenTypedef-107] + _ = x[TokenTypeof-108] + _ = x[TokenUndefined-109] + _ = x[TokenUnimpl-110] + _ = x[TokenUnion-111] + _ = x[TokenUnsigned-112] + _ = x[TokenUsing-113] + _ = x[TokenVect-114] + _ = x[TokenVirtual-115] + _ = x[TokenVoid-116] + _ = x[TokenVolatile-117] + _ = x[TokenWarning-118] + _ = x[TokenWhere-119] + _ = x[TokenWhile-120] + _ = x[TokenWith-121] + _ = x[TokenIntegerLiteral-122] + _ = x[TokenHexLiteral-123] + _ = x[TokenBinaryLiteral-124] + _ = x[TokenFloatLiteral-125] + _ = x[TokenCharLiteral-126] + _ = x[TokenStringLiteral-127] + _ = x[TokenCCodeBlock-128] + _ = x[TokenIdentifier-129] + _ = x[TokenLparen-130] + _ = x[TokenRparen-131] + _ = x[TokenLbrace-132] + _ = x[TokenLbraceNew-133] + _ = x[TokenRbrace-134] + _ = x[TokenLbrack-135] + _ = x[TokenRbrack-136] + _ = x[TokenSemi-137] + _ = x[TokenComma-138] + _ = x[TokenDot-139] + _ = x[TokenEllipsis-140] + _ = x[TokenAssign-141] + _ = x[TokenNewAssign-142] + _ = x[TokenGt-143] + _ = x[TokenLt-144] + _ = x[TokenBang-145] + _ = x[TokenTilde-146] + _ = x[TokenQuestion-147] + _ = x[TokenColon-148] + _ = x[TokenEqual-149] + _ = x[TokenLe-150] + _ = x[TokenGe-151] + _ = x[TokenNotequal-152] + _ = x[TokenAnd-153] + _ = x[TokenOr-154] + _ = x[TokenInc-155] + _ = x[TokenDec-156] + _ = x[TokenAdd-157] + _ = x[TokenSub-158] + _ = x[TokenMul-159] + _ = x[TokenDiv-160] + _ = x[TokenBitand-161] + _ = x[TokenBitor-162] + _ = x[TokenCaret-163] + _ = x[TokenMod-164] + _ = x[TokenAddAssign-165] + _ = x[TokenSubAssign-166] + _ = x[TokenMulAssign-167] + _ = x[TokenDivAssign-168] + _ = x[TokenModAssign-169] + _ = x[TokenAndAssign-170] + _ = x[TokenOrAssign-171] + _ = x[TokenXorAssign-172] + _ = x[TokenLshiftAssign-173] + _ = x[TokenRshiftAssign-174] + _ = x[TokenLshift-175] + _ = x[TokenRshift-176] + _ = x[TokenArrow-177] + _ = x[TokenAt-178] + _ = x[TokenAltQuestion-179] + _ = x[TokenAltColon-180] + _ = x[TokenWs-181] + _ = x[TokenComment-182] + _ = x[TokenCommentBlockEol-183] + _ = x[TokenCommentBlock-184] + _ = x[TokenCommentInlineEol-185] + _ = x[TokenCommentInline-186] + _ = x[TokenLastTokenType-186] +} + +const _TokenType_name = "TokenEOFTokenUnknownTokenT__0TokenAfterTokenAsTokenAssertTokenAsyncTokenAttributeTokenAutoTokenAwaitTokenBankTokenBitfieldsTokenBitorderTokenBreakTokenCallTokenCaseTokenCastTokenCatchTokenCharTokenClassTokenConnectTokenConstTokenConstantTokenContinueTokenCriticalTokenDataTokenDefaultTokenDefaultNewTokenDefinedTokenDeleteTokenDeviceTokenDmlTokenDoTokenDoubleTokenEachTokenElseTokenEndianTokenEnumTokenErrorTokenEventTokenExportTokenExternTokenFieldTokenFloatTokenFooterTokenForTokenForeachTokenGotoTokenGroupTokenHashElseTokenHashForeachTokenHashIfTokenHashSelectTokenHeaderTokenHeader2TokenHookTokenIfTokenImplementTokenImportTokenInTokenIndependentTokenInfoTokenInlineTokenIntTokenInterfaceTokenIsTokenLayoutTokenLocalTokenLogTokenLoggroupTokenLongTokenMemoizedTokenMethodTokenNamespaceTokenNewTokenNothrowTokenParamTokenPortTokenPrivateTokenProtectedTokenProvisionalTokenPublicTokenRegisterTokenRestrictTokenReturnTokenSavedTokenSelectTokenSequenceTokenSessionTokenSharedTokenShortTokenSignedTokenSizeTokenSizeofTokenSizeoftypeTokenSpecViolTokenStartupTokenStaticTokenStringifyTokenStructTokenSubdeviceTokenSwitchTokenTemplateTokenThenTokenThisTokenThrowTokenThrowsTokenTryTokenTypedefTokenTypeofTokenUndefinedTokenUnimplTokenUnionTokenUnsignedTokenUsingTokenVectTokenVirtualTokenVoidTokenVolatileTokenWarningTokenWhereTokenWhileTokenWithTokenIntegerLiteralTokenHexLiteralTokenBinaryLiteralTokenFloatLiteralTokenCharLiteralTokenStringLiteralTokenCCodeBlockTokenIdentifierTokenLparenTokenRparenTokenLbraceTokenLbraceNewTokenRbraceTokenLbrackTokenRbrackTokenSemiTokenCommaTokenDotTokenEllipsisTokenAssignTokenNewAssignTokenGtTokenLtTokenBangTokenTildeTokenQuestionTokenColonTokenEqualTokenLeTokenGeTokenNotequalTokenAndTokenOrTokenIncTokenDecTokenAddTokenSubTokenMulTokenDivTokenBitandTokenBitorTokenCaretTokenModTokenAddAssignTokenSubAssignTokenMulAssignTokenDivAssignTokenModAssignTokenAndAssignTokenOrAssignTokenXorAssignTokenLshiftAssignTokenRshiftAssignTokenLshiftTokenRshiftTokenArrowTokenAtTokenAltQuestionTokenAltColonTokenWsTokenCommentTokenCommentBlockEolTokenCommentBlockTokenCommentInlineEolTokenCommentInline" + +var _TokenType_index = [...]uint16{0, 8, 20, 29, 39, 46, 57, 67, 81, 90, 100, 109, 123, 136, 146, 155, 164, 173, 183, 192, 202, 214, 224, 237, 250, 263, 272, 284, 299, 311, 322, 333, 341, 348, 359, 368, 377, 388, 397, 407, 417, 428, 439, 449, 459, 470, 478, 490, 499, 509, 522, 538, 549, 564, 575, 587, 596, 603, 617, 628, 635, 651, 660, 671, 679, 693, 700, 711, 721, 729, 742, 751, 764, 775, 789, 797, 809, 819, 828, 840, 854, 870, 881, 894, 907, 918, 928, 939, 952, 964, 975, 985, 996, 1005, 1016, 1031, 1044, 1056, 1067, 1081, 1092, 1106, 1117, 1130, 1139, 1148, 1158, 1169, 1177, 1189, 1200, 1214, 1225, 1235, 1248, 1258, 1267, 1279, 1288, 1301, 1313, 1323, 1333, 1342, 1361, 1376, 1394, 1411, 1427, 1445, 1460, 1475, 1486, 1497, 1508, 1522, 1533, 1544, 1555, 1564, 1574, 1582, 1595, 1606, 1620, 1627, 1634, 1643, 1653, 1666, 1676, 1686, 1693, 1700, 1713, 1721, 1728, 1736, 1744, 1752, 1760, 1768, 1776, 1787, 1797, 1807, 1815, 1829, 1843, 1857, 1871, 1885, 1899, 1912, 1926, 1943, 1960, 1971, 1982, 1992, 1999, 2015, 2028, 2035, 2047, 2067, 2084, 2105, 2123} + +func (i TokenType) String() string { + idx := int(i) - -1 + if i < -1 || idx >= len(_TokenType_index)-1 { + return "TokenType(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _TokenType_name[_TokenType_index[idx]:_TokenType_index[idx+1]] +}