Bug 181264 - Completion nodes in switches and while statements
Summary: Completion nodes in switches and while statements
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 4.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 4.0   Edit
Assignee: Doug Schaefer CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-04-05 14:01 EDT by Bryan Wilkinson CLA
Modified: 2008-06-20 10:01 EDT (History)
3 users (show)

See Also:


Attachments
proposed patch (7.47 KB, patch)
2007-05-14 18:10 EDT, Bryan Wilkinson CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bryan Wilkinson CLA 2007-04-05 14:01:15 EDT
The GNUCSourceParser does not allow for the creation of a compeltion node in the condition of a switch statement.  The GNUCPPSourceParser does not allow for the creation of completion nodes in conditions of switch or while statements.
Comment 1 Bryan Wilkinson CLA 2007-05-14 18:10:37 EDT
Created attachment 67150 [details]
proposed patch

GNUCSourceParser and GNUCPPSourceParser now handle EOC tokens in parseWhileStatement() and parseSwitchStatement().
Comment 2 Doug Schaefer CLA 2007-05-16 15:35:35 EDT
Patch applied. Thanks, Bryan! I didn't realize the parser didn't even support content assist there. Good catch.
Comment 3 Mike Kucera CLA 2007-05-23 14:04:06 EDT
Verified that this works for the C99 parser.

The C99 grammar file has five simple grammar rules that handle all the possible cases where a completion token can occur.

ident ::= 'identifier'  | 'Completion'
']' ::=? 'RightBracket' | 'EndOfCompletion'
')' ::=? 'RightParen'   | 'EndOfCompletion'
'}' ::=? 'RightBrace'   | 'EndOfCompletion'
';' ::=? 'SemiColon'    | 'EndOfCompletion'

Basically this says that a Completion token can occur at any point where an identifier token can occur. The input token stream will always contain only EndOfCompletion tokens after a Completion token, the last 4 rules allows the parser to use the EndOfCompletion tokens to return a successful parse.

The language grammar itself is completely untouched by the content assist mechanism. The solution is completely general and does not require modification for every case where a Completion token could occur.

(Of course these grammar rules lead to tons of shift/reduce conflicts, but they are resolved by giving them higher priority by using '::=?' instead of '::=').
Comment 4 Doug Schaefer CLA 2008-06-03 14:54:23 EDT
assigning
Comment 5 Doug Schaefer CLA 2008-06-03 14:54:43 EDT
done