This repository has been archived on 2024-02-27. You can view files and clone it, but cannot push or open issues or pull requests.
arf/analyzer/argument.go

70 lines
1.5 KiB
Go
Raw Normal View History

2022-09-22 15:51:45 -06:00
package analyzer
import "git.tebibyte.media/arf/arf/parser"
// import "git.tebibyte.media/arf/arf/infoerr"
// Argument represents a value that can be placed anywhere a value goes. This
// allows things like phrases being arguments to other phrases.
type Argument interface {
// Phrase
// Dereference
// Subscript
// Object
// Array
// Variable
// IntLiteral
// UIntLiteral
// FloatLiteral
// StringLiteral
// RuneLiteral
ToString (indent int) (output string)
}
// analyzeArgument analyzes an argument
func (analyzer AnalysisOperation) analyzeArgument (
inputArgument parser.Argument,
) (
outputArgument Argument,
err error,
2022-09-22 15:51:45 -06:00
) {
switch inputArgument.Kind() {
case parser.ArgumentKindNil:
2022-09-29 15:34:51 -06:00
panic("invalid state: attempt to analyze nil argument")
2022-09-22 15:51:45 -06:00
case parser.ArgumentKindPhrase:
2022-09-26 16:28:21 -06:00
// TODO
2022-09-22 15:51:45 -06:00
case parser.ArgumentKindDereference:
2022-09-26 16:28:21 -06:00
// TODO
2022-09-22 15:51:45 -06:00
case parser.ArgumentKindSubscript:
2022-09-26 16:28:21 -06:00
// TODO
2022-09-22 15:51:45 -06:00
2022-09-29 15:34:51 -06:00
case parser.ArgumentKindList:
2022-09-26 16:28:21 -06:00
// TODO
2022-09-22 15:51:45 -06:00
case parser.ArgumentKindIdentifier:
2022-09-26 16:28:21 -06:00
// TODO
2022-09-22 15:51:45 -06:00
case parser.ArgumentKindDeclaration:
2022-09-26 16:28:21 -06:00
// TODO
2022-09-22 15:51:45 -06:00
case parser.ArgumentKindInt:
2022-09-26 16:28:21 -06:00
outputArgument = IntLiteral(inputArgument.Value().(int64))
2022-09-22 15:51:45 -06:00
case parser.ArgumentKindUInt:
2022-09-26 16:28:21 -06:00
outputArgument = UIntLiteral(inputArgument.Value().(uint64))
2022-09-22 15:51:45 -06:00
case parser.ArgumentKindFloat:
2022-09-26 16:28:21 -06:00
outputArgument = FloatLiteral(inputArgument.Value().(float64))
2022-09-22 15:51:45 -06:00
case parser.ArgumentKindString:
2022-09-26 16:28:21 -06:00
outputArgument = StringLiteral(inputArgument.Value().(string))
2022-09-22 15:51:45 -06:00
case parser.ArgumentKindRune:
2022-09-26 16:28:21 -06:00
outputArgument = RuneLiteral(inputArgument.Value().(rune))
2022-09-22 15:51:45 -06:00
}
return
}