-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
191 additions
and
9 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
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,48 @@ | ||
package ast | ||
|
||
import ( | ||
"github.com/retroenv/retroasm/expression" | ||
"github.com/retroenv/retroasm/lexer/token" | ||
) | ||
|
||
// Rept ... | ||
type Rept struct { | ||
*node | ||
|
||
Count *expression.Expression | ||
} | ||
|
||
// NewRept returns a new rept node. | ||
func NewRept(count []token.Token) Rept { | ||
return Rept{ | ||
node: &node{}, | ||
Count: expression.New(count...), | ||
} | ||
} | ||
|
||
// Copy returns a copy of the rept node. | ||
func (r Rept) Copy() Node { | ||
return Rept{ | ||
node: r.node, | ||
Count: r.Count.Copy(), | ||
} | ||
} | ||
|
||
// Endr ... | ||
type Endr struct { | ||
*node | ||
} | ||
|
||
// NewEndr returns a new rept end node. | ||
func NewEndr() Endr { | ||
return Endr{ | ||
node: &node{}, | ||
} | ||
} | ||
|
||
// Copy returns a copy of the rept end node. | ||
func (e Endr) Copy() Node { | ||
return Endr{ | ||
node: e.node, | ||
} | ||
} |
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,24 @@ | ||
package directives | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/retroenv/retroasm/parser/ast" | ||
) | ||
|
||
// Rept ... | ||
func Rept(p Parser) (ast.Node, error) { | ||
p.AdvanceReadPosition(1) | ||
countTokens, err := readDataTokens(p, true) | ||
if err != nil { | ||
return nil, fmt.Errorf("reading rept count tokens: %w", err) | ||
} | ||
|
||
return ast.NewRept(countTokens), nil | ||
} | ||
|
||
// Endr ... | ||
func Endr(p Parser) (ast.Node, error) { | ||
p.AdvanceReadPosition(1) | ||
return ast.NewEndr(), nil | ||
} |
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