Trying to grab all blank lines (only line numbers) by Antlr 4 lexer/parser for a given PHP file. The grammar I am using is available on GitHub Antlr grammar for PHP.
The Whitespace token defined as:
Whitespace: [ \t\r\n]+ -> skip;
I changed this to:
Whitespace: (
' '
| '\t'
| '\r' '\n' { newline(); }
| '\n' { newline(); }
);
But it's collecting almost all the lines, since every line is ending by "\n". Any expert advice can give me a lead.
The sample PHP to test:
<?php
//02-5002201-00001 5002201 - Machine hours test
function test()
{
/* Name: Test.php
Title: Demo
by: XYZ
*/
if (true && false)
{
echo "aa";
}
//TODO
echo <<<SEGDTA
<link rel="stylesheet" type="text/css" href="ui.css"/>
<script type="text/javascript" src="min.js"></script>
SEGDTA;
}
?>