EnglishРусский  

   ..

   sp.tbl

   sp.txt

   spt.txt

   tblget.g

   xml.g

   xmluser.g

Данный проект закрыт! Создан новый скриптовый язык с тем же именем. Всё доступно на GitHub.
Также попробуйте нашу open source кроссплатформенную программу для создания и управления скриптами.

Реклама

Инсталлятор CreateInstall
Бесплатные и коммерческие инсталляторы

source\lib\xml\tblget.g
  1 define
  2 {
  3    NUMSYM = 256
  4 }
  5 type pos
  6 {
  7    byte state
  8    byte afunc
  9    byte retstate
 10 }
 11 /*type r
 12 {
 13    arr of str
 14 }*/
 15 global 
 16 {
 17   arr res[0,$NUMSYM] of pos
 18   uint cres = 0
 19   uint pres = 0
 20   uint mres = 0
 21   arr arbeg of str 
 22   hash names
 23   uint main
 24  //  arr ar of arr of str   
 25 } 
 26 
 27 operator pos = ( pos l r )
 28 {
 29    l.state = r.state
 30    l.afunc = r.afunc
 31    l.retstate = r.retstate
 32    return l
 33 }
 34 
 35 method pos.getpos( str s )
 36 {
 37    uint i
 38    arrstr ar 
 39    s.split( ar, '/',  /*$SPLIT_EMPTY |*/ $SPLIT_NOSYS )
 40    if *ar 
 41    {
 42       if (ar[0])[0] =='_'
 43       {
 44          this.state = names[ar[0]]
 45       }
 46       else
 47       {        
 48          this.state = ar[0].int()         
 49          if this.state != 255 && this.state
 50          { 
 51             this.state += pres 
 52          }          
 53       }
 54       this.afunc = 0
 55       this.retstate = 0 
 56       if *ar > 1
 57       {         
 58          this.afunc = ar[1].int()         
 59          if *ar > 2
 60          {
 61             this.retstate = ar[2].int()            
 62             if this.retstate != 255 && this.retstate
 63             { 
 64                this.retstate += pres               
 65             }
 66          }
 67       }
 68    }   
 69 } 
 70 
 71 func proc( str s, uint beg )
 72 {   
 73    uint i, j
 74    arrstr ar
 75    pos  p,pd
 76 
 77    s.split( ar, ',', $SPLIT_EMPTY | $SPLIT_NOSYS /*| $SPLIT_QUOTE*/ )   
 78    if beg 
 79    {
 80       i=0
 81       res.expand( $NUMSYM )
 82       pd.getpos( ar[1] )
 83       /*i=0
 84       print( ?(i,",","") + ar[i] )
 85       i=1
 86       print( ?(i,",","") + ar[i] )*/
 87       fornum j=0, $NUMSYM
 88       {
 89          res[cres,j] = pd
 90       } 
 91       p.state = cres+1
 92       //res[cres,0] = p
 93       fornum i=2, *ar
 94       {
 95          p = pd         
 96          p.getpos(ar[i])
 97          //print( ?(i,",","") + ar[i] )                  
 98          fornum j=0, *arbeg[i]
 99          {
100             res[cres, uint((arbeg[i])[j])] = p
101          }
102       }     
103       cres++
104       
105    }
106    else
107    {    
108       arbeg.cut( 0 )
109       arbeg.expand( *ar )
110       if ar[0] == "_main" {
111          main = 1
112          mres = cres
113          //cres = 0         
114       }
115        
116       names[ar[0]] = cres+1
117       
118       i=0
119       print( ?(i,",","") + ar[i] )
120       i=1
121       print( ?(i,",","") + ar[i] )
122       fornum i=2, *ar
123       {
124          print( ?(i,",","") + ar[i] )
125          arbeg[i].setlen(0)
126          if (ar[i])[0] == 0x27
127          {            
128             arbeg[i].appendch((ar[i])[1])
129          }
130          elif (ar[i])[0] == 'q'
131          {          
132             arbeg[i].appendch( 0x27 )  
133          }
134          elif (ar[i])[0] == 's'
135          {  
136             arbeg[i].appendch(0x20)          
137             arbeg[i].appendch(0x09)            
138             arbeg[i].appendch(0x0D)
139             arbeg[i].appendch(0x0A)
140          }         
141       }
142       print( "\n" )
143    }   
144 }
145 
146 
147 func tblget<main>
148 {
149    str s, curs
150    uint i, j, beg = 0
151    uint state = 0
152    
153    s.read( "sp.txt" )
154    while i < *s
155    {
156       switch state
157       {
158          case 0
159          {
160             if s[i]=='(': state = 1
161             elif s[i]=='-': state = 2
162             else
163             {    
164                i--           
165                state = 3               
166             }
167          }
168          case 1
169          {
170             if s[i]==')': state = 2
171          }
172          case 2
173          {
174             if s[i]==0x0A
175             {
176                state = 0
177                beg = 0
178                pres = cres
179             }
180          }
181          case 3
182          {          
183             if s[i] == 0x0A 
184             {
185                state = 0
186                proc( curs, beg )
187                beg = 1                         
188                curs.clear()               
189             }
190             else
191             {
192                curs.appendch( s[i])
193             }
194          }
195       } 
196       i++         
197    }
198    
199    str a
200    print( "\( cres ) \( mres )\n" )
201    fornum i=0, cres
202    {
203       fornum j=0, $NUMSYM
204       { 
205          if res[i,j].state && res[i,j].state !=255
206          {
207             if res[i,j].state > mres
208             {
209                res[i,j].state -= mres
210             }
211             else
212             {
213                res[i,j].state += cres-mres 
214             }            
215          }
216          if res[i,j].retstate && res[i,j].retstate !=255
217          {
218             if res[i,j].retstate > mres
219             {
220                res[i,j].retstate -= mres
221             }
222             else
223             {
224                res[i,j].retstate += cres-mres
225             }            
226          }         
227       }
228    }
229    res.insert( 0, (cres-mres)*$NUMSYM )
230    //mres+1
231    fornum i = 0, cres-mres
232    {
233       fornum j= 0, $NUMSYM
234       {
235          res[i,j]=res[i + cres,j]  
236       }
237    }
238    res.del( cres*$NUMSYM, (2*cres-mres)*$NUMSYM )
239 /* 
240    fornum i=0, *res/$NUMSYM
241    {
242       fornum j=0, 10
243       {
244          a.clear()
245          int2str( a, "%x ", res[i,j].state )
246          print( a )
247       }
248       print( "\n" )
249    }
250    */ 
251    res->buf.write("sp.tbl")
252    a.clear()
253    fornum j=0, 255
254    {      
255       a@" "
256       if j >= 0x20 : a.appendch( j )
257       else : a@" "      
258    }
259    a@"\n"
260    fornum i=0, *res/$NUMSYM
261    {   
262       fornum j=0, 255
263       {
264          //a.clear()
265          a.out4( "%2x", res[i,j].state )
266          //print( a )
267       }
268       a@"\n"
269    }
270    a.write( "spt.txt")
271    getch()
272 }
273 
Редактировать