-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from Flipez/add-rescue
[object/error] Add ability to rescue errors and introduce `begin/rescue/end`
- Loading branch information
Showing
14 changed files
with
213 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 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,23 @@ | ||
package ast | ||
|
||
import ( | ||
"bytes" | ||
|
||
"github.com/flipez/rocket-lang/token" | ||
) | ||
|
||
type Begin struct { | ||
Token token.Token | ||
Block *Block | ||
} | ||
|
||
func (b *Begin) TokenLiteral() string { return b.Token.Literal } | ||
func (b *Begin) String() string { | ||
var out bytes.Buffer | ||
|
||
out.WriteString("begin\n") | ||
out.WriteString(b.Block.String()) | ||
out.WriteString("\nend") | ||
|
||
return out.String() | ||
} |
This file contains 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 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,16 @@ | ||
package ast | ||
|
||
import ( | ||
"github.com/flipez/rocket-lang/token" | ||
) | ||
|
||
type Rescue struct { | ||
Token token.Token // the { token | ||
ErrorIdent token.Token | ||
Block *Block | ||
} | ||
|
||
func (r *Rescue) TokenLiteral() string { return r.Token.Literal } | ||
func (r *Rescue) String() string { | ||
return r.Block.String() | ||
} |
This file contains 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 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 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 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 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 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 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,11 @@ | ||
package parser | ||
|
||
import ( | ||
"github.com/flipez/rocket-lang/ast" | ||
) | ||
|
||
func (p *Parser) parseBegin() ast.Expression { | ||
expression := &ast.Begin{Token: p.curToken} | ||
expression.Block = p.parseBlock() | ||
return expression | ||
} |
This file contains 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 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 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
23b63fd
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.
Successfully deployed to the following URLs:
rocket-lang – ./docs
rocket-lang.org
rocket-lang.vercel.app
www.rocket-lang.org
rocket-lang-flipez.vercel.app
rocket-lang-git-main-flipez.vercel.app
23b63fd
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.
Successfully deployed to the following URLs:
rocket-lang-play – ./wasm
rocket-lang-play-git-main-flipez.vercel.app
rocket-lang-play-flipez.vercel.app
play.rocket-lang.org
rocket-lang-play.vercel.app