MMQLEngine/mmql/engine/parsers/amount.go

33 lines
576 B
Go
Raw Normal View History

2022-10-21 21:58:19 +00:00
package parsers
2022-10-21 16:03:06 +00:00
import (
// "fmt"
engine "github.com/tgckpg/mmqlengine/mmql/engine"
stmtd "github.com/tgckpg/mmqlengine/mmql/statements"
)
/*
EXPECT: [Number] [Units]
OR
EXPECT: [FUNCTION]( ...params )
*/
func AmountStatement( lexer *engine.Lexer ) ( istmt stmtd.IStatement, err error ) {
stmt := stmtd.AmountStatement{}
val, err := lexer.ReadDecimal()
if err != nil {
return
}
2022-10-21 21:58:19 +00:00
stmt.SetValue( val )
2022-10-21 16:03:06 +00:00
unit, err := lexer.ReadAlpha()
if err != nil {
return
}
2022-10-21 21:58:19 +00:00
stmt.SetUnit( unit )
2022-10-21 16:03:06 +00:00
istmt = stmt
return
}