GitLab update scheduled for Friday, October 22th between 08:15 and 08:45 CEST. If unpleasant, please contact René or Martin.

Commit 4675200b authored by Johannes Mey's avatar Johannes Mey
Browse files

reuse lexer from relast preprocessor, move lexer and parser into subdirectories

parent d7d471f2
Pipeline #6516 passed with stage
in 1 minute and 37 seconds
Subproject commit 6fb98d06f2b05b735af78fe68b486c145eb730dc
Subproject commit 54af6737685fab0be452f446b70b9842aba89e42
......@@ -114,14 +114,24 @@ jastadd {
}
scanner {
include "src/main/jastadd/Ros2Rag.flex"
basedir ".."
include "ros2rag.base/src/main/jastadd/scanner/Header.flex", [-5]
include "relast.preprocessor/src/main/jastadd/scanner/Preamble.flex", [-4]
include "relast.preprocessor/src/main/jastadd/scanner/Macros.flex", [-3]
include "ros2rag.base/src/main/jastadd/scanner/Macros.flex", [-3]
include "relast.preprocessor/src/main/jastadd/scanner/RulesPreamble.flex", [-2]
include "ros2rag.base/src/main/jastadd/scanner/MappingContent.flex", [-1]
include "ros2rag.base/src/main/jastadd/scanner/Keywords.flex"
include "relast.preprocessor/src/main/jastadd/scanner/Keywords.flex"
include "relast.preprocessor/src/main/jastadd/scanner/Symbols.flex", [1]
include "relast.preprocessor/src/main/jastadd/scanner/RulesPostamble.flex", [2]
}
parser {
basedir ".."
include "ros2rag.base/src/main/jastadd/Preamble.parser"
include "relast.preprocessor/src/main/jastadd/RelAst.parser"
include "ros2rag.base/src/main/jastadd/Ros2Rag.parser"
include "ros2rag.base/src/main/jastadd/parser/Preamble.parser"
include "ros2rag.base/src/main/jastadd/parser/Ros2Rag.parser"
include "relast.preprocessor/src/main/jastadd/parser/RelAst.parser"
}
}
}
......
package org.jastadd.ros2rag.scanner;
import org.jastadd.ros2rag.parser.Ros2RagParser.Terminals;
%%
%public
%final
%class Ros2RagScanner
%extends beaver.Scanner
%type beaver.Symbol
%function nextToken
%yylexthrow beaver.Scanner.Exception
%scanerror Ros2RagScanner.ScannerError
%line
%column
%{
private StringBuilder stringLitSb = new StringBuilder();
private beaver.Symbol sym(short id) {
return new beaver.Symbol(id, yyline + 1, yycolumn + 1, yylength(), yytext());
}
private beaver.Symbol sym(short id, String text) {
return new beaver.Symbol(id, yyline + 1, yycolumn + 1, yylength(), text);
}
public static class ScannerError extends Error {
public ScannerError(String message) {
super(message);
}
}
%}
WhiteSpace = [ ] | \t | \f | \n | \r | \r\n
TraditionalComment = [/][*][^*]*[*]+([^*/][^*]*[*]+)*[/]
EndOfLineComment = "//" [^\n\r]*
Comment = {TraditionalComment} | {EndOfLineComment}
MappingContent = [{][:][^:]*[:]+([^:}][^:]*[:]+)*[}]
ID = [a-zA-Z$_][a-zA-Z0-9$_]*
%%
{WhiteSpace} { /* ignore */ }
{Comment} { return sym(Terminals.COMMENT); }
{MappingContent} { return sym(Terminals.MAPPING_CONTENT); }
"abstract" { return sym(Terminals.ABSTRACT); }
"rel" { return sym(Terminals.RELATION); }
"read" { return sym(Terminals.READ); }
"write" { return sym(Terminals.WRITE); }
"using" { return sym(Terminals.USING); }
"canDependOn" { return sym(Terminals.CAN_DEPEND_ON); }
"maps" { return sym(Terminals.MAPS); }
"to" { return sym(Terminals.TO); }
"as" { return sym(Terminals.AS); }
"with" { return sym(Terminals.WITH); }
";" { return sym(Terminals.SCOL); }
":" { return sym(Terminals.COL); }
"::=" { return sym(Terminals.ASSIGN); }
"*" { return sym(Terminals.STAR); }
"." { return sym(Terminals.DOT); }
"," { return sym(Terminals.COMMA); }
"<" { return sym(Terminals.LT); }
">" { return sym(Terminals.GT); }
"[" { return sym(Terminals.LBRACKET); }
"]" { return sym(Terminals.RBRACKET); }
"/" { return sym(Terminals.SLASH); }
"?" { return sym(Terminals.QUESTION_MARK); }
"->" { return sym(Terminals.RIGHT); }
"<-" { return sym(Terminals.LEFT); }
"<->" { return sym(Terminals.BIDIRECTIONAL); }
// ID
{ID} { return sym(Terminals.ID); }
<<EOF>> { return sym(Terminals.EOF); }
[^] { throw new ScannerError((yyline+1) +"," + (yycolumn+1) + ": Illegal character <"+yytext()+">"); }
package org.jastadd.ros2rag.scanner;
import org.jastadd.ros2rag.parser.Ros2RagParser.Terminals;
%%
%public
%final
%class Ros2RagScanner
%extends beaver.Scanner
%type beaver.Symbol
%function nextToken
%yylexthrow beaver.Scanner.Exception
%scanerror Ros2RagScanner.ScannerError
%line
%column
"read" { return sym(Terminals.READ); }
"write" { return sym(Terminals.WRITE); }
"using" { return sym(Terminals.USING); }
"canDependOn" { return sym(Terminals.CAN_DEPEND_ON); }
"maps" { return sym(Terminals.MAPS); }
"to" { return sym(Terminals.TO); }
"as" { return sym(Terminals.AS); }
"with" { return sym(Terminals.WITH); }
MappingContent = [{][:][^:]*[:]+([^:}][^:]*[:]+)*[}]
{MappingContent} { return sym(Terminals.MAPPING_CONTENT); }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment