Product -> FinancialInstrument
This commit is contained in:
		@@ -7,14 +7,14 @@ import (
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
EXPECT: BUY
 | 
			
		||||
THEN EXPECT: [AmountStatement] OF [ProductStatement]
 | 
			
		||||
THEN EXPECT: [AmountStatement] OF [FinancialInstrumentStatement]
 | 
			
		||||
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: [AmountType] OF [FinancialInstrumentType]
 | 
			
		||||
    THEN EXPECT: [SOLD|BOUGHT] FROM [ExchangeType]
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
@@ -43,19 +43,19 @@ func BuyStatement( lexer *engine.Lexer ) ( istmt stmtd.IStatement, err error ) {
 | 
			
		||||
        return
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // ProductStatement
 | 
			
		||||
    readProduct := engine.LexerExpect{
 | 
			
		||||
    // FinancialInstrumentStatement
 | 
			
		||||
    readFI := engine.LexerExpect{
 | 
			
		||||
        Statements: true,
 | 
			
		||||
        Keywords: false,
 | 
			
		||||
        Brackets: false,
 | 
			
		||||
        Quotes: false,
 | 
			
		||||
        Key: "PRODUCT",
 | 
			
		||||
        Key: "FINANCIAL_INSTRUMENT",
 | 
			
		||||
    }
 | 
			
		||||
    productStmt, err := lexer.ReadStatement( &readProduct )
 | 
			
		||||
    productStmt, err := lexer.ReadStatement( &readFI )
 | 
			
		||||
    if err != nil {
 | 
			
		||||
        return
 | 
			
		||||
    }
 | 
			
		||||
    orderStmt.Product( productStmt )
 | 
			
		||||
    orderStmt.FinancialInstrument( productStmt )
 | 
			
		||||
 | 
			
		||||
    istmt = orderStmt
 | 
			
		||||
    return
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ func TestBuyStatement( t *testing.T ) {
 | 
			
		||||
    supportedStmts := map[string] func( *engine.Lexer ) ( stmtd.IStatement, error ) {
 | 
			
		||||
        "BUY": BuyStatement,
 | 
			
		||||
        "AMOUNT": AmountStatement,
 | 
			
		||||
        "PRODUCT": ProductStatement,
 | 
			
		||||
        "FINANCIAL_INSTRUMENT": FinancialInstrumentStatement,
 | 
			
		||||
    }
 | 
			
		||||
    lexer.SupportedStmts = &supportedStmts
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,8 +12,8 @@ OR
 | 
			
		||||
EXPECT: [FUNCTION]( ...params )
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
func ProductStatement( lexer *engine.Lexer ) ( istmt stmtd.IStatement, err error ) {
 | 
			
		||||
    stmt := stmtd.ProductStatement{}
 | 
			
		||||
func FinancialInstrumentStatement( lexer *engine.Lexer ) ( istmt stmtd.IStatement, err error ) {
 | 
			
		||||
    stmt := stmtd.FinancialInstrumentStatement{}
 | 
			
		||||
 | 
			
		||||
    name, err := lexer.ReadAlpha()
 | 
			
		||||
    if err != nil {
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@ type AmountStatement struct {
 | 
			
		||||
    Unit string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type ProductStatement struct {
 | 
			
		||||
type FinancialInstrumentStatement struct {
 | 
			
		||||
    IStatement
 | 
			
		||||
    Name string
 | 
			
		||||
}
 | 
			
		||||
@@ -44,5 +44,5 @@ type OrderStatement struct {
 | 
			
		||||
func ( this *OrderStatement ) For( stmt IStatement ) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ( this *OrderStatement ) Product( stmt IStatement ) {
 | 
			
		||||
func ( this *OrderStatement ) FinancialInstrument( stmt IStatement ) {
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user