Skip to content

正規表現におけるネストしたスターの動作を再修正#7

Merged
ytakano merged 1 commit into
ytakano:masterfrom
y-yu:fix-regex-nested-star
Dec 28, 2022
Merged

正規表現におけるネストしたスターの動作を再修正#7
ytakano merged 1 commit into
ytakano:masterfrom
y-yu:fix-regex-nested-star

Conversation

@y-yu
Copy link
Copy Markdown
Contributor

@y-yu y-yu commented Dec 27, 2022

  • 正規表現エンジンが入れ子のStarでスタックオーバーフローする問題を回避 #4 で修理した内容を冷静にみると(a*)*splitが生成されなくなっていておかしいくしてしまっていた 😇
    expr: (a*)*
    AST: Seq([Star(Seq([Star(Char('a'))]))])
    
    code:
    0000: char a
    0001: match
    
  • (r*)*r*とするはずが、誤って(r*)*rとしていたので修正した 🙇
  • 修正後は次のようなコードが生成される 🙆‍♀️
    expr: (a*)*
    AST: Seq([Star(Seq([Star(Char('a'))]))])
    
    code:
    0000: split 0001, 0003
    0001: char a
    0002: jump 0000
    0003: match
    
    • これはa*のコードと一致する 👍
      expr: a*
      AST: Seq([Star(Char('a'))])
      
      code:
      0000: split 0001, 0003
      0001: char a
      0002: jump 0000
      0003: match
      

@ytakano ytakano merged commit 715cb2b into ytakano:master Dec 28, 2022
@ytakano
Copy link
Copy Markdown
Owner

ytakano commented Dec 28, 2022

ありがとうございます!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants