From ceaa92b1dda6b19751fdcf6169a6bbc1caca0e9b Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Wed, 12 Oct 2022 07:04:38 +0000 Subject: [PATCH] Update 'How to Parse' --- How-to-Parse.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/How-to-Parse.md b/How-to-Parse.md index 224773d..a544537 100644 --- a/How-to-Parse.md +++ b/How-to-Parse.md @@ -12,7 +12,7 @@ These structs are not used outside of their respective modules, and are created # Operation Methods -All methods of an operation struct are private, since they are called by the aforementioned public facing function. There is one main method that is named after the kind of operation being done (e.g. `LexingOperation.tokenize()`, `ParsingOperation.parse()`). This method runs through the source material, and should generally call dedicated methods when it encounters something that needs to be parsed/lexed. An example of one of these methods would be `LexingOperation.tokenizeNumber()`. +All methods of an operation struct are private, since they are called by the aforementioned public facing function. There is one main method that is named after the kind of operation being done (e.g. `lexingOperation.tokenize()`, `parsingOperation.parse()`). This method runs through the source material, and should generally call dedicated methods when it encounters something that needs to be parsed/lexed. An example of one of these methods would be `lexingOperation.tokenizeNumber()`. Each of these methods must: @@ -25,4 +25,4 @@ 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. - If the method consumes an entire line up until a newline, it should advance to the beginning of the next one before exiting. -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. \ No newline at end of file +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. \ No newline at end of file