| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- // package prc_comment -- процесс комментария
- package prc_comment
- import (
- "fmt"
- "log"
- "plt/lev2/vm/pos"
- "plt/lev2/vm/state_vm"
- "strings"
- )
- // PrcComment -- процесс комментария
- type PrcComment struct {
- strOut string
- }
- // NewPrcComment -- возвроащает новый процесс комментария
- func NewPrcComment() *PrcComment {
- log.Println("NewPrcComment()")
- sf := &PrcComment{}
- sf.parse()
- return sf
- }
- // Парсит инструкции в попытке извлечь комментарий
- func (sf *PrcComment) parse() {
- vmState := state_vm.VM_State
- posCur := pos.PosCur
- posCur.IncX()
- vmState.RuneInc()
- beginPosY := posCur.GetY()
- begPosX := posCur.GetX()
- out := ""
- for vmState.StrCur() != ")" {
- if vmState.StrCur() == "\n" {
- posCur.NextLine()
- }
- out += vmState.StrNext()
- posCur.IncX()
- }
- vmState.RuneInc()
- out = strings.ReplaceAll(out, "\n\n", "\n")
- sf.strOut = fmt.Sprintf("%v:%v\t#(%v)", beginPosY, begPosX, out)
- }
- // Run -- запускает процесс (комментарий)
- func (sf *PrcComment) Run() {
- fmt.Printf("%v\n", sf.strOut)
- }
|