Ros2Rag.parser 3.72 KB
Newer Older
1
2
3
4
Ros2Rag ros2rag
  = update_definition.d ros2rag.r       {: r.getUpdateDefinitionList().insertChild(d, 0); return r; :}
  | dependency_definition.d ros2rag.r   {: r.getDependencyDefinitionList().insertChild(d, 0); return r; :}
  | mapping_definition.d ros2rag.r      {: r.getMappingDefinitionList().insertChild(d, 0); return r; :}
5
  | comment ros2rag.r                   {: return r; :}
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
  |                                     {: return new Ros2Rag(); :}
;

// read Joint.CurrentPosition using LinkStateToIntPosition ;
// write RobotArm._AppropriateSpeed using CreateSpeedMessage ;
UpdateDefinition update_definition
  = READ ID.type_name DOT ID.token_name SCOL
    {:
      ReadFromMqttDefinition result = new ReadFromMqttDefinition();
      result.setToken(TokenComponent.createRef(type_name + "." + token_name));
      return result;
    :}
  | READ ID.type_name DOT ID.token_name USING ID.mapping_def SCOL
    {:
      ReadFromMqttDefinition result = new ReadFromMqttDefinition();
      result.setToken(TokenComponent.createRef(type_name + "." + token_name));
      result.setMapping(MappingDefinition.createRef(mapping_def));
      return result;
    :}
  | WRITE ID.type_name DOT ID.token_name SCOL
    {:
      WriteToMqttDefinition result = new WriteToMqttDefinition();
      result.setToken(TokenComponent.createRef(type_name + "." + token_name));
      return result;
    :}
  | WRITE ID.type_name DOT ID.token_name USING ID.mapping_def SCOL
    {:
      WriteToMqttDefinition result = new WriteToMqttDefinition();
      result.setToken(TokenComponent.createRef(type_name + "." + token_name));
      result.setMapping(MappingDefinition.createRef(mapping_def));
      return result;
    :}
;

// RobotArm._AppropriateSpeed canDependOn Joint.CurrentPosition as dependency1 ;
DependencyDefinition dependency_definition
  = ID.target_type DOT ID.target_token CAN_DEPEND_ON ID.source_type DOT ID.source_token AS ID.id SCOL
    {:
      DependencyDefinition result = new DependencyDefinition();
      result.setSource(TokenComponent.createRef(source_type + "." + source_token));
      result.setTarget(TokenComponent.createRef(target_type + "." + target_token));
      result.setID(id);
      return result;
    :}
;

//LinkStateToIntPosition maps protobuf panda.Linkstate.PandaLinkState x to IntPosition y {
//  panda.Linkstate.PandaLinkState.Position p = x.getPos();
//  y = IntPosition.of((int) p.getPositionX(), (int) p.getPositionY(), (int) p.getPositionZ());
//}
MappingDefinition mapping_definition
57
  = ID.id MAPS mapping_type.from TO mapping_type.to MAPPING_CONTENT.content
58
59
60
    {:
      MappingDefinition result = new MappingDefinition();
      result.setID(id);
61
62
63
      result.setFrom(from);
      result.setTo(to);
      result.setContent(content.substring(2, content.length() - 2));
64
65
66
67
      return result;
    :}
;

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
MappingDefinitionType mapping_type
  = java_type_use.type ID.variable
    {:
      MappingDefinitionType result = new MappingDefinitionType();
      result.setType(type);
      result.setVariableName(variable);
      return result;
    :}
  | java_type_use.type ID.variable WITH ID.method
    {:
      MappingDefinitionType result = new MappingDefinitionType();
      result.setType(type);
      result.setVariableName(variable);
      result.setSerializationMethodName(method);
      return result;
    :}
;

//String mapping_def_content
//  = LB_CURLY COL mapping_def_content_body.b   {: return b.stream().collect(java.util.stream.Collectors.joining("\n")); :}
//;
//
//ArrayList mapping_def_content_body
//  = COL RB_CURLY                          {: return new ArrayList(); :}
//  | TEXT.text mapping_def_content_body.b  {: b.add(0, text); return b; :}
//;
//String mapping_def_content
//  = MappingContent.c      {: int length = c.length(); return c.substring(2, length - 2); :}
//;