This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 76454 - lexer incorrectly handle multi part string literals
Summary: lexer incorrectly handle multi part string literals
Status: CLOSED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Vladimir Voskresensky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-16 23:03 UTC by Vladimir Voskresensky
Modified: 2008-01-11 13:37 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Voskresensky 2006-05-16 23:03:55 UTC
lexer should correctly create StringLiterals for following examples

#define likely(x) (x)
#define unlikely(x) (x)

void ddd_assert_fail (const char *assertion, const char *file,
		      unsigned int line, const char *function);


#define _assert_fn ""


#define assert(ex) \
_ASSERT_VOID_CAST(unlikely(ex) ? \
  0 : \
  (ddd_assert_fail (#ex, __FILE__, __LINE__, _assert_fn), 0) \
  )

void foo() { 
    if ("1" "2" 
         "3" != 0) {
      assert ( "1" "2" 
             "3" != 0);
    }
}

Note:
need to update StringLiteral rule like:
StringLiteral
        :
            (
                (options{warnWhenFollowAmbig = false; }: 
                    StringPart 
                    (options{warnWhenFollowAmbig = false; }: 
                            InterStringWhitespace
                    )*
                )+
            )
        ;

protected
InterStringWhitespace	
	:	(	(' ' |'\t' | '\f')
			// handle newlines
		|	(        
                           { (LA(1) == '\r') && (LA(2) == '\n') }? "\r\n"  // MS
			|   '\r'    // Mac
			|   '\n'    // Unix 
			)	{ newline(); }
		)	
                { 
                        $setType(Token.SKIP);
                }
	;

protected
StringPart
	:	'"'
		( Escape
		|	(	"\\\r\n"   // MS 
			|	"\\\r"     // MAC
			|	"\\\n"     // Unix
			)	{newline();}
		|	~('"' | '\r' | '\n' | '\\')
		)*
		'"'
	;

+ need to handle correct creating of parameters in MacroExpander.addParam.
string should be correctly concatenated. Is it possible to do on lexer level?
Comment 1 Vladimir Voskresensky 2006-05-19 16:04:33 UTC
Integrated fixes.
The problems like:
if ("1" "2" 
         "3" != 0) {
    }
ddd_assert_fail("1\"1a""2"  "3"             
                        "4"
                        "5"
                         "6", 0, 0, 0);
where ddd_assert is name of function are solved;
problems like 
      assert ( "1" "2" 
             "3" != 0);
where assert is macro with params fixed with workaround.

P.S. mark issue as started, not resolved, need to review of FIXUP
Comment 2 Vladimir Voskresensky 2006-11-07 16:14:26 UTC
fixed in APT lexer