-
-
Notifications
You must be signed in to change notification settings - Fork 2
use separated Vec for each rule_type instead of TokenData #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8bc1036
DataStack trait
ehwan 8f48b63
move DataStack to parser mod
ehwan f776b41
[WIP] emit
ehwan ccc329b
bootstrap
ehwan 5d45df6
fix empty_stack_name
ehwan a92cef5
optimize identity reduce action
ehwan a342094
extract reduce args from same stack sequentially
ehwan fb532d7
rename temp res var name from res to __res
ehwan f96c1f7
fix comments
ehwan 7ec20d2
rustfmt emit.rs
ehwan 22102ba
fix suggestions
ehwan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,58 @@ | ||||||||||||
| /// A trait for data stack in the parser. | ||||||||||||
| /// | ||||||||||||
| /// Since each non-terminal could have different ruletypes, | ||||||||||||
| /// this effectively handles those rule types into separated `Vec` stack, | ||||||||||||
| /// instead of using enum of rule types (since it would be costful at memory aspects if the size differs significantly). | ||||||||||||
| /// For people who is curious about the implementation details, | ||||||||||||
| /// you should see the actual generated `DataStack` structs, like `GrammarDataStack` in `rusty_lr_parser/src/parser/parser_expanded.rs`. | ||||||||||||
| pub trait DataStack: Sized + Default { | ||||||||||||
| /// Type for terminal symbols | ||||||||||||
| type Term; | ||||||||||||
| /// Type for non-terminal symbols - this must be enum type that was auto-generated by rusty_lr | ||||||||||||
| type NonTerm; | ||||||||||||
| /// Type for user data that is passed to the parser from the user. | ||||||||||||
| type UserData; | ||||||||||||
| /// Type for `Err` variant returned by reduce action | ||||||||||||
| type ReduceActionError; | ||||||||||||
| /// The value of the start symbol | ||||||||||||
| type StartType; | ||||||||||||
| /// Type for location of the token | ||||||||||||
| type Location: crate::Location; | ||||||||||||
|
|
||||||||||||
| fn pop_start(&mut self) -> Option<Self::StartType>; | ||||||||||||
| fn pop(&mut self); | ||||||||||||
| fn push_terminal(&mut self, term: Self::Term); | ||||||||||||
| fn push_empty(&mut self); | ||||||||||||
|
|
||||||||||||
| fn clear(&mut self); | ||||||||||||
| fn reserve(&mut self, additional: usize); | ||||||||||||
| fn with_capacity(capacity: usize) -> Self { | ||||||||||||
| let mut self_: Self = Default::default(); | ||||||||||||
| self_.reserve(capacity); | ||||||||||||
| self_ | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| fn split_off(&mut self, at: usize) -> Self; | ||||||||||||
|
||||||||||||
| fn split_off(&mut self, at: usize) -> Self; | |
| fn split_off(&mut self, at: usize) -> Self; | |
| /// Appends the contents of `other` to `self`. | |
| /// | |
| /// After the operation, `other` is emptied and left in its default state. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
split_offmethod lacks documentation explaining what theatparameter represents and the behavior of the method. Consider adding a docstring to clarify its usage.