MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / _tokenize

Function _tokenize

SLiCAP/SLiCAPlex.py:241–272  ·  view source on GitHub ↗

Reset the lexer, and create the tokens from the file: 'cirFileName'. :param cirFileName: Name of the netlist file to be tokenized. :type cirFileName: str :return: list with title line, command liness, or element definition lines. Each line consists of a list of token

(netlist)

Source from the content-addressed store, hash-verified

239 return out
240
241def _tokenize(netlist):
242 """
243 Reset the lexer, and create the tokens from the file: 'cirFileName'.
244
245 :param cirFileName: Name of the netlist file to be tokenized.
246 :type cirFileName: str
247
248 :return: list with title line, command liness, or element definition lines.
249
250 Each line consists of a list of tokens
251
252 :rtype: list
253 """
254 # Initialize the lexer
255 lexer.errCount = 0
256 lexer.lineno = 0
257 lexer.input(netlist)
258 lines = []
259 lastLine = []
260 tok = lexer.token()
261 while tok:
262 if tok.type != 'NEWLINE' and tok.type != 'PLUS':
263 lastLine.append(tok)
264 elif tok.type == 'NEWLINE':
265 if len(lastLine) != 0:
266 lines.append(lastLine)
267 lastLine = []
268 elif tok.type == 'PLUS':
269 lastLine = lines[-1]
270 del lines[-1]
271 tok = lexer.token()
272 return lines, lexer.errCount
273
274def _printError(msg, tok):
275 """

Callers 2

_parseNetlistFunction · 0.90
SLiCAPlex.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected