-package org.simantics.scl.compiler.parsing.documentation;\r
-\r
-%%\r
-\r
-%public\r
-%char\r
-%unicode\r
-%class DocumentationLexer\r
-%function nextToken\r
-%type DocumentationElement\r
-%yylexthrow DocumentationParsingException\r
-%eofval{\r
- return null;\r
-%eofval}\r
-\r
-%{\r
- public static String trimW(String text) {\r
- int a = 0, b = text.length();\r
- while(a < b) {\r
- char c = text.charAt(a);\r
- if(c != ' ' && c != '\t' && c != '\r' && c != '\n')\r
- break;\r
- ++a;\r
- }\r
- while(a < b) {\r
- char c = text.charAt(b-1);\r
- if(c != ' ' && c != '\t' && c != '\r' && c != '\n')\r
- break;\r
- --b;\r
- }\r
- return text.substring(a, b);\r
- }\r
-\r
- public static String trimN(String text, int amount) { \r
- text = trimW(text);\r
- return text.substring(amount, text.length()-amount).trim();\r
- }\r
-%}\r
-\r
-whitespace = [ \t]\r
-eol = "\n" | "\r\n"\r
-textStartChar = [^ \n\r*>=-]\r
-textLine = {whitespace}* {textStartChar} [^\n\r]* {eol}\r
-emptyLine = {eol}\r
-h1 = "=" [^\n\r=][^\n\r]*[^\n\r=] "=" {whitespace}* {eol}\r
-h2 = "==" [^\n\r=][^\n\r]*[^\n\r=] "==" {whitespace}* {eol}\r
-h3 = "===" [^\n\r=][^\n\r]*[^\n\r=] "===" {whitespace}* {eol}\r
-h3 = "===" [^\n\r=][^\n\r]*[^\n\r=] "===" {whitespace}* {eol}\r
-listItem = [*#]+ [^\n\r]* {eol}\r
-birdTrack = ">" [^\n\r]* {eol}\r
-entityRef = "-" [^\n\r]* {eol}\r
-%%\r
-\r
-<YYINITIAL> {\r
- {textLine}+ { return new Paragraph(yytext().trim()); }\r
- {birdTrack}+ { return new Preformatted(yytext()); }\r
- {h1} { return new Header(1, trimN(yytext(), 1)); }\r
- {h2} { return new Header(2, trimN(yytext(), 2)); }\r
- {h3} { return new Header(3, trimN(yytext(), 3)); }\r
- {listItem} { return new ListItem(trimW(yytext())); }\r
- {entityRef} { return new EntityRef(trimW(yytext().substring(1))); }\r
- {emptyLine} { } \r
- {whitespace}+ { }\r
- . { System.err.println("At " + yychar + ": Illegal character '" + yytext() + "'."); }\r
-}\r
+package org.simantics.scl.compiler.parsing.documentation;
+
+%%
+
+%public
+%char
+%unicode
+%class DocumentationLexer
+%function nextToken
+%type DocumentationElement
+%yylexthrow DocumentationParsingException
+%eofval{
+ return null;
+%eofval}
+
+%{
+ public static String trimW(String text) {
+ int a = 0, b = text.length();
+ while(a < b) {
+ char c = text.charAt(a);
+ if(c != ' ' && c != '\t' && c != '\r' && c != '\n')
+ break;
+ ++a;
+ }
+ while(a < b) {
+ char c = text.charAt(b-1);
+ if(c != ' ' && c != '\t' && c != '\r' && c != '\n')
+ break;
+ --b;
+ }
+ return text.substring(a, b);
+ }
+
+ public static String trimN(String text, int amount) {
+ text = trimW(text);
+ return text.substring(amount, text.length()-amount).trim();
+ }
+%}
+
+whitespace = [ \t]
+eol = "\n" | "\r\n"
+textStartChar = [^ \n\r*>=-]
+textLine = {whitespace}* {textStartChar} [^\n\r]* {eol}
+emptyLine = {eol}
+h1 = "=" [^\n\r=][^\n\r]*[^\n\r=] "=" {whitespace}* {eol}
+h2 = "==" [^\n\r=][^\n\r]*[^\n\r=] "==" {whitespace}* {eol}
+h3 = "===" [^\n\r=][^\n\r]*[^\n\r=] "===" {whitespace}* {eol}
+h3 = "===" [^\n\r=][^\n\r]*[^\n\r=] "===" {whitespace}* {eol}
+listItem = [*#]+ [^\n\r]* {eol}
+birdTrack = ">" [^\n\r]* {eol}
+entityRef = "-" [^\n\r]* {eol}
+%%
+
+<YYINITIAL> {
+ {textLine}+ { return new Paragraph(yytext().trim()); }
+ {birdTrack}+ { return new Preformatted(yytext()); }
+ {h1} { return new Header(1, trimN(yytext(), 1)); }
+ {h2} { return new Header(2, trimN(yytext(), 2)); }
+ {h3} { return new Header(3, trimN(yytext(), 3)); }
+ {listItem} { return new ListItem(trimW(yytext())); }
+ {entityRef} { return new EntityRef(trimW(yytext().substring(1))); }
+ {emptyLine} { }
+ {whitespace}+ { }
+ . { System.err.println("At " + yychar + ": Illegal character '" + yytext() + "'."); }
+}