Update
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@
|
||||
|
||||
import std/[json, strutils, os, strformat, sequtils, algorithm]
|
||||
|
||||
# Core types and base classes — imported and re-exported for public API consumers
|
||||
# Core types and base classes - imported and re-exported for public API consumers
|
||||
import nimcheck/core/types
|
||||
import nimcheck/core/tokenizerbase
|
||||
import nimcheck/core/validatorbase
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## Validator registration — called at module load time.
|
||||
## Validator registration - called at module load time.
|
||||
##
|
||||
## Each language validator registers itself here.
|
||||
## This file is imported by the main nimcheck.nim module.
|
||||
|
||||
@@ -202,7 +202,7 @@ proc validateBrackets*(self: TokenizerBase): seq[ValidationError] =
|
||||
let hintStr = &"Add a closing '{pairStr}' before this point"
|
||||
let err = newValidationError(
|
||||
esError,
|
||||
&"Unclosed '{ch}' — expected matching '{pairStr}'",
|
||||
&"Unclosed '{ch}' - expected matching '{pairStr}'",
|
||||
ErrUnclosedBracket,
|
||||
pos,
|
||||
SourceRange(startPos: pos, endPos: pos),
|
||||
@@ -215,12 +215,12 @@ proc validateBrackets*(self: TokenizerBase): seq[ValidationError] =
|
||||
self.errors.add(result)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Abstract interface — subclasses must implement
|
||||
# Abstract interface - subclasses must implement
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
method tokenize*(self: TokenizerBase) {.base, gcsafe.} =
|
||||
## Tokenize the entire source. Must be overridden.
|
||||
raise newException(ValueError, "tokenize() not implemented — subclass must override")
|
||||
raise newException(ValueError, "tokenize() not implemented - subclass must override")
|
||||
|
||||
proc getAllTokens*(self: TokenizerBase): seq[Token] =
|
||||
## Get all tokens after tokenization.
|
||||
|
||||
@@ -36,7 +36,7 @@ proc newValidatorBase*(
|
||||
result.result.flavor = options.flavor
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Template methods — subclasses override
|
||||
# Template methods - subclasses override
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
method createTokenizer*(self: ValidatorBase): TokenizerBase {.base, gcsafe.} =
|
||||
@@ -121,7 +121,7 @@ method validate*(self: ValidatorBase): ValidationResult {.base, gcsafe.} =
|
||||
self.result.moduleInfo.linesOfCode = self.source.count('\n') + 1
|
||||
|
||||
except Exception as e:
|
||||
# Never crash — always report useful error
|
||||
# Never crash - always report useful error
|
||||
self.result.valid = false
|
||||
self.result.errors.add(newValidationError(
|
||||
esCritical,
|
||||
@@ -129,7 +129,7 @@ method validate*(self: ValidatorBase): ValidationResult {.base, gcsafe.} =
|
||||
"E9999",
|
||||
newSourcePosition(0, 0, 0),
|
||||
newSourceRange(newSourcePosition(0, 0, 0), newSourcePosition(0, 0, 0)),
|
||||
hint = "This is a bug in the validator — please report it"
|
||||
hint = "This is a bug in the validator - please report it"
|
||||
))
|
||||
when defined(nimcheckDebug):
|
||||
if self.options.debugMode:
|
||||
@@ -162,7 +162,7 @@ proc isValid*(self: ValidatorBase): bool =
|
||||
self.result.valid
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Factory — create correct validator for a flavor
|
||||
# Factory - create correct validator for a flavor
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
type
|
||||
|
||||
@@ -77,7 +77,7 @@ method tokenize*(self: PHPTokenizer) =
|
||||
self.emitToken(tkNewline, "\n", startPos)
|
||||
continue
|
||||
|
||||
# Inside PHP mode — check for exit
|
||||
# Inside PHP mode - check for exit
|
||||
if self.peekString(2) == "?>" and self.inPhpMode:
|
||||
for _ in 1..2: discard self.advance()
|
||||
self.emitToken(tkDirective, "?>", startPos)
|
||||
|
||||
Reference in New Issue
Block a user