package actions import ( engine "github.com/tgckpg/mmqlengine/mmql/engine" stmtd "github.com/tgckpg/mmqlengine/mmql/statements" ) /* EXPECT: BUY THEN EXPECT: [AmountStatement] OF [ProductStatement] THEN EXPECT: FOR [AmountStatement] THEN EXPECT: FROM [ExchangeType] THEN OPT EXPECT: [ExchangeType] THEN OPT EXPECT: [AND|OR] THEN EXPECT: [ActionExpression] THEN OPT EXPECT: FOR EVERY THEN EXPECT: [AmountType] OF [ProductType] THEN EXPECT: [SOLD|BOUGHT] FROM [ExchangeType] */ func BuyStatement( lexer *engine.Lexer ) ( istmt stmtd.IStatement, err error ) { orderStmt := stmtd.OrderStatement{} orderStmt.Action = "BUY" // AmountStatement readAmount := engine.LexerExpect{ Statements: true, Keywords: false, Brackets: false, Quotes: false, Key: "AMOUNT", } amountStmt, err := lexer.ReadStatement( &readAmount ) if err != nil { return } orderStmt.For( amountStmt ) // OF err = lexer.ReadKeyword( "OF" ) if err != nil { return } // ProductStatement readProduct := engine.LexerExpect{ Statements: true, Keywords: false, Brackets: false, Quotes: false, Key: "PRODUCT", } productStmt, err := lexer.ReadStatement( &readProduct ) if err != nil { return } orderStmt.Product( productStmt ) istmt = orderStmt return }