UnexpectedToken Traceback (most recent call last)
File ~/stage/fluidsimfoam/src/fluidsimfoam/foam_input_files/parser.py:49, in parse(text, grammar)
48 try:
---> 49 tree = lark_parser.parse(text)
50 except LarkError:
File ~/.cache/pypoetry/virtualenvs/fluidsimfoam-cRTsTZ0y-py3.9/lib/python3.9/site-packages/lark/lark.py:645, in Lark.parse(self, text, start, on_error)
628 """Parse the given text, according to the options provided.
629
630 Parameters:
(...)
643
644 """
--> 645 return self.parser.parse(text, start=start, on_error=on_error)
File ~/.cache/pypoetry/virtualenvs/fluidsimfoam-cRTsTZ0y-py3.9/lib/python3.9/site-packages/lark/parser_frontends.py:96, in ParsingFrontend.parse(self, text, start, on_error)
95 stream = self._make_lexer_thread(text)
---> 96 return self.parser.parse(stream, chosen_start, **kw)
File ~/.cache/pypoetry/virtualenvs/fluidsimfoam-cRTsTZ0y-py3.9/lib/python3.9/site-packages/lark/parsers/earley.py:266, in Parser.parse(self, lexer, start)
264 columns[0].add(item)
--> 266 to_scan = self._parse(lexer, columns, to_scan, start_symbol)
268 # If the parse was successful, the start
269 # symbol should have been completed in the last step of the Earley cycle, and will be in
270 # this column. Find the item for the start_symbol, which is the root of the SPPF tree.
File ~/.cache/pypoetry/virtualenvs/fluidsimfoam-cRTsTZ0y-py3.9/lib/python3.9/site-packages/lark/parsers/earley.py:237, in Parser._parse(self, lexer, columns, to_scan, start_symbol)
235 self.predict_and_complete(i, to_scan, columns, transitives)
--> 237 to_scan = scan(i, token, to_scan)
238 i += 1
File ~/.cache/pypoetry/virtualenvs/fluidsimfoam-cRTsTZ0y-py3.9/lib/python3.9/site-packages/lark/parsers/earley.py:214, in Parser._parse.<locals>.scan(i, token, to_scan)
213 expect = {i.expect.name for i in to_scan}
--> 214 raise UnexpectedToken(token, expect, considered_rules=set(to_scan), state=frozenset(i.s for i in to_scan))
216 return next_to_scan
UnexpectedToken: Unexpected token Token('LIST_TYPE', 'List<scalar>') at line 28, column 36.
Expected one of:
* MACRO
* CNAME
* DOUBLE_NAME
* LSQB
* __ANON_1
* LPAR
* SEMICOLON
* __ANON_0
* EQKEY
* SIGNED_NUMBER
* ESCAPED_STRING
* NEWLINE
During handling of the above exception, another exception occurred:
UnexpectedToken Traceback (most recent call last)
Cell In[2], line 1
----> 1 field = read_field_file("0/Cx")
File ~/stage/fluidsimfoam/src/fluidsimfoam/foam_input_files/fields.py:206, in read_field_file(path)
202 raise RuntimeError
204 cls = classes[cls]
--> 206 return cls.from_path(path)
File ~/stage/fluidsimfoam/src/fluidsimfoam/foam_input_files/fields.py:66, in FieldABC.from_path(cls, path)
63 @classmethod
64 def from_path(cls, path: str or Path):
65 path = Path(path)
---> 66 field = cls.from_code(path.read_text())
67 field.path = path
68 return field
File ~/stage/fluidsimfoam/src/fluidsimfoam/foam_input_files/fields.py:52, in FieldABC.from_code(cls, code)
44 index_closing_par = code.rindex(
45 ")", index_nonuniform, index_boundaryField
46 )
48 code_to_parse = (
49 code[:index_nonuniform] + ";\n\n" + code[index_boundaryField:]
50 )
---> 52 tree = parse(code_to_parse)
53 code_data = code[index_opening_par + 1 : index_closing_par].strip()
55 if code_data.startswith("("):
File ~/stage/fluidsimfoam/src/fluidsimfoam/foam_input_files/parser.py:51, in parse(text, grammar)
49 tree = lark_parser.parse(text)
50 except LarkError:
---> 51 tree = lark_parser_advanced.parse(text)
52 else:
53 tree = parsers[grammar].parse(text)
File ~/.cache/pypoetry/virtualenvs/fluidsimfoam-cRTsTZ0y-py3.9/lib/python3.9/site-packages/lark/lark.py:645, in Lark.parse(self, text, start, on_error)
627 def parse(self, text: str, start: Optional[str]=None, on_error: 'Optional[Callable[[UnexpectedInput], bool]]'=None) -> 'ParseTree':
628 """Parse the given text, according to the options provided.
629
630 Parameters:
(...)
643
644 """
--> 645 return self.parser.parse(text, start=start, on_error=on_error)
File ~/.cache/pypoetry/virtualenvs/fluidsimfoam-cRTsTZ0y-py3.9/lib/python3.9/site-packages/lark/parser_frontends.py:96, in ParsingFrontend.parse(self, text, start, on_error)
94 kw = {} if on_error is None else {'on_error': on_error}
95 stream = self._make_lexer_thread(text)
---> 96 return self.parser.parse(stream, chosen_start, **kw)
File ~/.cache/pypoetry/virtualenvs/fluidsimfoam-cRTsTZ0y-py3.9/lib/python3.9/site-packages/lark/parsers/earley.py:266, in Parser.parse(self, lexer, start)
263 else:
264 columns[0].add(item)
--> 266 to_scan = self._parse(lexer, columns, to_scan, start_symbol)
268 # If the parse was successful, the start
269 # symbol should have been completed in the last step of the Earley cycle, and will be in
270 # this column. Find the item for the start_symbol, which is the root of the SPPF tree.
271 solutions = [n.node for n in columns[-1] if n.is_complete and n.node is not None and n.s == start_symbol and n.start == 0]
File ~/.cache/pypoetry/virtualenvs/fluidsimfoam-cRTsTZ0y-py3.9/lib/python3.9/site-packages/lark/parsers/earley.py:237, in Parser._parse(self, lexer, columns, to_scan, start_symbol)
234 for token in lexer.lex(expects):
235 self.predict_and_complete(i, to_scan, columns, transitives)
--> 237 to_scan = scan(i, token, to_scan)
238 i += 1
240 expects.clear()
File ~/.cache/pypoetry/virtualenvs/fluidsimfoam-cRTsTZ0y-py3.9/lib/python3.9/site-packages/lark/parsers/earley.py:214, in Parser._parse.<locals>.scan(i, token, to_scan)
212 if not next_set and not next_to_scan:
213 expect = {i.expect.name for i in to_scan}
--> 214 raise UnexpectedToken(token, expect, considered_rules=set(to_scan), state=frozenset(i.s for i in to_scan))
216 return next_to_scan
UnexpectedToken: Unexpected token Token('LIST_TYPE', 'List<scalar>') at line 28, column 36.
Expected one of:
* MACRO
* CNAME
* DOUBLE_NAME
* LSQB
* __ANON_1
* LPAR
* SEMICOLON
* __ANON_0
* EQKEY
* SIGNED_NUMBER
* ESCAPED_STRING
* NEWLINE
* LBRACE