Opened 14 years ago

Closed 14 years ago

#121 closed task (fixed)

redesign treatment of different parsing modes

Reported by: Peter Johansson Owned by: Peter Johansson
Priority: major Milestone: 0.6
Component: core Version: trunk
Keywords: Cc:

Description (last modified by Peter Johansson)

needed for #122

A comment is detected by identifying its start code and its end code. A parsing mode is characterized by a set of such start- and end- code.

Therefore, we should replace all the different mode functions in Parser with a general function taking a vector<pair<string,string>>.

A question we need to resolve is when we have several pairs of start- end- code, say 2.

Then what happens if we have a line like this:

start1 some comment start2 some comment end1 bla bla

Is then the last "bla bla" comment or code? Well, let's try with a typical C++ code with start and end codes "/*" "*/" and "" "\n" and we get

/* some comment // some comment */ bla bla

Clearly "bla bla" must be treated as code since the "*/" closes "/*" and overrides "". On the other hand if we swap the two pairs of start and end codes we get

/// some comment /* some comment \n 
bla bla

Clearly "bla bla" must be treated as a comment in this case because the "\n" end code does not close "/*".

Hence, the vector of code pairs should be ordered in such a fashion that vector[n] overrides vector[m] if n<m. Is this valid for all formats?

Change History (4)

comment:1 Changed 14 years ago by Peter Johansson

Description: modified (diff)

added link to #122

comment:2 Changed 14 years ago by Peter Johansson

Status: newassigned

comment:3 Changed 14 years ago by Peter Johansson

(In [260]) adding parse function in Parser. refs #121

comment:4 Changed 14 years ago by Peter Johansson

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.