textx

Overcoming infinite left recursion in TextX parser

被刻印的时光 ゝ 提交于 2019-12-25 00:48:58
问题 I am writing a parser for an existing language, using the TextX Python Library (based on the Arpeggio PEG parser) But when I try to use it to parse a file, I get the exception: RecursionError: maximum recursion depth exceeded while calling a Python object Here is a minimal example that raises this exception: #!/usr/bin/env python from textx import metamodel_from_str meta_model_string = "Expr: ( Expr '+' Expr ) | INT ;" model_string = "1 + 1" mm = metamodel_from_str(meta_model_string, debug

Parsing dhcpd.conf with textX

不羁的心 提交于 2019-12-24 18:39:15
问题 I'm using https://github.com/igordejanovic/textX to parse dhcpd.conf file (no, https://pypi.org/project/iscconf/ does not work for me, it crashes on my dhcpd.conf file), specifically extract hosts with fixed addresses. Records are like: host example1 { option host-name "example1"; ddns-hostname "example1"; fixed-address 192.168.1.181; } host example2 { hardware ethernet aa:bb:ff:20:fa:13; fixed-address 192.168.1.191; option host-name "example2"; ddns-hostname "example2"; } Code: def get_hosts