Skip to content

Commit

Permalink
fixed errors in Dot grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Mar 14, 2024
1 parent 570a6c8 commit cb707e2
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 73 deletions.
37 changes: 17 additions & 20 deletions src/org/rascalmpl/library/lang/dot/Dot.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,20 @@ import String;
import Set;
import Map;

public alias Id = str;
alias Id = str;

@synopsis{Abstract Data Type of Dot language}
data DotGraph = graph(Id id, Stms stmts) | digraph(Id id, Stms stmts);

public data DotGraph = graph(Id id, Stms stmts) | digraph(Id id, Stms stmts);
alias Stms = list[Stm];

public alias Stms = list[Stm];
alias NodeId = tuple[Id, PortId];

public alias NodeId = tuple[Id, PortId];
alias PortId = tuple[Id, CompassPt];

public alias PortId = tuple[Id, CompassPt];
data CompassPt = N()|NE()|E()|SE()|S()|SW()|W()|NW()|C()|_();

public data CompassPt = N()|NE()|E()|SE()|S()|SW()|W()|NW()|C()|_();



public data Stm
data Stm
= N(Id id, Attrs attrs)
| N(Id id)
| N(NodeId nid, Attrs attrs)
Expand Down Expand Up @@ -59,30 +56,30 @@ public data Stm
| EDGE(Attrs attrs)
;

public alias Attr = tuple[str prop, Id val];
alias Attr = tuple[str prop, Id val];

public alias Attrs = list[Attr];
alias Attrs = list[Attr];

public alias Outline = map[int key, list[str] args];
alias Outline = map[int key, list[str] args];

public alias Dotline = tuple[DotGraph graph, Outline outline];
alias Dotline = tuple[DotGraph graph, Outline outline];


@synopsis{Dummy function call needed to tag initialized global variables of type DotGraph.
It is possible to select that variable on the outline menu of the Rascal Editor.
An application is for example to display dotgraphs.}

public DotGraph export(DotGraph g) {return g;}
DotGraph export(DotGraph g) {return g;}

public Dotline export(Dotline g) {return g;}
Dotline export(Dotline g) {return g;}

public bool hasOutline(Dotline _) {return true;}
bool hasOutline(Dotline _) {return true;}

public bool hasOutline(DotGraph _) {return false;}
bool hasOutline(DotGraph _) {return false;}

public Outline currentOutline;
Outline currentOutline;

public void setCurrentOutline(Dotline current) {
void setCurrentOutline(Dotline current) {
currentOutline = current.outline;
}

Expand Down
93 changes: 43 additions & 50 deletions src/org/rascalmpl/library/lang/dot/syntax/Dot.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,47 @@

module lang::dot::\syntax::Dot

start syntax DOT = LAYOUT* Graph Id "{" StatementList "}" "\n"?;

keyword Reserved = "graph"|"digraph"|"node"|"edge"|"subgraph";

syntax Graph = "graph"|"digraph"|AttrTag;

syntax AttrTag = "node"|"edge"|"graph";

syntax Nod = NodeId|Subgraph;

lexical Id = ([A-Z a-z 0-9 _] !<< [A-Z a-z 0-9 _]+ !<< [a-z A-Z 0-9 _][a-z A-Z 0-9 _]* !>> [0-9 A-Z _ a-z]) \ Reserved
| [\"] (![\"] | "\\\"")* [\"]
| [\-]? "." [0-9]+
| [\-]? [0-9]+ "." [0-9]*
;
start syntax DOT = Graph Id "{" StatementList "}" "\n"?;

keyword Reserved
= "graph"
| "digraph"
| "node"
| "edge"
| "subgraph"
;

syntax Graph
= "graph"
| "digraph"
| AttrTag
;

syntax AttrTag
= "node"
| "edge"
| "graph"
;

syntax Nod
= NodeId
| Subgraph
;

lexical Id
= ([A-Z a-z 0-9 _] !<< [a-z A-Z 0-9 _][a-z A-Z 0-9 _]* !>> [0-9 A-Z _ a-z]) \ Reserved
| [\"] (![\"] | "\\\"")* [\"]
| [\-]? "." [0-9]+
| [\-]? [0-9]+ "." [0-9]*
;

syntax StatementList = StatementOptional*;

syntax Statement = NodeStatement
|EdgeStatement
|AttrStatement
>Id "=" Id
;
syntax Statement
= NodeStatement
| EdgeStatement
| AttrStatement
| Id "=" Id
;

syntax StatementOptional = Statement ";"?;

Expand All @@ -45,9 +63,10 @@ syntax EdgeOp = "-\>" | "--";

syntax EdgeRhs = Edg+;

syntax NodeId = Id
| Id Port
;
syntax NodeId
= Id
| Id Port
;

syntax Port = ":" Id Id?
// | ":" Id
Expand Down Expand Up @@ -77,29 +96,3 @@ layout LAYOUTLIST = LAYOUT* !>> [\ \t\n\r] !>> "//" !>> "/*"
lexical LAYOUT = Whitespace: [\ \t\n\r]
| @category="Comment" Comment
;


/*
graph : [ strict ] (graph | digraph) [ ID ] '{' stmt_list '}'
stmt_list : [ stmt [ ';' ] [ stmt_list ] ]
stmt : node_stmt
| edge_stmt
| attr_stmt
| ID '=' ID
| subgraph
attr_stmt : (graph | node | edge) attr_list
attr_list : '[' [ a_list ] ']' [ attr_list ]
a_list : ID [ '=' ID ] [ ',' ] [ a_list ]
edge_stmt : (node_id | subgraph) edgeRHS [ attr_list ]
edgeRHS : edgeop (node_id | subgraph) [ edgeRHS ]
node_stmt : node_id [ attr_list ]
node_id : ID [ port ]
port : ':' ID [ ':' compass_pt ]
| ':' compass_pt
subgraph : [ subgraph [ ID ] ] '{' stmt_list '}'
compass_pt : (n | ne | e | se | s | sw | w | nw | c | _)
*/
2 changes: 0 additions & 2 deletions src/org/rascalmpl/library/util/Test.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ with tests, but also to query larger volumes of failing tests.
}
module util::Test

extend Message;

data TestResult = \testResult(str name, bool success, loc src, str message = "", list[value] exceptions = []);

@synopsis{Run all tests for the given module name}
Expand Down
1 change: 0 additions & 1 deletion src/org/rascalmpl/library/util/Webserver.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
module util::Webserver

extend Content;
import IO;

@javaClass{org.rascalmpl.library.util.Webserver}
java void serve(loc server, Response (Request) callback, bool asDaemon = true);
Expand Down

0 comments on commit cb707e2

Please sign in to comment.