Stub for parsing arguments
This commit is contained in:
parent
25cc74a6d9
commit
f6ff3c725d
61
analyzer/argument.go
Normal file
61
analyzer/argument.go
Normal file
@ -0,0 +1,61 @@
|
||||
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,
|
||||
) {
|
||||
switch inputArgument.Kind() {
|
||||
case parser.ArgumentKindNil:
|
||||
|
||||
case parser.ArgumentKindPhrase:
|
||||
|
||||
case parser.ArgumentKindDereference:
|
||||
|
||||
case parser.ArgumentKindSubscript:
|
||||
|
||||
case parser.ArgumentKindObjectDefaultValues:
|
||||
|
||||
case parser.ArgumentKindArrayDefaultValues:
|
||||
|
||||
case parser.ArgumentKindIdentifier:
|
||||
|
||||
case parser.ArgumentKindDeclaration:
|
||||
|
||||
case parser.ArgumentKindInt:
|
||||
|
||||
case parser.ArgumentKindUInt:
|
||||
|
||||
case parser.ArgumentKindFloat:
|
||||
|
||||
case parser.ArgumentKindString:
|
||||
|
||||
case parser.ArgumentKindRune:
|
||||
|
||||
case parser.ArgumentKindOperator:
|
||||
|
||||
}
|
||||
return
|
||||
}
|
40
analyzer/literals.go
Normal file
40
analyzer/literals.go
Normal file
@ -0,0 +1,40 @@
|
||||
package analyzer
|
||||
|
||||
import "fmt"
|
||||
|
||||
type IntLiteral int64
|
||||
type UIntLiteral uint64
|
||||
type FloatLiteral float64
|
||||
type StringLiteral string
|
||||
type RuneLiteral rune
|
||||
|
||||
// ToString outputs the data in the argument as a string.
|
||||
func (literal IntLiteral) ToString (indent int) (output string) {
|
||||
output += doIndent(indent, fmt.Sprint("arg int ", literal, "\n"))
|
||||
return
|
||||
}
|
||||
|
||||
// ToString outputs the data in the argument as a string.
|
||||
func (literal UIntLiteral) ToString (indent int) (output string) {
|
||||
output += doIndent(indent, fmt.Sprint("arg uint ", literal, "\n"))
|
||||
return
|
||||
}
|
||||
|
||||
// ToString outputs the data in the argument as a string.
|
||||
func (literal FloatLiteral) ToString (indent int) (output string) {
|
||||
output += doIndent(indent, fmt.Sprint("arg float ", literal, "\n"))
|
||||
return
|
||||
}
|
||||
|
||||
// ToString outputs the data in the argument as a string.
|
||||
func (literal StringLiteral) ToString (indent int) (output string) {
|
||||
output += doIndent(indent, fmt.Sprint("arg string \"", literal, "\"\n"))
|
||||
return
|
||||
}
|
||||
|
||||
// ToString outputs the data in the argument as a string.
|
||||
func (literal RuneLiteral) ToString (indent int) (output string) {
|
||||
output += doIndent(indent, fmt.Sprint("arg rune '", literal, "'\n"))
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user