Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WCCL
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
WCCL
Commits
3ce9a0ab
Commit
3ce9a0ab
authored
12 years ago
by
Paweł Kędzia
Browse files
Options
Downloads
Patches
Plain Diff
Single and multi line comment handling added to lexicon grammar
parent
2fd075c6
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libwccl/lexicon/lexfilegrammar.g
+34
-1
34 additions, 1 deletion
libwccl/lexicon/lexfilegrammar.g
tests/data/indecl.lex
+4
-0
4 additions, 0 deletions
tests/data/indecl.lex
with
38 additions
and
1 deletion
libwccl/lexicon/lexfilegrammar.g
+
34
−
1
View file @
3ce9a0ab
...
...
@@ -28,7 +28,7 @@ options {
// ----------------------------------------------------------------------------
class ANTLRLexiconParser extends Parser;
options {
k =
1
;
k =
2
;
buildAST = false;
exportVocab = ANTLRLexicons;
defaultErrorHandler = false;
...
...
@@ -113,3 +113,36 @@ NEWLINE
| '\n'
) { newline(); $setType(antlr::Token::SKIP); }
;
COMMENT
options {
paraphrase = "Single line comment";
}
: "//" (~('\n'|'\r'))* { $setType(antlr::Token::SKIP); }
;
ML_COMMENT
options {
paraphrase = "Multi line comment";
}
: "/*"
( // TODO: test it and add reference to the site it's taken from!
/* This actually works OK despite the ambiguity that
'\r' '\n' can be matched in one alternative or by matching
'\r' in one iteration and '\n' in another.. But
this is really matched just by one rule per (...)*
loop iteration, so it's OK.
This is exactly how they do it all over the web - just
turn off the warning for this particular token.*/
options {
generateAmbigWarnings = false;
}
: { LA(2)!='/' }? '*'
| '\r' '\n' { newline(); }
| '\r' { newline(); }
| '\n' { newline(); }
| ~('*'|'\n'|'\r')
)*
"*/"
{ $setType(antlr::Token::SKIP); }
;
This diff is collapsed.
Click to expand it.
tests/data/indecl.lex
+
4
−
0
View file @
3ce9a0ab
/**
* ML COMMENT
*/
// Single line comment
by part
och interj
ach interj
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment