Update 'How to Parse'

Sasha Koshka 2022-09-01 03:23:19 +00:00
parent d007a655d0
commit fc3c36eba8

@ -25,5 +25,3 @@ Each of these methods must:
- For example, a method meant to tokenize a string should advance the parser to the rune *after* the closing quotation. This ensures that methods can be properly called one after another. - For example, a method meant to tokenize a string should advance the parser to the rune *after* the closing quotation. This ensures that methods can be properly called one after another.
Methods can return their results in one of two ways. The first, most robust, and most obvious way is for them to simply *return* the result. Sometimes, however, this option is not preferable. In this case, the method should take in a parameter called `into`, which should be a pointer of the "container" in which to put the result. For example, the method `ParsingOperation.parseEnumMembers()` takes in a pointer to an enum struct where the enum members need to go. As it parses each enum member, it adds it to the enum section's member slice. This approach is primarily for methods that parse *multiple* things, and in order to ensure good error handling, it is advisable to handle the parsing of individual items in a separate method. Methods can return their results in one of two ways. The first, most robust, and most obvious way is for them to simply *return* the result. Sometimes, however, this option is not preferable. In this case, the method should take in a parameter called `into`, which should be a pointer of the "container" in which to put the result. For example, the method `ParsingOperation.parseEnumMembers()` takes in a pointer to an enum struct where the enum members need to go. As it parses each enum member, it adds it to the enum section's member slice. This approach is primarily for methods that parse *multiple* things, and in order to ensure good error handling, it is advisable to handle the parsing of individual items in a separate method.
# Error Handling