diff --git a/compiler/ast/ast_parsed_types.nim b/compiler/ast/ast_parsed_types.nim index 20dfa5fe8b9..03a245ee5d2 100644 --- a/compiler/ast/ast_parsed_types.nim +++ b/compiler/ast/ast_parsed_types.nim @@ -6,7 +6,7 @@ import lexer # For the token type definition ] -# NOTE further refactoring considerations for the parser +# NOTE further refactoring considerations for the parser: # # - store everything in tokens, do not require identifier interning for any # purposes during the parsing stage, it must be done later, during @@ -49,7 +49,7 @@ type # flag in the first place? func len*(node: ParsedNode): int = - ## Number of the sons of a parsed node + ## Number of sons of the parsed node return node.sons.len() # NOTE added for the sake of API similarity between PNode @@ -70,7 +70,7 @@ iterator pairs*(node: ParsedNode): (int, ParsedNode) = yield (idx, item) proc add*(node: ParsedNode, other: ParsedNode) = - ## Add new element to the sons + ## append `other` to `node`'s `sons` node.sons.add(other) proc transitionSonsKind*(n: ParsedNode, kind: TNodeKind) = diff --git a/compiler/ast/parser.nim b/compiler/ast/parser.nim index dd980e14a1e..fdd268b2c76 100644 --- a/compiler/ast/parser.nim +++ b/compiler/ast/parser.nim @@ -90,7 +90,6 @@ proc skipInd*(p: var Parser) proc optPar*(p: var Parser) proc optInd*(p: var Parser, n: ParsedNode) proc indAndComment*(p: var Parser, n: ParsedNode, maybeMissEquals = false) -# proc setBaseFlags*(n: ParsedNode, base: NumericalBase) proc parseSymbol*(p: var Parser, mode = smNormal): ParsedNode proc parseTry(p: var Parser; isExpr: bool): ParsedNode proc parseCase(p: var Parser): ParsedNode diff --git a/compiler/ast/reports.nim b/compiler/ast/reports.nim index 44c7ec755fa..79b2295afed 100644 --- a/compiler/ast/reports.nim +++ b/compiler/ast/reports.nim @@ -86,13 +86,12 @@ type reportInst*: ReportLineInfo ## Information about instantiation location ## of the reports - present for all reports in order to track their - ## origins throught the compiler. + ## origin withing the compiler. reportFrom*: ReportLineInfo ## Information about submit location of the ## report. Contains information about the place where report was - ## /submitted/ to the system - sometimes report might be created, - ## modified to add new information and only them put into the pipeline. - + ## /submitted/ to the system - sometimes a report is created, modified + ## to add new information, and only then put into the pipeline. type LexerReport* = object of ReportBase diff --git a/compiler/sem/lookups.nim b/compiler/sem/lookups.nim index 8ac6895ee26..093395bc90b 100644 --- a/compiler/sem/lookups.nim +++ b/compiler/sem/lookups.nim @@ -29,8 +29,7 @@ import modulegraphs ], compiler/utils/[ - debugutils, - astrepr + debugutils ], compiler/front/[ msgs, @@ -741,7 +740,6 @@ proc qualifiedLookUp*(c: PContext, n: PNode, flags: set[TLookupFlag]): PSym = result = errorExpectedIdentifier(c, ident, wrongNode, errExprCtx) elif checkModule in flags: result = searchInScopes(c, ident, amb).skipAlias(n, c.config) - # debug(result, verboseTReprConf) # xxx: search in scopes can return an skError -- this happens because # skError is a const referring to skUnknown, which gets used in resolving # `result`, which starts off as undeclared/unknown. diff --git a/compiler/sem/passes.nim b/compiler/sem/passes.nim index 61e800fe496..8da891aea1d 100644 --- a/compiler/sem/passes.nim +++ b/compiler/sem/passes.nim @@ -26,8 +26,7 @@ import lineinfos, ], compiler/utils/[ - pathutils, - astrepr + pathutils ] type @@ -90,7 +89,7 @@ proc processTopLevelStmt( toProcess: PNode, a: var TPassContextArray): bool = ## Main processing pipeline entry point - accepts a toplevel node, - ## collection of pass contexts and main module graph which defines passes + ## collection of pass contexts and a main module graph which defines passes ## to use. # First step works with the base tree as entry point var processingResult = toProcess @@ -100,9 +99,6 @@ proc processTopLevelStmt( # results each time. processingResult = graph.passes[i].process(a[i], processingResult) if isNil(processingResult): - # QUESTION this is an error/fatal diagnostic or some parts of the - # compiler are expected to return `nil` on failure? If the latter - # is true, which ones? return false result = true @@ -185,7 +181,7 @@ proc processModule*( if defaultStream.isNil(): let filename = toFullPathConsiderDirty(graph.config, fileIdx) stream = llStreamOpen(filename, fmRead) - if stream == nil: + if stream.isNil(): localReport( graph.config, reportStr(rsemCannotOpenFile, filename.string)) @@ -280,7 +276,7 @@ proc processModule*( processingOk = processTopLevelStmt( graph, toplevelStatements, passesArray) - if rest != nil and processingOk: + if not rest.isNil() and processingOk: processingOk = processTopLevelStmt( graph, rest, passesArray) diff --git a/compiler/sem/pragmas.nim b/compiler/sem/pragmas.nim index 93b8e15501f..a1c1396545d 100644 --- a/compiler/sem/pragmas.nim +++ b/compiler/sem/pragmas.nim @@ -37,8 +37,7 @@ import compiler/utils/[ ropes, pathutils, - debugUtils, - astrepr + debugutils ], compiler/sem/[ semdata,