EnglishРусский  

   ..

   bnf.g

   default.g

The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

  1 /******************************************************************************
  2 *
  3 * Copyright (C) 2006, The Gentee Group. All rights reserved. 
  4 * This file is part of the Gentee open source project - http://www.gentee.com. 
  5 * 
  6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
  7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
  8 * ACCEPTANCE OF THE AGREEMENT.
  9 *
 10 * ID: standard 17.11.06 0.0.A.
 11 *
 12 * Author: Alexey Krivonogov ( gentee )
 13 *
 14 ******************************************************************************/
 15 
 16 
 17 func str bnfparser( str in out )
 18 {
 19    uint i brack mode quote
 20 
 21    str   squote = "<span class = \"darkblue\">'</span>"
 22    
 23    fornum i, *in
 24    {
 25       if mode && ( in[i] < 'a' || in[i] > 'z' )
 26       {
 27          out += "</span>"
 28          mode = 0         
 29       }
 30       if "<".eqlenign( in.ptr() + i )
 31       {
 32          brack++
 33          out += "<"
 34          i += 3
 35          continue
 36       }
 37       if "0x".eqlenign( in.ptr() + i )
 38       {
 39          str val
 40          val.copy( in.ptr() + i, 4 )
 41          out += "<span class = \"darkblue\">\(val)</span>"
 42          i += 3
 43          continue
 44       }
 45       if in[i] == 0x27
 46       {
 47          if !quote && in[i + 1] == 0x27
 48          {
 49             out += "\(squote)<span class = \"blue\">'</span>\(squote)"
 50             i += 2
 51             continue                        
 52          }
 53 
 54          if !quote
 55          {
 56             out += "<span class = \"blue\">"
 57          }
 58          else
 59          {
 60             out += "</span>"
 61          }
 62          out += squote
 63          quote = !quote         
 64          continue
 65       }      
 66       if !mode && in[i] >= 'a' && in[i] <= 'z' && !brack 
 67       {
 68          out += "<span class = \"blue\">"
 69          mode = 1
 70       }
 71       if ">".eqlenign( in.ptr() + i )
 72       {
 73          if brack : brack--
 74          out += ">"
 75          i += 3
 76          continue
 77       }
 78       out.appendch( in[i] )
 79    }
 80    if mode == 1 : out += "</span>"
 81    return out
 82 }
 83 
 84 
 85 text bnfout( arrstr param )
 86 \{
 87    str     bnflist
 88    arrstr  bnfarr
 89    
 90    _gtp.get( "bnf_common", bnflist )
 91 
 92    bnfarr.loadtrim( bnflist )   
 93    foreach cur, bnfarr
 94    {
 95       arrstr  items
 96       str     stemp
 97       
 98       cur.split( items, '=', $SPLIT_FIRST | $SPLIT_NOSYS )
 99       stemp.replacech( items[1], '<', "<" )
100       items[1].replacech( stemp, '>', ">" )
101       bnfparser( items[1], stemp.clear() )
102       items.clear()
103       stemp.split( items, ':', $SPLIT_FIRST | $SPLIT_NOSYS )
104       @"<p><b>\( items[0] )</b> :\( items[1] )</p>\l"
105    }   
106 }\!   
107