Mercurial > iscconf
changeset 20:e7e13ad7dc64
Fix a problem with parsing MAC addresses starting with octets like '2e'
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Thu, 15 Nov 2012 13:43:38 +0100 |
| parents | 31c52a207eca |
| children | 2314681f3563 |
| files | iscconf/parser.py tests/test_dhcp.py |
| diffstat | 2 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/iscconf/parser.py Tue Jul 31 16:37:57 2012 +0200 +++ b/iscconf/parser.py Thu Nov 15 13:43:38 2012 +0100 @@ -30,7 +30,7 @@ pass def t_INTEGER(t): - r'-?[0-9]+(?![0-9:.])' # Avoid conflicts with MAC and IP addresses + r'-?[0-9]+(?![a-f0-9:.])' # Avoid conflicts with MAC and IP addresses t.value = int(t.value) return t @@ -115,10 +115,13 @@ p[0] = p[2] def p_error(p): - raise SyntaxError("Syntax error at %r line %d" % (p.value, p.lineno)) + if p: + raise SyntaxError("Syntax error at %r line %d" % (p.value, p.lineno)) + else: + raise SyntaxError("Syntax error") def parse(string): return ply.yacc.parse(string) -ply.lex.lex(debug=0) -ply.yacc.yacc(debug=0) +ply.lex.lex(debug=1) +ply.yacc.yacc(debug=1)
--- a/tests/test_dhcp.py Tue Jul 31 16:37:57 2012 +0200 +++ b/tests/test_dhcp.py Thu Nov 15 13:43:38 2012 +0100 @@ -14,6 +14,12 @@ data = iscconf.parse('# xxx') self.assertEqual(data, {}) + def test_mac_2e(self): + data = iscconf.parse("2e:2c:45:e8:c9:23;") + self.assertEqual(data, { + (): '2e:2c:45:e8:c9:23', + }) + def test_single(self): data = iscconf.parse("""\ host s10557.dc2 {
