X-Sharp / XSharpPublic

Public repository for the source code for the XSharp Compiler, Runtime, Project System and Tools.
Apache License 2.0
112 stars 38 forks source link

Issues with INDEX ON UDC #1162

Closed cpyrgas closed 1 year ago

cpyrgas commented 1 year ago

https://www.xsharp.eu/forum/italian/3218-everything-works?start=20#24311

The INDEX ON command in dbcmd.xh is missing several clauses, as it is defined simply as

#command INDEX ON <key> TO <(file)> [<u: UNIQUE>]                       ;
      => dbCreateIndex(                                                 ;
                        <(file)>, <"key">, <{key}>,                     ;
                        IIF( <.u.>, TRUE, NIL )                           ;
                      )

I took the definition from VO:

#command INDEX ON <key>     ;
     [TAG <order>]  ;
     [TO </file/>]  ;
     [FOR <fo>]     ;
     [<all:ALL>]    ;
     [WHILE <wh>]   ;
     [NEXT <nx>]    ;
     [RECORD <rec>] ;
     [<rs:REST>]    ;
     [EVAL <ev>]    ;
     [EVERY <evr>]  ;
     [<u:UNIQUE>]   ;
     [<asd:ASCENDING>]      ;
     [<dsd:DESCENDING>]     ;
     [<lCur:USECURRENT>]    ;
     [<lAdd:ADDITIVE>]      ;
     [<lCus:CUSTOM>]        ;
     [<lNop:NOOPTIMIZE>]    ;
        ;
    => OrdCondSet( <$fo$>, <{fo}>,  ;
     [<.all.>],     ;
     <{wh}>,        ;
     <{ev}>, <evr>, ;
     RecNo(), <nx>, <rec>,  ;
     [<.rs.>], [<.dsd.>],   ;
     <.lAdd.>, [<.lCur.>], [<.lCus.>], [<.lNop.>] )      ;
    ;;  ;
       OrdCreate(<(file)>,<(order)>,<(key)>,,IF(<.u.>,.T., NIL))

FUNCTION Start() AS VOID
LOCAL cDbf AS STRING
LOCAL n AS INT
cDbf := "C:\test\index"
FErase(cDbf + ".cdx")
DbCreate(cDbf, {{"FLD","C",10,0}})
DbUseArea(TRUE,"DBFCDX",cDbf,"myalias")
FOR n := 1 UPTO 20
    DbAppend()
    FieldPut(1,AsString(20-n))
NEXT
INDEX ON FLD TAG MYORDER TO (cDbf) EVAL {||Console.WriteLine("indexing...")} EVERY 10
DbCloseArea()

This results in X# to error XS9003: Pre-processor: Result Marker 'file' not found in match list After removing the backslashes from [TO </file/>] ;, then another error is reported: error XS9002: Parser: unexpected input '$' And after removing the dollar signs from OrdCondSet( <$fo$>, <{fo}>, ;, now it seems to work as expected!

Not very familiar with the details of the preprocessor, should those be supported as in VO?

cpyrgas commented 1 year ago

Actually the UDC from X# is also included in VO. But VO also includes the extended version, which should include also in X#

RobertvanderHulst commented 1 year ago

Chris, The VO UDC is a bit different . The </file/> and <$fo$> markers are VO UDC specific and do not exist in the preprocessors of other languages.

cpyrgas commented 1 year ago

Confirmed fixed