Skip to content
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

Return line of text similar to readlines #49

Open
gazayas opened this issue Jun 27, 2023 · 0 comments
Open

Return line of text similar to readlines #49

gazayas opened this issue Jun 27, 2023 · 0 comments
Labels

Comments

@gazayas
Copy link
Owner

gazayas commented Jun 27, 2023

LexNode objects currently look like this.

Masamune::AbstractSyntaxTree.new("x = 1\n y = 2").lex_nodes
=> 
[#<Masamune::LexNode:0x00007fe2f0655498 @ast_id=226780, @index=0, @position=[1, 0], @state=CMDARG, @token="x", @type=:ident>,            
 #<Masamune::LexNode:0x00007fe2f06552b8 @ast_id=226780, @index=1, @position=[1, 1], @state=CMDARG, @token=" ", @type=:sp>,               
 #<Masamune::LexNode:0x00007fe2f06550d8 @ast_id=226780, @index=2, @position=[1, 2], @state=BEG, @token="=", @type=:op>,                  
 #<Masamune::LexNode:0x00007fe2f0654f20 @ast_id=226780, @index=3, @position=[1, 3], @state=BEG, @token=" ", @type=:sp>,                  
 #<Masamune::LexNode:0x00007fe2f0654d90 @ast_id=226780, @index=4, @position=[1, 4], @state=END, @token="1", @type=:int>,                 
 #<Masamune::LexNode:0x00007fe2f0654c28 @ast_id=226780, @index=5, @position=[1, 5], @state=BEG, @token="\n", @type=:nl>,                 
 #<Masamune::LexNode:0x00007fe2f0654a70 @ast_id=226780, @index=6, @position=[2, 0], @state=BEG, @token=" ", @type=:sp>,                  
 #<Masamune::LexNode:0x00007fe2f0654890 @ast_id=226780, @index=7, @position=[2, 1], @state=CMDARG, @token="y", @type=:ident>,            
 #<Masamune::LexNode:0x00007fe2f0654728 @ast_id=226780, @index=8, @position=[2, 2], @state=CMDARG, @token=" ", @type=:sp>,               
 #<Masamune::LexNode:0x00007fe2f0654598 @ast_id=226780, @index=9, @position=[2, 3], @state=BEG, @token="=", @type=:op>,                  
 #<Masamune::LexNode:0x00007fe2f0654430 @ast_id=226780, @index=10, @position=[2, 4], @state=BEG, @token=" ", @type=:sp>,
 #<Masamune::LexNode:0x00007fe2f06542a0 @ast_id=226780, @index=11, @position=[2, 5], @state=END, @token="2", @type=:int>]

I would like to write something like msmn.lines to get all the lines like a File object does. Since all of the line numbers and tokens are here, I think we could build the lines pretty easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant