compiler refactoring, pass config around explicitly
This commit is contained in:
parent
eef12654bd
commit
b7116a28ee
17 changed files with 93 additions and 1879 deletions
|
|
@ -27,7 +27,7 @@ when isMainModule:
|
|||
outp.close
|
||||
|
||||
import
|
||||
llstream, lexer, idents, strutils, ast, astalgo, msgs
|
||||
llstream, lexer, idents, strutils, ast, astalgo, msgs, options
|
||||
|
||||
type
|
||||
TParser* = object # A TParser object represents a file that
|
||||
|
|
@ -84,20 +84,20 @@ proc getTok(p: var TParser) =
|
|||
p.hasProgress = true
|
||||
|
||||
proc openParser*(p: var TParser, fileIdx: FileIndex, inputStream: PLLStream,
|
||||
cache: IdentCache;
|
||||
cache: IdentCache; config: ConfigRef;
|
||||
strongSpaces=false) =
|
||||
## Open a parser, using the given arguments to set up its internal state.
|
||||
##
|
||||
initToken(p.tok)
|
||||
openLexer(p.lex, fileIdx, inputStream, cache)
|
||||
openLexer(p.lex, fileIdx, inputStream, cache, config)
|
||||
getTok(p) # read the first token
|
||||
p.firstTok = true
|
||||
p.strongSpaces = strongSpaces
|
||||
|
||||
proc openParser*(p: var TParser, filename: string, inputStream: PLLStream,
|
||||
cache: IdentCache;
|
||||
cache: IdentCache; config: ConfigRef;
|
||||
strongSpaces=false) =
|
||||
openParser(p, filename.fileInfoIdx, inputStream, cache, strongSpaces)
|
||||
openParser(p, filename.fileInfoIdx, inputStream, cache, config, strongSpaces)
|
||||
|
||||
proc closeParser(p: var TParser) =
|
||||
## Close a parser, freeing up its resources.
|
||||
|
|
@ -2178,8 +2178,8 @@ proc parseTopLevelStmt(p: var TParser): PNode =
|
|||
if result.kind == nkEmpty: parMessage(p, errExprExpected, p.tok)
|
||||
break
|
||||
|
||||
proc parseString*(s: string; cache: IdentCache; filename: string = "";
|
||||
line: int = 0;
|
||||
proc parseString*(s: string; cache: IdentCache; config: ConfigRef;
|
||||
filename: string = ""; line: int = 0;
|
||||
errorHandler: TErrorHandler = nil): PNode =
|
||||
## Parses a string into an AST, returning the top node.
|
||||
## `filename` and `line`, although optional, provide info so that the
|
||||
|
|
@ -2192,7 +2192,7 @@ proc parseString*(s: string; cache: IdentCache; filename: string = "";
|
|||
# XXX for now the builtin 'parseStmt/Expr' functions do not know about strong
|
||||
# spaces...
|
||||
parser.lex.errorHandler = errorHandler
|
||||
openParser(parser, filename, stream, cache, false)
|
||||
openParser(parser, filename, stream, cache, config, false)
|
||||
|
||||
result = parser.parseAll
|
||||
closeParser(parser)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue