home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Convert_VB339301182001.psc / ODL Converter / Classes / SCODLanguage.cls < prev   
Encoding:
Visual Basic class definition  |  2001-11-07  |  24.4 KB  |  700 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "ODLanguage"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = False
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Option Explicit
  15. Implements SCLangEngine
  16. Private m_colKeyWords As Collection
  17. Private m_colOperators As Collection
  18. Private r_gslLanguage As SCLanguage
  19.  
  20. Private Function SCLangEngine_StandardParse(ByVal Expression As String) As SemanticResult
  21.     SCLangEngine_StandardParse = SemanticParse(LexicalParse(Expression))
  22. End Function
  23.  
  24. Private Function SCLangEngine_SemanticParse(LexicalInput As LexicalResult) As SemanticResult
  25.     SCLangEngine_SemanticParse = SemanticParse(LexicalInput)
  26. End Function
  27.  
  28. Private Function SCLangEngine_LexicalParse(ByVal Expression As String) As LexicalResult
  29.     SCLangEngine_LexicalParse = LexicalParse(Expression)
  30. End Function
  31.  
  32. Private Property Get SCLangEngine_Language() As SCLanguage
  33.     Set SCLangEngine_Language = r_gslLanguage
  34. End Property
  35.  
  36. Private Property Set SCLangEngine_Language(ByVal v_gslLanguage As SCLanguage)
  37.     Set r_gslLanguage = v_gslLanguage
  38.     If Not v_gslLanguage Is Nothing Then
  39.         With v_gslLanguage
  40.             .AddKeyWord "", "appobject"
  41.             .AddKeyWord "", "control"
  42.             .AddKeyWord "", "defaultvalue"
  43.             .AddKeyWord "", "dllname"
  44.             .AddKeyWord "", "entry"
  45.             .AddKeyWord "", "helpstring"
  46.             .AddKeyWord "", "hidden"
  47.             .AddKeyWord "", "immediatebind"
  48.             .AddKeyWord "", "lcid"
  49.             .AddKeyWord "", "nonextensible"
  50.             .AddKeyWord "", "oleautomation"
  51.             .AddKeyWord "", "propget"
  52.             .AddKeyWord "", "propputref"
  53.             .AddKeyWord "", "readonly"
  54.             .AddKeyWord "", "restricted"
  55.             .AddKeyWord "", "source"
  56.             .AddKeyWord "", "vararg"
  57.             .AddKeyWord "", "out"
  58.             .AddKeyWord "", "in"
  59.             .AddKeyWord "", "bindable"
  60.             .AddKeyWord "", "default"
  61.             .AddKeyWord "", "displaybind"
  62.             .AddKeyWord "", "dual"
  63.             .AddKeyWord "", "helpcontext"
  64.             .AddKeyWord "", "helpfile"
  65.             .AddKeyWord "", "id"
  66.             .AddKeyWord "", "licensed"
  67.             .AddKeyWord "", "optional"
  68.             .AddKeyWord "", "propput"
  69.             .AddKeyWord "", "public"
  70.             .AddKeyWord "", "retval"
  71.             .AddKeyWord "", "requestedit"
  72.             .AddKeyWord "", "uuid"
  73.             .AddKeyWord "", "version"
  74.             .AddKeyWord "", "unsigned"
  75.             .AddKeyWord "", "long"
  76.             .AddKeyWord "", "int"
  77.             .AddKeyWord "", "BSTR"
  78.             .AddKeyWord "", "UINT"
  79.             .AddKeyWord "", "typedef"
  80.             .AddKeyWord "", "LPSTR"
  81.             .AddKeyWord "", "double"
  82.             .AddKeyWord "", "float"
  83.             .AddKeyWord "", "char"
  84.             .AddKeyWord "", "struct"
  85.             .AddKeyWord "", "enum"
  86.             .AddKeyWord "", "union"
  87.             .AddKeyWord "", "module"
  88.             .AddKeyWord "", "boolean"
  89.             .AddKeyWord "", "coclass"
  90.             .AddKeyWord "", "importlib"
  91.             .AddOperator "{", "{"
  92.             .AddOperator "}", "}"
  93.             .AddOperator "\", "\"
  94.             .AddOperator "@", "@"
  95.             .AddOperator "+", "+"
  96.             .AddOperator "-", "-"
  97.             .AddOperator "->*", "->*"
  98.             .AddOperator ".*", ".*"
  99.             .AddOperator ".", "."
  100.             .AddOperator "->", "->"
  101.             .AddOperator "==", "=="
  102.             .AddOperator "=", "="
  103.             .AddOperator ">", ">"
  104.             .AddOperator "<", "<"
  105.             .AddOperator "/", "/"
  106.             .AddOperator "*", "*"
  107.             .AddOperator "(", "("
  108.             .AddOperator ")", ")"
  109.             .AddOperator "[", "["
  110.             .AddOperator "]", "]"
  111.             .AddOperator ",", ","
  112.             .AddOperator ";", ";"
  113.             .AddOperator ":", ":"
  114.             .AddOperator "&", "&"
  115.             .AddOperator "|", "|"
  116.             .AddOperator "#", "#"
  117.             .AddOperator "!", "!"
  118.             .AddOperator "^", "^"
  119.         End With
  120.     End If
  121.     FixLanguage
  122. End Property
  123.  
  124. Public Property Get Language() As SCLanguage
  125.     Set Language = r_gslLanguage
  126. End Property
  127.  
  128. Public Property Set Language(ByVal v_gslLanguage As SCLanguage)
  129.     Set r_gslLanguage = v_gslLanguage
  130. End Property
  131.  
  132. Friend Function LexicalParse(ByVal Expression As String) As LexicalResult
  133.     Dim m_lngPosition As Long
  134.     Dim m_glpProcess As LexicalProcess
  135.     Dim m_lprResult As LexicalProcResult
  136.     Dim m_glrResult As LexicalResult
  137.     m_glpProcess.Expression = Expression
  138.     m_glpProcess.ExpressionLength = Len(Expression)
  139.     m_lngPosition = 1
  140.     m_glpProcess.CharIndex = 1
  141.     Do
  142.         m_glpProcess.Position = m_lngPosition
  143.         With m_lprResult
  144.             m_lprResult = LexicalKeyWord(m_glpProcess)
  145.             If Not .Success Then _
  146.                 m_lprResult = LexicalConstant(m_glpProcess)
  147.             If Not .Success Then _
  148.                 m_lprResult = LexicalComment(m_glpProcess)
  149.             If Not .Success Then _
  150.                 m_lprResult = LexicalIdentifier(m_glpProcess)
  151.             If Not .Success Then _
  152.                 m_lprResult = LexicalOperator(m_glpProcess)
  153.             If Not .Success Then _
  154.                 m_lprResult = LexicalString(m_glpProcess)
  155.             If Not .Success Then _
  156.                 m_lprResult = LexicalWhiteSpace(m_glpProcess)
  157.             If Not .Success Then
  158.                 m_lngPosition = m_lngPosition + 1
  159.                     '//This should NEVER happen.
  160.             ElseIf .Success Then
  161.                 AddToken m_lprResult.Token, m_glrResult.Tokens
  162.                 m_lngPosition = .NewPosition
  163.             End If
  164.         End With
  165.     Loop Until m_lngPosition > Len(Expression)
  166.     LexicalParse = m_glrResult
  167. End Function
  168.  
  169. Friend Function SemanticParse(LexicalInput As LexicalResult) As SemanticResult
  170.     
  171. End Function
  172.  
  173. Friend Function StandardParse(ByVal Expression As String) As SemanticResult
  174.     StandardParse = SemanticParse(LexicalParse(Expression))
  175. End Function
  176.  
  177. Private Function LexicalString(Process As LexicalProcess) As LexicalProcResult
  178. Declarations:
  179.     Dim m_lngPosition As Long
  180.     Dim m_strChar As String * 1
  181.     Dim m_lprResult As LexicalProcResult
  182.     Dim m_booFoundSlash As Boolean
  183.     Dim m_chiInfo As CharInfo
  184. Try:
  185.     On Error GoTo Catch
  186.     m_lngPosition = Process.Position
  187.     Do
  188.         m_strChar = Mid(Process.Expression, m_lngPosition, 1)
  189.         m_chiInfo = GetCharInfo(m_strChar)
  190.         If Process.CharIndex = 1 Then
  191.             If Not m_strChar = m_gl_CST_strOprQuote Then
  192.                 GoTo Failure
  193.             End If
  194.         Else
  195.             If m_booFoundSlash Then
  196.                 m_booFoundSlash = False
  197.             ElseIf m_strChar = m_gl_CST_strOprBackSlash Then
  198.                 m_booFoundSlash = True
  199.                 If m_lngPosition = Process.ExpressionLength Then
  200.                     GoTo Failure
  201.                 End If
  202.             ElseIf m_strChar = m_gl_CST_strOprQuote Then
  203.                 Process.CharIndex = Process.CharIndex
  204.                 GoTo Success
  205.             End If
  206.         End If
  207.         Process.CharIndex = Process.CharIndex + 1
  208.         m_lngPosition = m_lngPosition + 1
  209.     Loop Until m_lngPosition > Process.ExpressionLength
  210. Finally:
  211.     GoTo EndTry
  212. Success:
  213.     With m_lprResult
  214.         .Success = True
  215.         With .Token
  216.             .TokenType = G_LTT_String
  217.             .Value = Mid(Process.Expression, Process.Position, Process.CharIndex)
  218.             .Length = Len(.Value)
  219.         End With
  220.         .NewPosition = Process.Position + Process.CharIndex
  221.     End With
  222.     LexicalString = m_lprResult
  223.     GoTo EndTry
  224. Failure:
  225.     m_lprResult.Success = False
  226.     GoTo EndTry
  227. Catch:
  228.     m_lprResult.Success = False
  229.     GoTo EndTry
  230. EndTry:
  231.     Process.CharIndex = 1
  232.     Exit Function
  233. End Function
  234.  
  235. Private Function LexicalComment(Process As LexicalProcess) As LexicalProcResult
  236. Declarations:
  237.     Dim m_lngPosition As Long
  238.     Dim m_strChar As String * 1
  239.     Dim m_lprResult As LexicalProcResult
  240.     Dim m_lngCommentType As Long
  241.     Dim m_chiInfo As CharInfo
  242.     Dim m_lngNextItem As Long
  243.     Dim m_lngNextUnderItem As Long
  244.     Dim m_lngCRPos As Long
  245. Try:
  246.     On Error GoTo Catch
  247.     m_lngPosition = Process.Position
  248.     m_strChar = Mid(Process.Expression, m_lngPosition, 1)
  249.     m_chiInfo = GetCharInfo(m_strChar)
  250.     If Process.CharIndex = 1 Then
  251.         If m_chiInfo.IsAlpha Or m_chiInfo.IsNumeric Then
  252.             GoTo Failure
  253.         ElseIf m_strChar = m_gl_CST_strOprForwardSlash Then
  254.             If Mid(Process.Expression, m_lngPosition + 1, 1) = m_gl_CST_strOprForwardSlash Then
  255.                 m_lngCommentType = 1
  256.                 GoTo Success
  257.             ElseIf Mid(Process.Expression, m_lngPosition + 1, 1) = m_gl_CST_strOprTimes Then
  258.                 m_lngCommentType = 2
  259.                 GoTo Success
  260.             End If
  261.         End If
  262.     End If
  263.     Process.CharIndex = Process.CharIndex + 1
  264. Finally:
  265.     GoTo EndTry
  266. Success:
  267.     With m_lprResult
  268.         If m_lngCommentType = 1 Then
  269.             m_lngNextItem = Process.Position
  270.             m_lngNextUnderItem = m_lngNextItem
  271.             m_lngCRPos = m_lngNextItem
  272.             Do
  273.                 m_lngNextItem = NextCarrageReturn(Process.Expression, m_lngCRPos)
  274.                 m_lngNextUnderItem = InStr(m_lngCRPos, Process.Expression, " \" & vbCr)
  275.                 m_lngCRPos = m_lngNextItem + 1
  276.             Loop Until m_lngNextItem = 0 Or (m_lngNextUnderItem > m_lngNextItem) Or m_lngNextUnderItem = 0
  277.             If m_lngNextItem = 0 Then
  278.                 Process.CharIndex = (Process.ExpressionLength - (Process.Position - 1))
  279.             Else
  280.                 Process.CharIndex = ((m_lngNextItem - 1) - (Process.Position - 1))
  281.             End If
  282.         Else
  283.             Process.CharIndex = InStr(Process.Position, Process.Expression, "*/") - (Process.Position - 1) + 1
  284.             If Process.CharIndex <= 0 Then
  285.                 Process.CharIndex = Process.ExpressionLength - (Process.Position - 1)
  286.             End If
  287.         End If
  288.         .Success = True
  289.         .NewPosition = Process.Position + Process.CharIndex
  290.         With .Token
  291.             .Value = Mid(Process.Expression, Process.Position, Process.CharIndex)
  292.             .TokenType = G_LTT_Comment
  293.             .Length = Len(.Value)
  294.         End With
  295.     End With
  296.     LexicalComment = m_lprResult
  297.     GoTo EndTry
  298. Failure:
  299.     m_lprResult.Success = False
  300.     GoTo EndTry
  301. Catch:
  302.     m_lprResult.Success = False
  303.     GoTo EndTry
  304. EndTry:
  305.     Process.CharIndex = 1
  306.     Exit Function
  307. End Function
  308.  
  309. Private Function LexicalConstant(Process As LexicalProcess) As LexicalProcResult
  310. Declarations:
  311.     Dim m_lngPosition As Long
  312.     Dim m_strChar As String * 1
  313.     Dim m_lprResult As LexicalProcResult
  314.     Dim m_booIsHex As Boolean
  315.     Dim m_chiInfo As CharInfo
  316.     Dim m_booIsNegative As Boolean
  317. Try:
  318.     On Error GoTo Catch
  319.     m_lngPosition = Process.Position
  320.     Do
  321.         m_strChar = Mid(Process.Expression, m_lngPosition, 1)
  322.         m_chiInfo = GetCharInfo(m_strChar)
  323.         If Process.CharIndex = 1 Then
  324.             If m_strChar = m_gl_CST_strOprMinus And Not Process.Position = Process.ExpressionLength Then
  325.                 m_booIsNegative = True
  326.             ElseIf Not m_chiInfo.IsNumeric Then
  327.                 GoTo Failure
  328.             ElseIf m_lngPosition = Process.ExpressionLength Then
  329.                 Process.CharIndex = Process.CharIndex + 1
  330.                 GoTo Success
  331.             End If
  332.         Else
  333.             If Not m_booIsHex Then
  334.                 If m_booIsNegative Then
  335.                     If Not m_chiInfo.IsNumeric Then
  336.                         If Process.CharIndex = 2 Then
  337.                             m_booIsNegative = False
  338.                             GoTo Failure
  339.                         Else
  340.                             If m_strChar = vbCr Or m_strChar = vbLf Or m_strChar = m_gl_CST_strOprSpace Or IsOperator(m_strChar, m_colOperators) Or (m_lngPosition >= Process.ExpressionLength) Then
  341.                                 GoTo Success
  342.                             Else
  343.                                 GoTo Failure
  344.                             End If
  345.                         End If
  346.                     Else
  347.                         If m_lngPosition = Process.ExpressionLength Then
  348.                             Process.CharIndex = Process.CharIndex + 1
  349.                             GoTo Success
  350.                         End If
  351.                     End If
  352.                 Else
  353.                     If Not m_chiInfo.IsNumeric Then
  354.                         If Not Process.CharIndex = 2 And m_strChar = "x" Then
  355.                             If m_strChar = vbCr Or m_strChar = vbLf Or m_strChar = m_gl_CST_strOprSpace Or IsOperator(m_strChar, m_colOperators) Then
  356.                                 GoTo Success
  357.                             Else
  358.                                 GoTo Failure
  359.                             End If
  360.                         Else
  361.                             m_booIsHex = True
  362.                         End If
  363.                     End If
  364.                 End If
  365.             Else
  366.                 Select Case m_strChar
  367.                     Case "0" To "9", "a" To "f", "A" To "F"
  368.                         
  369.                     Case Else
  370.                         If Process.CharIndex = 3 Then
  371.                             '//If it's suspected of being a hexadecimal value,
  372.                             '//and the first item after the 'x' isn't a hexa-
  373.                             '//decimal value or a decimal value, thne it's
  374.                             '//clearly not valid.
  375.                             GoTo Failure
  376.                         End If
  377.                         If m_strChar = vbCr Or m_strChar = vbLf Or m_strChar = m_gl_CST_strOprSpace Or IsOperator(m_strChar, m_colOperators) Then
  378.                             GoTo Success
  379.                         Else
  380.                             GoTo Failure
  381.                         End If
  382.                 End Select
  383.             End If
  384.         End If
  385.         Process.CharIndex = Process.CharIndex + 1
  386.         m_lngPosition = m_lngPosition + 1
  387.     Loop Until m_lngPosition > Process.ExpressionLength
  388. Finally:
  389.     GoTo Success
  390. Success:
  391.     With m_lprResult
  392.         .Success = True
  393.         .NewPosition = Process.Position + Process.CharIndex - 1
  394.         If Not m_booIsHex Then
  395.             With .Token
  396.                 .Length = Process.CharIndex - 1
  397.                 .Value = CLng(Mid(Process.Expression, Process.Position, Process.CharIndex - 1))
  398.                 .TokenType = G_LTT_Constant
  399.                 .Position = Process.Position
  400.             End With
  401.         Else
  402.             With .Token
  403.                 .Length = Process.CharIndex - 1
  404.                 .Value = (Mid(Process.Expression, Process.Position, Process.CharIndex - 1))
  405.                 .Value = CLng("&H" & Mid(.Value, 3))
  406.                 .TokenType = G_LTT_Constant
  407.                 .Position = Process.Position
  408.                 .CustID = True
  409.                     '//Internal... signifies that it was a number in 0x0N
  410.                     '//form
  411.             End With
  412.         End If
  413.     End With
  414.     LexicalConstant = m_lprResult
  415.     GoTo EndTry
  416. Failure:
  417.     m_lprResult.Success = False
  418.     GoTo EndTry
  419. Catch:
  420.     m_lprResult.Success = False
  421.     GoTo EndTry
  422. EndTry:
  423.     Process.CharIndex = 1
  424.     Exit Function
  425. End Function
  426.  
  427. Private Function LexicalWhiteSpace(Process As LexicalProcess) As LexicalProcResult
  428. Declarations:
  429.     Dim m_lngPosition As Long
  430.     Dim m_strChar As String * 1
  431.     Dim m_lprResult As LexicalProcResult
  432.  
  433.     Dim m_chiInfo As CharInfo
  434. Try:
  435.     On Error GoTo Catch
  436.     m_lngPosition = Process.Position
  437.     Do
  438.         m_strChar = Mid(Process.Expression, m_lngPosition, 1)
  439.         m_chiInfo = GetCharInfo(m_strChar)
  440.         Select Case m_strChar
  441.             Case m_gl_CST_strOprSpace, vbTab, vbCr, vbLf
  442.             Case Else
  443.                 If Process.CharIndex > 1 Then
  444.                     Process.CharIndex = Process.CharIndex - 1
  445.                     GoTo Success
  446.                 Else
  447.                     GoTo Failure
  448.                 End If
  449.         End Select
  450.         Process.CharIndex = Process.CharIndex + 1
  451.         m_lngPosition = m_lngPosition + 1
  452.     Loop Until m_lngPosition > Process.ExpressionLength
  453. Finally:
  454.     GoTo Success
  455. Success:
  456.     With m_lprResult
  457.         .Success = True
  458.         .NewPosition = Process.Position + Process.CharIndex
  459.         With .Token
  460.             .Value = Mid(Process.Expression, Process.Position, Process.CharIndex)
  461.             .TokenType = G_LTT_WhiteSpace
  462.             .Length = Process.CharIndex
  463.             .Position = Process.Position
  464.         End With
  465.     End With
  466.     LexicalWhiteSpace = m_lprResult
  467.     GoTo EndTry
  468. Failure:
  469.     m_lprResult.Success = False
  470.     GoTo EndTry
  471. Catch:
  472.     m_lprResult.Success = False
  473.     GoTo EndTry
  474. EndTry:
  475.     Process.CharIndex = 1
  476.     Exit Function
  477. End Function
  478.  
  479. Private Function LexicalKeyWord(Process As LexicalProcess) As LexicalProcResult
  480. Declarations:
  481.     Dim m_lngPosition As Long
  482.     Dim m_strChar As String * 1
  483.     Dim m_lprResult As LexicalProcResult
  484.  
  485.     Dim m_chiInfo As CharInfo
  486. Try:
  487.     On Error GoTo Catch
  488.     m_lngPosition = Process.Position
  489.     Do
  490.         m_strChar = Mid(Process.Expression, m_lngPosition, 1)
  491.         m_chiInfo = GetCharInfo(m_strChar)
  492.         If Process.CharIndex = 1 Then
  493.             If (m_chiInfo.IsNumeric) Then 'And Not IsOperator(m_strChar, m_colOperators) Then
  494.                 GoTo Failure
  495.             End If
  496.         Else
  497.             Select Case True
  498.                 Case IsOperator(m_strChar, m_colOperators), m_strChar = m_gl_CST_strOprSpace, m_strChar = vbCr, m_strChar = vbLf, m_strChar = vbTab
  499.                     GoTo Success
  500.                 Case Else
  501.                     If m_lngPosition = Process.ExpressionLength Then
  502.                         Process.CharIndex = Process.CharIndex + 1
  503.                         GoTo Success
  504.                     End If
  505.             End Select
  506.         End If
  507.         Process.CharIndex = Process.CharIndex + 1
  508.         m_lngPosition = m_lngPosition + 1
  509.     Loop Until m_lngPosition > Process.ExpressionLength
  510. Finally:
  511.     GoTo EndTry
  512. Success:
  513.     With m_lprResult
  514.         .Success = True
  515.         .NewPosition = Process.Position + Process.CharIndex - 1
  516.         With .Token
  517.             .Value = Mid(Process.Expression, Process.Position, Process.CharIndex - 1)
  518.             If Not IsKeyword(.Value, m_colKeyWords) Then
  519.                 GoTo Failure
  520.             End If
  521.             .Length = Len(.Value)
  522.             .TokenType = G_LTT_Keyword
  523.             .Position = Process.Position
  524.         End With
  525.     End With
  526.     LexicalKeyWord = m_lprResult
  527.     GoTo EndTry
  528. Failure:
  529.     m_lprResult.Success = False
  530.     GoTo EndTry
  531. Catch:
  532.     m_lprResult.Success = False
  533.     GoTo EndTry
  534. EndTry:
  535.     Process.CharIndex = 1
  536.     Exit Function
  537. End Function
  538.  
  539. Private Function LexicalOperator(Process As LexicalProcess) As LexicalProcResult
  540. Declarations:
  541.     Dim m_lngPosition As Long
  542.     Dim m_strChar As String * 1
  543.     Dim m_lprResult As LexicalProcResult
  544.     Dim m_lngSuccessChar As Long
  545.     Dim m_chiInfo As CharInfo
  546.     Dim m_strExp As String
  547. Try:
  548.     On Error GoTo Catch
  549.     m_lngPosition = Process.Position
  550.     Do
  551.         m_strChar = Mid(Process.Expression, m_lngPosition, 1)
  552.         m_chiInfo = GetCharInfo(m_strChar)
  553.         m_strExp = m_strExp & m_strChar
  554.         If Process.CharIndex = 1 Then
  555.             If IsOperator(m_strChar, m_colOperators) Then
  556.                 m_lngSuccessChar = Process.CharIndex
  557.                 If Process.Position = Process.ExpressionLength Then
  558.                     Process.CharIndex = Process.CharIndex + 1
  559.                     GoTo Success
  560.                 End If
  561.             End If
  562.         Else
  563.             If Not IsOperator(m_strExp, m_colOperators) Then
  564.                 GoTo Success
  565.             Else
  566.                 m_lngSuccessChar = Process.CharIndex + 1
  567.             End If
  568.         End If
  569.         Process.CharIndex = Process.CharIndex + 1
  570.         m_lngPosition = m_lngPosition + 1
  571.     Loop Until m_lngPosition > Process.ExpressionLength
  572. Finally:
  573.     GoTo EndTry
  574. Success:
  575.     With m_lprResult
  576.         .Success = True
  577.         .NewPosition = Process.Position + Process.CharIndex - 1
  578.         With .Token
  579.             .Length = Process.CharIndex - 1
  580.             .Position = Process.Position
  581.             .TokenType = G_LTT_Operator
  582.             .Value = Mid(Process.Expression, Process.Position, Process.CharIndex - 1)
  583.             If Not IsOperator(.Value, m_colOperators) Then
  584.                 If m_lngSuccessChar = 0 Then
  585.                     GoTo Failure
  586.                 Else
  587.                     Process.CharIndex = m_lngSuccessChar
  588.                     GoTo Success
  589.                         '//update
  590.                 End If
  591.             End If
  592.         End With
  593.     End With
  594.     LexicalOperator = m_lprResult
  595.     GoTo EndTry
  596. Failure:
  597.     m_lprResult.Success = False
  598.     GoTo EndTry
  599. Catch:
  600.     m_lprResult.Success = False
  601.     GoTo EndTry
  602. EndTry:
  603.     Process.CharIndex = 1
  604.     Exit Function
  605. End Function
  606.  
  607. Private Function LexicalIdentifier(Process As LexicalProcess) As LexicalProcResult
  608. Declarations:
  609.     Dim m_lngPosition As Long
  610.     Dim m_strChar As String * 1
  611.     Dim m_lprResult As LexicalProcResult
  612.     Dim m_chiInfo As CharInfo
  613. Try:
  614.     On Error GoTo Catch
  615.     m_lngPosition = Process.Position
  616.     Do
  617.         m_strChar = Mid(Process.Expression, m_lngPosition, 1)
  618.         m_chiInfo = GetCharInfo(m_strChar)
  619.         If Process.CharIndex = 1 Then
  620.             If m_chiInfo.IsNumeric Or Not (m_chiInfo.IsAlpha Or m_chiInfo.IsUnderscore) Then
  621.                 GoTo Failure
  622.             ElseIf Process.Position = Process.ExpressionLength Then
  623.                 Process.CharIndex = Process.CharIndex + 1
  624.                 GoTo Success
  625.             End If
  626.         Else
  627.             Select Case True
  628.                 Case IsOperator(m_strChar, m_colOperators), m_strChar = m_gl_CST_strOprSpace, m_strChar = vbCr, m_strChar = vbLf, m_strChar = vbTab
  629.                     GoTo Success
  630.                 Case Else
  631.                     If m_lngPosition = Process.ExpressionLength Then
  632.                         Process.CharIndex = Process.CharIndex + 1
  633.                         GoTo Success
  634.                     End If
  635.             End Select
  636.         End If
  637.         Process.CharIndex = Process.CharIndex + 1
  638.         m_lngPosition = m_lngPosition + 1
  639.     Loop Until m_lngPosition > Process.ExpressionLength
  640. Finally:
  641.     GoTo EndTry
  642. Success:
  643.     With m_lprResult
  644.         .Success = True
  645.         .NewPosition = Process.Position + Process.CharIndex - 1
  646.         With .Token
  647.             .Value = Mid(Process.Expression, Process.Position, Process.CharIndex - 1)
  648.             .Length = Len(.Value)
  649.             .TokenType = G_LTT_Identifier
  650.             .Position = Process.Position
  651.         End With
  652.     End With
  653.     LexicalIdentifier = m_lprResult
  654.     GoTo EndTry
  655. Failure:
  656.     m_lprResult.Success = False
  657.     GoTo EndTry
  658. Catch:
  659.     m_lprResult.Success = False
  660.     GoTo EndTry
  661. EndTry:
  662.     Process.CharIndex = 1
  663.     Exit Function
  664. End Function
  665.  
  666. Private Sub AddToken(Token As LexicalToken, Tokens As LexicalTokens)
  667.     With Tokens
  668.         If .Count = 0 Then
  669.             ReDim .Tokens(1 To .Count + 1)
  670.         Else
  671.             ReDim Preserve .Tokens(1 To .Count + 1)
  672.         End If
  673.         .Count = .Count + 1
  674.         With .Tokens(.Count)
  675.             .CustID = Token.CustID
  676.             .Length = Token.Length
  677.             .Position = Token.Position
  678.             .TokenType = Token.TokenType
  679.             .Value = Token.Value
  680.         End With
  681.     End With
  682. End Sub
  683.  
  684. Public Sub FixLanguage()
  685.     Dim m_lngLoop As Long
  686.     Set m_colKeyWords = New Collection
  687.     Set m_colOperators = New Collection
  688.     For m_lngLoop = 1 To Language.KeywordList.Count
  689.         m_colKeyWords.Add Language.KeywordList.Keywords(m_lngLoop).StringValue, "k" & LCase(Language.KeywordList.Keywords(m_lngLoop).StringValue)
  690.     Next
  691.     For m_lngLoop = 1 To Language.OperatorList.Count
  692.         m_colOperators.Add Language.OperatorList.Operators(m_lngLoop).Value, "o" & LCase(Language.OperatorList.Operators(m_lngLoop).Value)
  693.     Next
  694.     'Debug.Print m_colKeyWords.Count; m_colOperators.Count
  695. End Sub
  696.  
  697. Public Property Get OperatorCol() As Collection
  698.     Set OperatorCol = m_colOperators
  699. End Property
  700.