﻿http://billfen.wordpress.com/incremental-parsing-and-ast-repair-with-javacc-and-jjtree/
http://ibm-netrexx.215625.n3.nabble.com/NetRexx-Eclipse-status-video-td3271843.html

http://www.reddit.com/r/lisp/comments/15h1wj/on_lisps_recent_discussions_on_this_subreddit/c7nic44
The "macro system" that underlies Racket or Chez Scheme is not the pattern-matching frontend that you often use. The core concept is the "syntax object"---basically, s-expressions that are augmented with lexical information and source location information (and also a set of primitive operations on them). Macros are just functions that take syntax objects as input and produce syntax objects (and you can write them like that) that the macro expander handles specially.

http://srfi.schemers.org/srfi-49/srfi-49.html
Scheme SRFI : Indentation-sensitive syntax

==============================================================================

RexxCode *RexxSource::translate
    RexxCode *newMethod = this->translateBlock(_labels);
        while (!this->atEnd())             /* loop until end of source          */
        {
            this->directive();               /* process the directive             */
        }



void RexxSource::directive
    switch (this->keyDirective(token))
    { /* match against the directive list  */

        case DIRECTIVE_CLASS:              /* ::CLASS directive                 */
            classDirective();
            break;

        case DIRECTIVE_EXTENSION:         /* ::EXTENSION directive              */
            extensionDirective();
            break;

        case DIRECTIVE_METHOD:             /* ::METHOD directive                */
            methodDirective();
            break;

        case DIRECTIVE_ROUTINE:            /* ::ROUTINE directive               */
            routineDirective();
            break;

        case DIRECTIVE_REQUIRES:           /* ::REQUIRES directive              */
            requiresDirective();
            break;

        case DIRECTIVE_ATTRIBUTE:          /* ::ATTRIBUTE directive             */
            attributeDirective();
            break;

        case DIRECTIVE_CONSTANT:           /* ::CONSTANT directive              */
            constantDirective();
            break;

        case DIRECTIVE_OPTIONS:            /* ::OPTIONS directive               */
            optionsDirective();
            break;

        default:                           /* unknown directive                 */
            syntaxError(Error_Translation_bad_directive);
            break;
    }



RexxInstruction *RexxSource::sourceNewObject
RexxInstruction *RexxSource::instruction
this->addClause(_instruction)


Refining token->subclass :
    resolveKeyword, called by
        subKeyword : done
        keyword
        builtin : done
        resolveBuiltin : done
        condition : done
        parseOption : done
        keyDirective : done
        subDirective : done


Crash after changing builtin function codes from 1 to 2700
    CallInstruction.cpp
                builtin_index = RexxSource::resolveBuiltin(_name);
                    result = (*(RexxSource::builtinTable[builtin_index]))(context, argcount, stack);
    InstructionParser.cpp
                    builtin_index = this->builtin(token);
                    if (builtin_index != 0) refineSubclass(token, builtin_index);
        new ((void *)newObject) RexxInstructionCall(name, _condition, argCount, this->subTerms, _flags, builtin_index);
--> better to cancel this change and just assign the same subclass 2700 to each token (their value is the name of the function)


=============================================================================================


A propos du problème de reset de location


interpreter\parser\InstructionParser.cpp :
RexxInstruction *RexxSource::sayNew()
/****************************************************************************/
/* Function:  Create a SAY instruction object                               */
/****************************************************************************/
{
    RexxObject *_expression = this->expression(TERM_EOC);
    /* create a new translator object    */
    RexxInstruction *newObject = new_instruction(SAY, Say);     <-- location is copied from this->clause by RexxSource::sourceNewObject
    /* now complete this                 */
    new ((void *)newObject) RexxInstructionSay(_expression);
    return newObject; /* done, return this                 */
}


interpreter\parser\SourceFile.hpp :
#define new_instruction(name, type) this->sourceNewObject(sizeof(RexxInstruction##type), The##type##InstructionBehaviour, KEYWORD_##name)


interpreter\parser\SourceFile.cpp :
RexxInstruction *RexxSource::sourceNewObject(
    size_t        size,                /* Object size                       */
    RexxBehaviour *_behaviour,         /* Object's behaviour                */
    int            type )              /* Type of instruction               */
/******************************************************************************/
/* Function:  Create a "raw" translator instruction object                    */
/******************************************************************************/
{
  RexxObject *newObject = new_object(size);        /* Get new object                    */
  newObject->setBehaviour(_behaviour); /* Give new object its behaviour     */
                                       /* do common initialization          */
  new ((void *)newObject) RexxInstruction (this->clause, type);                             <-- location is copied from this->clause
                                       /* now protect this                  */
  OrefSet(this, this->currentInstruction, (RexxInstruction *)newObject);
  return (RexxInstruction *)newObject; /* return the new object             */
}


