mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
ldgen: allow more chars in sections fragments
This commit is contained in:
@@ -31,6 +31,7 @@ from pyparsing import Optional
|
|||||||
from pyparsing import originalTextFor
|
from pyparsing import originalTextFor
|
||||||
from pyparsing import Forward
|
from pyparsing import Forward
|
||||||
from pyparsing import indentedBlock
|
from pyparsing import indentedBlock
|
||||||
|
from pyparsing import Combine
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
@@ -216,8 +217,14 @@ class Fragment():
|
|||||||
|
|
||||||
class Sections(Fragment):
|
class Sections(Fragment):
|
||||||
|
|
||||||
|
# Unless quoted, symbol names start with a letter, underscore, or point
|
||||||
|
# and may include any letters, underscores, digits, points, and hyphens.
|
||||||
|
GNU_LD_SYMBOLS = Word(alphas + "_.", alphanums + "._-")
|
||||||
|
|
||||||
|
entries_grammar = Combine(GNU_LD_SYMBOLS + Optional("+"))
|
||||||
|
|
||||||
grammars = {
|
grammars = {
|
||||||
"entries": KeyGrammar(Word(alphanums + "+.").setResultsName("section"), 1, None, True)
|
"entries": KeyGrammar(entries_grammar.setResultsName("section"), 1, None, True)
|
||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@@ -523,6 +523,59 @@ entries:
|
|||||||
with self.assertRaises(ParseFatalException):
|
with self.assertRaises(ParseFatalException):
|
||||||
FragmentFile(test_fragment, self.sdkconfig)
|
FragmentFile(test_fragment, self.sdkconfig)
|
||||||
|
|
||||||
|
def test_entries_grammar(self):
|
||||||
|
|
||||||
|
test_fragment = self.create_fragment_file(u"""
|
||||||
|
[sections:test]
|
||||||
|
entries:
|
||||||
|
_valid1
|
||||||
|
valid2.
|
||||||
|
.valid3_-
|
||||||
|
""")
|
||||||
|
|
||||||
|
fragment_file = FragmentFile(test_fragment, self.sdkconfig)
|
||||||
|
self.assertEqual(fragment_file.fragments[0].entries,
|
||||||
|
{"_valid1", "valid2.", ".valid3_-"})
|
||||||
|
|
||||||
|
# invalid starting char
|
||||||
|
test_fragment = self.create_fragment_file(u"""
|
||||||
|
[sections:test]
|
||||||
|
entries:
|
||||||
|
1invalid
|
||||||
|
""")
|
||||||
|
|
||||||
|
with self.assertRaises(ParseException):
|
||||||
|
FragmentFile(test_fragment, self.sdkconfig)
|
||||||
|
|
||||||
|
test_fragment = self.create_fragment_file(u"""
|
||||||
|
[sections:test]
|
||||||
|
entries:
|
||||||
|
-invalid
|
||||||
|
""")
|
||||||
|
|
||||||
|
with self.assertRaises(ParseException):
|
||||||
|
FragmentFile(test_fragment, self.sdkconfig)
|
||||||
|
|
||||||
|
# + notation
|
||||||
|
test_fragment = self.create_fragment_file(u"""
|
||||||
|
[sections:test]
|
||||||
|
entries:
|
||||||
|
valid+
|
||||||
|
""")
|
||||||
|
|
||||||
|
fragment_file = FragmentFile(test_fragment, self.sdkconfig)
|
||||||
|
self.assertEqual(fragment_file.fragments[0].entries,
|
||||||
|
{"valid+"})
|
||||||
|
|
||||||
|
test_fragment = self.create_fragment_file(u"""
|
||||||
|
[sections:test]
|
||||||
|
entries:
|
||||||
|
inva+lid+
|
||||||
|
""")
|
||||||
|
|
||||||
|
with self.assertRaises(ParseFatalException):
|
||||||
|
FragmentFile(test_fragment, self.sdkconfig)
|
||||||
|
|
||||||
|
|
||||||
class SchemeTest(FragmentTest):
|
class SchemeTest(FragmentTest):
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user