Skip to content

Commit 3bb47ad

Browse files
committed
Add comment in test.hsd, document regexp in dict.py
1 parent 8950f2c commit 3bb47ad

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/hsd/dict.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,23 @@
1717

1818
_DataType = Union[_ItemType, List[_ItemType]]
1919

20+
# Pattern to transform HSD string values into actual Python data types
2021
_TOKEN_PATTERN = re.compile(r"""
22+
# Integer
2123
(?:\s*(?:^|(?<=\s))(?P<int>[+-]?[0-9]+)(?:\s*$|\s+))
2224
|
25+
# Floating point
2326
(?:\s*(?:^|(?<=\s))
2427
(?P<float>[-+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?)(?:$|(?=\s+)))
2528
|
29+
# Logical (Yes/No)
2630
(?:\s*(?:^|(?<=\s))(?P<logical>[Yy][Ee][Ss]|[Nn][Oo])(?:$|(?=\s+)))
2731
|
28-
(?:\s*(?:(?P<qstr>(?P<quote>['"]).*?(?P=quote)) | (?P<str>.+?))(?:$|\s+))
32+
# Quoted string
33+
(?:\s*(?:(?P<qstr>(?P<quote>['"]).*?(?P=quote))
34+
|
35+
# Unquoted string
36+
(?P<str>.+?))(?:$|\s+))
2937
""", re.VERBOSE | re.MULTILINE)
3038

3139

test/test.hsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Hamiltonian = DFTB {
2222
1.030000 3.800000 2.820000
2323
}
2424
}
25+
# Adding arbitrary comment, this should not change parsing result
2526
Filling = Fermi {
2627
Temperature [Kelvin] = 1e-08
2728
}

0 commit comments

Comments
 (0)