Tuesday, April 13, 2010

Using XppScanner for lexical code parsing

The XppScanner class allows to parse X++ code in the way compiler does it. The simplest way to use it is to traverse all symbols in the given source code using iteration methods – firstSymbol() and nextSymbol(). The integer values returned by these methods are enumerated in the TokenTypes macro. For example, to check if there is “ttsbegin” statement in the code the following job can be used:

public static boolean checkTTSBegin(str _source)
{
    #TokenTypes

    XppScanner xppScanner = new XppScanner(_source);
    int symbol;

    for (symbol = xppScanner.firstSymbol(); symbol; symbol = xppScanner.nextSymbol())
    {
        if (symbol == #TTSBEGIN_SYM)
        {
            return true;
        }
    }

    return false;
}

PS. For this particular task you can, of course, use XppScanner.find() method.

8 comments:

  1. So tгavelers and tгavel business mаnagеrs are nοt open to гeсeiving communіcations from their employees.
    Ѕo, it is еsѕential to your meaning. Financіng сame ρartly fгom the ѕtatе prisоns, and
    to helρ them lіve up to it's name.

    Also visit my blog www.bandwiki.ca

    ReplyDelete
  2. Well connected to Major Expressway such as Pan-Island Expressway (PIE) and Central Expressway (CTE) to get you to places in no time.
    the interlace condo

    ReplyDelete
  3. If you need your ex-girlfriend or ex-boyfriend to come crawling back to you on their knees (even if they're dating somebody else now) you need to watch this video
    right away...

    (VIDEO) Have your ex CRAWLING back to you...?

    ReplyDelete