github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/lang/expressions/block.go (about) 1 package expressions 2 3 import ( 4 "github.com/lmorg/murex/lang" 5 "github.com/lmorg/murex/lang/expressions/functions" 6 ) 7 8 type BlockT struct { 9 Functions []functions.FunctionT 10 expression []rune 11 charPos int 12 lineN int 13 offset int 14 nextProperty functions.Property 15 } 16 17 func (blk *BlockT) nextChar() rune { 18 if blk.charPos+1 >= len(blk.expression) { 19 return 0 20 } 21 return blk.expression[blk.charPos+1] 22 } 23 24 func NewBlock(block []rune) *BlockT { 25 blk := new(BlockT) 26 blk.expression = block 27 blk.nextProperty = functions.P_NEW_CHAIN 28 return blk 29 } 30 31 func ParseBlock(block []rune) (*[]functions.FunctionT, error) { 32 blk := NewBlock(block) 33 err := blk.ParseBlock() 34 return &blk.Functions, err 35 } 36 37 func init() { 38 lang.ParseBlock = ParseBlock 39 }