RexxInstructionSay::RexxInstructionSay
    RexxInstructionExpression::RexxInstructionExpression
        RexxInstruction::RexxInstruction
            RexxInternalObject::RexxInternalObject

===================================================================

The parsing is a two phases process :
Phase 1 : the tokens are extracted from the source and accumulated in the list of tokens of the clause.
    See RexxSource::nextClause
        token = this->sourceNextToken
Phase 2 : the tokens are retrieved from the list of tokens of the clause.
    See all occurences of this->nextClause();


interpreter\parser\SourceFile.cpp
RexxInstruction *RexxSource::instruction()
                case KEYWORD_NOP:          /* NOP instruction                   */
                case KEYWORD_DROP:         /* DROP instruction                  */
                case KEYWORD_SIGNAL:       /* various forms of SIGNAL           */
                case KEYWORD_CALL:         /* various forms of CALL             */
                case KEYWORD_RAISE:        /* RAISE instruction                 */
                case KEYWORD_ADDRESS:      /* ADDRESS instruction               */
                case KEYWORD_NUMERIC:      /* NUMERIC instruction               */
                case KEYWORD_TRACE:        /* TRACE instruction                 */
                case KEYWORD_DO:           /* all variations of DO instruction  */
                case KEYWORD_LOOP:         /* all variations of LOOP instruction  */
                case KEYWORD_EXIT:         /* EXIT instruction                  */
                case KEYWORD_INTERPRET:    /* INTERPRET instruction             */
                case KEYWORD_PUSH:         /* PUSH instruction                  */
                case KEYWORD_QUEUE:        /* QUEUE instruction                 */
                case KEYWORD_REPLY:        /* REPLY instruction                 */
                case KEYWORD_RETURN:       /* RETURN instruction                */
                case KEYWORD_IF:           /* IF instruction                    */
                case KEYWORD_ITERATE:      /* ITERATE instruction               */
                case KEYWORD_LEAVE:        /* LEAVE instruction                 */
                case KEYWORD_EXPOSE:       /* EXPOSE instruction                */
                case KEYWORD_FORWARD:      /* FORWARD instruction               */
                case KEYWORD_PROCEDURE:    /* PROCEDURE instruction             */
                case KEYWORD_GUARD:        /* GUARD instruction                 */
                case KEYWORD_USE:          /* USE instruction                   */
                case KEYWORD_ARG:          /* ARG instruction                   */
                case KEYWORD_PULL:         /* PULL instruction                  */
                case KEYWORD_PARSE:        /* PARSE instruction                 */
                case KEYWORD_SAY:          /* SAY instruction                   */
                case KEYWORD_OPTIONS:      /* OPTIONS instruction               */
                case KEYWORD_SELECT:       /* SELECT instruction                */
                case KEYWORD_WHEN:         /* WHEN in an SELECT instruction     */
                case KEYWORD_OTHERWISE:    /* OTHERWISE in a SELECT             */
                case KEYWORD_ELSE:         /* unexpected ELSE                   */
                case KEYWORD_END:          /* END for a block construct         */
                case KEYWORD_THEN:         /* unexpected THEN                   */

Il y a une équivalence avec les fichiers *.hpp dans interpreter\instructions
sauf pour ces cas :
                case KEYWORD_LOOP:         /* all variations of LOOP instruction  */
                case KEYWORD_PUSH:         /* PUSH instruction                  */
                case KEYWORD_ITERATE:      /* ITERATE instruction               */
                case KEYWORD_ARG:          /* ARG instruction                   */
                case KEYWORD_PULL:         /* PULL instruction                  */
                case KEYWORD_WHEN:         /* WHEN in an SELECT instruction     */
    AssignmentInstruction
    ClassDirective
    CommandInstruction
    DoBlock
    EndIf
    ExtensionDirective
    LabelInstruction
    LibraryDirective
    MessageInstruction
    ParseTarget
    ParseTrigger
    RequiresDirective
    RexxDirective
    RexxInstruction


interpreter\parser\Scanner.cpp
RexxSource::characterTable[]
Cette table est utilisée pour scanner un symbol :
- elle renvoie 0 pour un caractère qui n'est pas autorisé dans un symbol.
- elle convertit les minuscules en majuscules.


interpreter\parser\Scanner.cpp
RexxSource::sourceNextToken
-->
gère les symboles, les strings, ...


interpreter\parser\Scanner.cpp
RexxSource::locateToken


interpreter\parser\SourceFile.cpp
RexxSource::commonString
Stocke tous les symboles, toutes les chaines de caractères dans
RexxDirectory   *strings;            /* common pool of created strings    */
--> le but est d'avoir une valeur unique de chaque chaîne
