Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various Cpp/C target fixes #145

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open

Various Cpp/C target fixes #145

wants to merge 54 commits into from

Commits on Jul 27, 2014

  1. When you name your source files *.c, MSVC (2010) assumes it's compili…

    …ng C, which means C89. All block-local variables need to be declared at the beginning of your functions.
    
    Or at begginning of {} block.
    ibre5041 committed Jul 27, 2014
    Configuration menu
    Copy the full SHA
    f03d333 View commit details
    Browse the repository at this point in the history
  2. Fix memory leak when using lexer rule label references.

    Inspired by bennyk. Since this patch uses std::unique_ptr the build now requires
    a compiler supporting at least some of C++11 features.
    ibre5041 committed Jul 27, 2014
    Configuration menu
    Copy the full SHA
    f5d2f90 View commit details
    Browse the repository at this point in the history
  3. Fix lexer labels onto EOF token

    + minor fix - remover StringTemplate warning in matchSet/terminalOptions
    ibre5041 committed Jul 27, 2014
    Configuration menu
    Copy the full SHA
    700d2df View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    0c90ab8 View commit details
    Browse the repository at this point in the history
  5. Fix to lexer label refs(array form)

    += operator
    ibre5041 committed Jul 27, 2014
    Configuration menu
    Copy the full SHA
    c243a87 View commit details
    Browse the repository at this point in the history
  6. Add test for lexer rule labels

    Python target used as an example
    ibre5041 committed Jul 27, 2014
    Configuration menu
    Copy the full SHA
    670347a View commit details
    Browse the repository at this point in the history
  7. lexer token names

    ibre5041 committed Jul 27, 2014
    Configuration menu
    Copy the full SHA
    0ef2d9f View commit details
    Browse the repository at this point in the history
  8. fix for filtering option

    ibre5041 committed Jul 27, 2014
    Configuration menu
    Copy the full SHA
    5b60623 View commit details
    Browse the repository at this point in the history
  9. fuzzy lexer test

    ibre5041 committed Jul 27, 2014
    Configuration menu
    Copy the full SHA
    dd3e20a View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    9420200 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    c93830e View commit details
    Browse the repository at this point in the history
  12. Do not use EOF macro in generated code

    = The current code depends on the fact that EOF is #define EOF -1 is some standart C headers
    = While generated enums use EOF_TOKEN
    = Moreover EOF(-1) is signed value while LA an other methods return ANTLR_UINT32, this cause plenty of compiler warnings
    = Moreover clang++11 refuses compile code like this:
    
        switch(this->LA(1)
        {
        case EOF: // -1
        ...
    
    This patch sets EOF_TOKEN = std::numerical_limits<ANTLR_UINT32>::max()
    All generated local varibles are of type ANTLR_UINT32 (instead of int)
    Generated conditions use EOF_TOKEN instead if pure EOF
    ibre5041 committed Jul 27, 2014
    Configuration menu
    Copy the full SHA
    e431dd4 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    9c9e336 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    6a4485d View commit details
    Browse the repository at this point in the history
  15. AST memory management

    ibre5041 committed Jul 27, 2014
    Configuration menu
    Copy the full SHA
    e35f17a View commit details
    Browse the repository at this point in the history
  16. AST tests

    ibre5041 committed Jul 27, 2014
    Configuration menu
    Copy the full SHA
    bec7e9c View commit details
    Browse the repository at this point in the history
  17. Memory leak fix.

    Allocate tree storage only withing context of the root grammar.
    ibre5041 committed Jul 27, 2014
    Configuration menu
    Copy the full SHA
    0b4952b View commit details
    Browse the repository at this point in the history
  18. avoid compiler warning

    ibre5041 committed Jul 27, 2014
    Configuration menu
    Copy the full SHA
    508797d View commit details
    Browse the repository at this point in the history

Commits on Aug 13, 2014

  1. Fix dirty flag setting

    SEGFAULT fix - m_dirty flag (align with Java target)
    ibre5041 committed Aug 13, 2014
    Configuration menu
    Copy the full SHA
    44ffe27 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0626d13 View commit details
    Browse the repository at this point in the history
  3. Performance improvement - do not alloc new instances of std::string i…

    …n CommonToken::getText()
    ibre5041 committed Aug 13, 2014
    Configuration menu
    Copy the full SHA
    7f32b85 View commit details
    Browse the repository at this point in the history
  4. Debug print

    ibre5041 committed Aug 13, 2014
    Configuration menu
    Copy the full SHA
    17dcc84 View commit details
    Browse the repository at this point in the history
  5. nextNode nextTree fix

    ibre5041 committed Aug 13, 2014
    Configuration menu
    Copy the full SHA
    3c713e3 View commit details
    Browse the repository at this point in the history
  6. Segfault fix

    Explanation:
    For code(using labels e1, e2) like this:
    
    sample_clause
        :    sample_key block_key?
            LEFT_PAREN e1=expression (COMMA e2=expression)? RIGHT_PAREN
            seed_part?
            -> ^(sample_key block_key? ^(EXPR $e1) ^(EXPR $e2)? seed_part?)
        ;
    
    ANTLR generates code like this:
    	e1=expression();
    	...
    	if ( this->get_backtracking()==0 ) stream_expression.add(e1.tree);
    	...
    	...
            // AST REWRITE
            // elements: e1, e2, block_key, sample_key, seed_part
            // token labels:
            // rule labels: retval, e1, e2
            // token list labels:
            // rule list labels:
            // wildcard labels:
            if ( this->get_backtracking()==0 ) {
                retval.tree = std::move(root_0);
                RewriteRuleSubtreeStream<ImplTraits> stream_retval(get_psrstate()->get_treeAdaptor(), "rule retval",retval.tree); // retval
                RewriteRuleSubtreeStream<ImplTraits> stream_e1(get_psrstate()->get_treeAdaptor(), "rule e1",e1.tree); // rewrite alias
                RewriteRuleSubtreeStream<ImplTraits> stream_e2(get_psrstate()->get_treeAdaptor(), "rule e2",e2.tree); // rewrite alias
    	...
    
    The variable e1 of type expression_return is assigned into two different SubTreeStreams.
    Since destructive copying is used(unique_ptr) the second assignment inserts NULL ptr into stream_e1.
    
    A new variable of type TreeType* (pure pointer) is added. A value of this pointer is used ONLY when
    inserting a tree into alias'es RewriteRuleSubtreeStream. When there are no aliases declared in the rule the "last pointer" remains unused.
    When inserting TreeTypePtr into a stream value is moved. When inserting a pure pointer into the aliases stream the whole tree is deeply dupped
    (assuming that the original tree was already moved into some other RewriteRuleSubtreeStream).
    
    New result:
            if ( this->get_backtracking()==0 ) {
                retval.tree = std::move(root_0);
                RewriteRuleSubtreeStream<ImplTraits> stream_retval(get_psrstate()->get_treeAdaptor(), "rule retval",retval.tree); // retval
                RewriteRuleSubtreeStream<ImplTraits> stream_e1(get_psrstate()->get_treeAdaptor(), "rule e1",e1_last); // rewrite alias
                RewriteRuleSubtreeStream<ImplTraits> stream_e2(get_psrstate()->get_treeAdaptor(), "rule e2",e2_last); // rewrite alias
    
    Note: we have also deal with this situation.
    
    unpivot_in_elements
        :   (    column_name
            |    LEFT_PAREN column_name (COMMA column_name)* RIGHT_PAREN
            )
            (     as_key
             (    constant
             |    (LEFT_PAREN)=> LEFT_PAREN constant (COMMA constant)* RIGHT_PAREN
             )
            )?
            -> column_name+ ^(PIVOT_ALIAS constant+)?
        ;
    
    The AST tree contains multiple instances of "column_name".
    RewriteRuleSubtreeStream can not contain reference(pointer) into matched tree as it would get overwritten
    in every "loop". It really needs to be moved.
    ibre5041 committed Aug 13, 2014
    Configuration menu
    Copy the full SHA
    3b7cc8d View commit details
    Browse the repository at this point in the history
  7. memory leak fix

    ibre5041 committed Aug 13, 2014
    Configuration menu
    Copy the full SHA
    470eff5 View commit details
    Browse the repository at this point in the history

Commits on Aug 15, 2014

  1. Configuration menu
    Copy the full SHA
    c29d448 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9ba24c5 View commit details
    Browse the repository at this point in the history
  3. Cleanup

    - unused #define macros removed
    - unused class templates removed
    - unused #include-s removed
    ibre5041 committed Aug 15, 2014
    Configuration menu
    Copy the full SHA
    52eac3d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    11b73bf View commit details
    Browse the repository at this point in the history
  5. Sync tests with latest changes

    = note: macros ANTLR_ENC_* are no more used
    =       use enums antlr3::ENC_* instead
    ibre5041 committed Aug 15, 2014
    Configuration menu
    Copy the full SHA
    c28a3ef View commit details
    Browse the repository at this point in the history
  6. Force all enum values (including EOF_TOKEN) to be unsigned

    - removes compiler warning
    ibre5041 committed Aug 15, 2014
    Configuration menu
    Copy the full SHA
    1ecc77e View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    1e1405f View commit details
    Browse the repository at this point in the history
  8. fix for BLOCK[$lc,"BLOCK"]

    create( ANTLR_UINT32 tokenType, const CommonTokenType* fromToken, const char* text);
    ibre5041 committed Aug 15, 2014
    Configuration menu
    Copy the full SHA
    fff2271 View commit details
    Browse the repository at this point in the history

Commits on Aug 16, 2014

  1. Configuration menu
    Copy the full SHA
    e33569b View commit details
    Browse the repository at this point in the history

Commits on Aug 28, 2015

  1. Function name aligned

    _LA renamed to LA
    
    Conflicts:
    	runtime/Cpp/include/antlr3intstream.inl
    ibre5041 committed Aug 28, 2015
    Configuration menu
    Copy the full SHA
    1e6ddad View commit details
    Browse the repository at this point in the history
  2. Function name aligned

        _LT renamed to LT
    
    Conflicts:
    	runtime/Cpp/include/antlr3treeparser.inl
    ibre5041 committed Aug 28, 2015
    Configuration menu
    Copy the full SHA
    7365950 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    bfa144c View commit details
    Browse the repository at this point in the history
  4. Reduce size of rule return class. Do not keep pointer onto parser in …

    …every tree node.
    
    Conflicts:
    	tool/src/main/resources/org/antlr/codegen/templates/Cpp/Cpp.stg
    ibre5041 committed Aug 28, 2015
    Configuration menu
    Copy the full SHA
    bdaf927 View commit details
    Browse the repository at this point in the history
  5. linux headers fix

    ibre5041 committed Aug 28, 2015
    Configuration menu
    Copy the full SHA
    09e49a4 View commit details
    Browse the repository at this point in the history

Commits on Sep 4, 2015

  1. fix test s005

    ibre5041 committed Sep 4, 2015
    Configuration menu
    Copy the full SHA
    b4839bf View commit details
    Browse the repository at this point in the history
  2. add TreeTypePtr create( ANTLR_UINT32 tokenType, const CommonTokenType…

    …* fromToken, StringType const& text);
    ibre5041 committed Sep 4, 2015
    Configuration menu
    Copy the full SHA
    545bc01 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    2ed5d99 View commit details
    Browse the repository at this point in the history

Commits on Sep 5, 2015

  1. Function names aligned

    _LA renamed to LA
    _LT renamed to LT
    
        Function name aligned
    
        _LT renamed to LT
    
    test synced _LT => LT
    ibre5041 committed Sep 5, 2015
    Configuration menu
    Copy the full SHA
    9146932 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7af3cd8 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3552feb View commit details
    Browse the repository at this point in the history
  4. a006

    ibre5041 committed Sep 5, 2015
    Configuration menu
    Copy the full SHA
    14bd4a5 View commit details
    Browse the repository at this point in the history

Commits on Sep 6, 2015

  1. Configuration menu
    Copy the full SHA
    c8eabb4 View commit details
    Browse the repository at this point in the history
  2. missing create functions

    ibre5041 committed Sep 6, 2015
    Configuration menu
    Copy the full SHA
    8557bc6 View commit details
    Browse the repository at this point in the history

Commits on Sep 17, 2015

  1. Store additional information in Tokens member TokenUserDataType

    Also:
    	CommonTree<ImplTraits>::toString() calls Token's method toString() insted of getText()
    	Test a007 shows how to use Token's UserData to pass information from Tree node to Tree leaf
    	Test a007 shows how to override Tokens toString() method
    ibre5041 committed Sep 17, 2015
    Configuration menu
    Copy the full SHA
    b339647 View commit details
    Browse the repository at this point in the history

Commits on Sep 28, 2015

  1. Store UserData in Tree node

    ibre5041 committed Sep 28, 2015
    Configuration menu
    Copy the full SHA
    5cdcf00 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e28a57c View commit details
    Browse the repository at this point in the history

Commits on Sep 30, 2015

  1. Configuration menu
    Copy the full SHA
    2808ae9 View commit details
    Browse the repository at this point in the history

Commits on Mar 31, 2016

  1. Configuration menu
    Copy the full SHA
    a4d1928 View commit details
    Browse the repository at this point in the history

Commits on May 11, 2016

  1. Configuration menu
    Copy the full SHA
    45cc4eb View commit details
    Browse the repository at this point in the history