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 88623 - Add LexerInput.match(String text)
Summary: Add LexerInput.match(String text)
Status: NEW
Alias: None
Product: editor
Classification: Unclassified
Component: Lexer (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Miloslav Metelka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-03 17:30 UTC by Miloslav Metelka
Modified: 2010-09-23 07:49 UTC (History)
0 users

See Also:
Issue Type: TASK
Exception Reporter:


Attachments
Proposed methods (tests and apichanges not included) (2.54 KB, patch)
2006-11-03 17:32 UTC, Miloslav Metelka
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Miloslav Metelka 2006-11-03 17:30:32 UTC
The method would be useful when checking for presence of certain pattern text on
the input. For example checking for "abcde" currently needs to be written as

int c;
if ((c = input.read()) == 'a'
 && (c = input.read()) == 'b'
 && (c = input.read()) == 'c'
 && (c = input.read()) == 'd'
 && (c = input.read()) == 'e') {
    // Possibly check the next character whether it's delimiter etc.
} else {
    // Check what was the c character that did not match
    // Whether it was delimiter or e.g. alphanumeric letter
}

With the match() method and a special constant MATCH this could be rewritten as

int c;
if ((c = input.match("abcde")) == LexerInput.MATCH) {
    // Possibly check the next character whether it's delimiter etc.
} else {
    // Check what was the c character that did not match
    // Whether it was delimiter or e.g. alphanumeric letter
}
Comment 1 Miloslav Metelka 2006-11-03 17:32:03 UTC
Created attachment 35772 [details]
Proposed methods (tests and apichanges not included)
Comment 2 _ briansmith 2006-11-03 17:54:02 UTC
Shouldn't these types of methods be in the Lexer, and not in the LexerInput? A
table-based lexer would never use these methods. Maybe there should be another
(abstract?) class that contains methods that are useful only for hand-written
lexers?