diff --git a/scenarios/gs_straight_road_cutin_scenario.osm b/scenarios/gs_straight_road_cutin_scenario.osm index a7c31f5a..e95e89ff 100644 --- a/scenarios/gs_straight_road_cutin_scenario.osm +++ b/scenarios/gs_straight_road_cutin_scenario.osm @@ -34,7 +34,7 @@ - + diff --git a/scenarios/trees/drive_tree.btree b/scenarios/trees/drive_tree.btree index d809960c..8cafe51b 100644 --- a/scenarios/trees/drive_tree.btree +++ b/scenarios/trees/drive_tree.btree @@ -4,6 +4,6 @@ behaviortree drive_tree: condition goal ( reached_goal() ) maneuver stop_reached_goal ( MStopConfig() ) -> - condition c_busy_lane( lane_occupied() ) + condition c_busy_lane( lane_occupied(), error=0.0 ) maneuver m_follow_leading_v ( MFollowConfig() ) - maneuver keep_velocity ( MVelKeepConfig(vel=MP(16.0,10,6)) ) \ No newline at end of file + maneuver keep_velocity ( MVelKeepConfig(vel=MP(16.0,10,6) )) \ No newline at end of file diff --git a/scenarios/trees/lane_change_scenario_tree.btree b/scenarios/trees/lane_change_scenario_tree.btree index e0c252f7..1102441c 100644 --- a/scenarios/trees/lane_change_scenario_tree.btree +++ b/scenarios/trees/lane_change_scenario_tree.btree @@ -1,6 +1,6 @@ behaviortree LaneChange: ? -> - condition lc( sim_time (repeat=False, tmin=3, tmax=10)) + condition lc( sim_time (repeat=False, tmin=3, tmax=10), delay=0.1) subtree lane_change_tree() subtree drive_tree() diff --git a/sv/SVPlanner.py b/sv/SVPlanner.py index 2c56127c..0980e973 100644 --- a/sv/SVPlanner.py +++ b/sv/SVPlanner.py @@ -135,7 +135,7 @@ def run_planner_process(self, traffic_state_sharr, mplan_sharr, debug_shdata): #log.info('Plan {} at time {} and FRENET STATE:'.format(self.vid, state_time)) #log.info((planner_state.vehicle_state.get_S(), planner_state.vehicle_state.get_D())) - + #Maneuver Tick if mconfig and planner_state.lane_config: #replan maneuver diff --git a/sv/btree/BTreeLeaves.py b/sv/btree/BTreeLeaves.py index c9e2489a..1fc98cf2 100644 --- a/sv/btree/BTreeLeaves.py +++ b/sv/btree/BTreeLeaves.py @@ -4,6 +4,7 @@ from py_trees import * import random +import time from sv.ManeuverStatus import * from sv.btree.BehaviorModels import * from sv.ManeuverConfig import * @@ -11,31 +12,48 @@ #alternative: class BCondition(behaviour.Behaviour): - def __init__(self, bmodel, name, condition, repeat=True, **kwargs): + def __init__(self, bmodel, name, condition, repeat=True, error=0, delay=0, **kwargs): super(BCondition, self).__init__(name) self.name = name self.condition = condition self.bmodel = bmodel self.kwargs = kwargs self.repeat = repeat + self.error = float(error) + self.delay = delay + self.trigger_time = True self.triggered = False + self.tic = 0 + self.toc = 0 def update(self): self.logger.debug(" %s [BCondition::update()]" % self.name) status = common.Status.FAILURE - #print("BCondition {} {}".format(self.name,self.kwargs)) + if self.trigger_time: + self.tic = time.perf_counter() + self.trigger_time = False + + self.toc = time.perf_counter() + elapsed_time = self.toc-self.tic + try: if self.repeat or not self.triggered: - if self.bmodel.test_condition(self.condition, self.kwargs): - #print("SUCCESS") - status = common.Status.SUCCESS - self.triggered = True + p = random.random() > self.error + if elapsed_time >= self.delay: + self.trigger_time = True + # negate xor: invert result from test_condition + if not (p ^ self.bmodel.test_condition(self.condition, self.kwargs)): + status = common.Status.SUCCESS + self.triggered = True + else: + status = common.Status.RUNNING + except KeyError as e: raise RuntimeError("Missing condition '" + self.name + "'.") - return status + return status class ManeuverAction(behaviour.Behaviour): diff --git a/sv/btree/BTreeParser.py b/sv/btree/BTreeParser.py index cfda59a2..87562b6c 100644 --- a/sv/btree/BTreeParser.py +++ b/sv/btree/BTreeParser.py @@ -234,11 +234,15 @@ def exitManeuver(self, ctx): self.exec_stack.append(s) self.nodes += name + "," - # e.g. endpoint = BCondition(self.bmodel,"endpoint", "lane_occupied", args) - def exitCondition(self, ctx): - name = ctx.name().getText() + # e.g. endpoint = BCondition(self.bmodel,"endpoint", "lane_occupied", error=0.2, delay=0.8, args) + def exitCondition(self, ctx): + name = ctx.name().getText() cconfig_name = ctx.cconfig().name().getText() s = name + " = " + "BCondition(parser.bmodel," + "\"" + name + "\"" + "," + "\"" + cconfig_name + "\"" + if ctx.error() != None: + s += ", " + ctx.error().getText() + if ctx.delay() != None: + s += ", " + ctx.delay().getText() cconfig_params = "" if hasattr(ctx.cconfig().params(), '__iter__'): for param in ctx.cconfig().params(): cconfig_params += "," + param.getText() diff --git a/sv/btree/parser/BTreeDSL.g4 b/sv/btree/parser/BTreeDSL.g4 index 8dba223d..be8cdd45 100644 --- a/sv/btree/parser/BTreeDSL.g4 +++ b/sv/btree/parser/BTreeDSL.g4 @@ -36,11 +36,13 @@ node : leafNode | nodeComposition; nodeComposition : OPERATOR INDENT node+ DEDENT; leafNode : (maneuver | condition | subtree) NL; -condition : 'condition' name '(' cconfig ')'; +condition : 'condition' name '(' cconfig (',' error)? (',' delay)? ')'; maneuver : 'maneuver' name '(' mconfig ')'; subtree : 'subtree' name '(' (midconf (',' midconf)*)? ')'; midconf : mid '=' mconfig; +error : 'error' '=' FLOAT; +delay : 'delay' '=' FLOAT; mconfig : name '(' params* ')'; cconfig : name '(' params* ')'; diff --git a/sv/btree/parser/BTreeDSL.interp b/sv/btree/parser/BTreeDSL.interp index 98281a88..949ca640 100644 --- a/sv/btree/parser/BTreeDSL.interp +++ b/sv/btree/parser/BTreeDSL.interp @@ -4,10 +4,12 @@ null ':' 'condition' '(' +',' ')' 'maneuver' 'subtree' -',' +'error' +'delay' null null '=' @@ -28,6 +30,8 @@ null null null null +null +null OPERATOR BOP ATT @@ -48,6 +52,8 @@ condition maneuver subtree midconf +error +delay mconfig cconfig mid @@ -60,4 +66,4 @@ name atn: -[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 19, 185, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 5, 2, 45, 10, 2, 3, 2, 5, 2, 48, 10, 2, 6, 2, 50, 10, 2, 13, 2, 14, 2, 51, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 5, 4, 60, 10, 4, 3, 5, 3, 5, 3, 5, 6, 5, 65, 10, 5, 13, 5, 14, 5, 66, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 5, 6, 74, 10, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 7, 9, 96, 10, 9, 12, 9, 14, 9, 99, 11, 9, 5, 9, 101, 10, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 7, 11, 112, 10, 11, 12, 11, 14, 11, 115, 11, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 7, 12, 122, 10, 12, 12, 12, 14, 12, 125, 11, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 7, 14, 134, 10, 14, 12, 14, 14, 14, 137, 11, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 5, 16, 147, 10, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 7, 17, 154, 10, 17, 12, 17, 14, 17, 157, 11, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 7, 18, 165, 10, 18, 12, 18, 14, 18, 168, 11, 18, 3, 18, 3, 18, 3, 19, 7, 19, 173, 10, 19, 12, 19, 14, 19, 176, 11, 19, 3, 19, 3, 19, 7, 19, 180, 10, 19, 12, 19, 14, 19, 183, 11, 19, 3, 19, 2, 2, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 2, 3, 3, 2, 12, 13, 2, 185, 2, 49, 3, 2, 2, 2, 4, 55, 3, 2, 2, 2, 6, 59, 3, 2, 2, 2, 8, 61, 3, 2, 2, 2, 10, 73, 3, 2, 2, 2, 12, 77, 3, 2, 2, 2, 14, 83, 3, 2, 2, 2, 16, 89, 3, 2, 2, 2, 18, 104, 3, 2, 2, 2, 20, 108, 3, 2, 2, 2, 22, 118, 3, 2, 2, 2, 24, 128, 3, 2, 2, 2, 26, 130, 3, 2, 2, 2, 28, 138, 3, 2, 2, 2, 30, 146, 3, 2, 2, 2, 32, 148, 3, 2, 2, 2, 34, 160, 3, 2, 2, 2, 36, 174, 3, 2, 2, 2, 38, 39, 7, 3, 2, 2, 39, 40, 5, 36, 19, 2, 40, 41, 7, 4, 2, 2, 41, 42, 7, 18, 2, 2, 42, 44, 5, 4, 3, 2, 43, 45, 7, 17, 2, 2, 44, 43, 3, 2, 2, 2, 44, 45, 3, 2, 2, 2, 45, 47, 3, 2, 2, 2, 46, 48, 7, 19, 2, 2, 47, 46, 3, 2, 2, 2, 47, 48, 3, 2, 2, 2, 48, 50, 3, 2, 2, 2, 49, 38, 3, 2, 2, 2, 50, 51, 3, 2, 2, 2, 51, 49, 3, 2, 2, 2, 51, 52, 3, 2, 2, 2, 52, 53, 3, 2, 2, 2, 53, 54, 7, 2, 2, 3, 54, 3, 3, 2, 2, 2, 55, 56, 5, 6, 4, 2, 56, 5, 3, 2, 2, 2, 57, 60, 5, 10, 6, 2, 58, 60, 5, 8, 5, 2, 59, 57, 3, 2, 2, 2, 59, 58, 3, 2, 2, 2, 60, 7, 3, 2, 2, 2, 61, 62, 7, 11, 2, 2, 62, 64, 7, 18, 2, 2, 63, 65, 5, 6, 4, 2, 64, 63, 3, 2, 2, 2, 65, 66, 3, 2, 2, 2, 66, 64, 3, 2, 2, 2, 66, 67, 3, 2, 2, 2, 67, 68, 3, 2, 2, 2, 68, 69, 7, 19, 2, 2, 69, 9, 3, 2, 2, 2, 70, 74, 5, 14, 8, 2, 71, 74, 5, 12, 7, 2, 72, 74, 5, 16, 9, 2, 73, 70, 3, 2, 2, 2, 73, 71, 3, 2, 2, 2, 73, 72, 3, 2, 2, 2, 74, 75, 3, 2, 2, 2, 75, 76, 7, 17, 2, 2, 76, 11, 3, 2, 2, 2, 77, 78, 7, 5, 2, 2, 78, 79, 5, 36, 19, 2, 79, 80, 7, 6, 2, 2, 80, 81, 5, 22, 12, 2, 81, 82, 7, 7, 2, 2, 82, 13, 3, 2, 2, 2, 83, 84, 7, 8, 2, 2, 84, 85, 5, 36, 19, 2, 85, 86, 7, 6, 2, 2, 86, 87, 5, 20, 11, 2, 87, 88, 7, 7, 2, 2, 88, 15, 3, 2, 2, 2, 89, 90, 7, 9, 2, 2, 90, 91, 5, 36, 19, 2, 91, 100, 7, 6, 2, 2, 92, 97, 5, 18, 10, 2, 93, 94, 7, 10, 2, 2, 94, 96, 5, 18, 10, 2, 95, 93, 3, 2, 2, 2, 96, 99, 3, 2, 2, 2, 97, 95, 3, 2, 2, 2, 97, 98, 3, 2, 2, 2, 98, 101, 3, 2, 2, 2, 99, 97, 3, 2, 2, 2, 100, 92, 3, 2, 2, 2, 100, 101, 3, 2, 2, 2, 101, 102, 3, 2, 2, 2, 102, 103, 7, 7, 2, 2, 103, 17, 3, 2, 2, 2, 104, 105, 5, 24, 13, 2, 105, 106, 7, 13, 2, 2, 106, 107, 5, 20, 11, 2, 107, 19, 3, 2, 2, 2, 108, 109, 5, 36, 19, 2, 109, 113, 7, 6, 2, 2, 110, 112, 5, 26, 14, 2, 111, 110, 3, 2, 2, 2, 112, 115, 3, 2, 2, 2, 113, 111, 3, 2, 2, 2, 113, 114, 3, 2, 2, 2, 114, 116, 3, 2, 2, 2, 115, 113, 3, 2, 2, 2, 116, 117, 7, 7, 2, 2, 117, 21, 3, 2, 2, 2, 118, 119, 5, 36, 19, 2, 119, 123, 7, 6, 2, 2, 120, 122, 5, 26, 14, 2, 121, 120, 3, 2, 2, 2, 122, 125, 3, 2, 2, 2, 123, 121, 3, 2, 2, 2, 123, 124, 3, 2, 2, 2, 124, 126, 3, 2, 2, 2, 125, 123, 3, 2, 2, 2, 126, 127, 7, 7, 2, 2, 127, 23, 3, 2, 2, 2, 128, 129, 5, 36, 19, 2, 129, 25, 3, 2, 2, 2, 130, 135, 5, 28, 15, 2, 131, 132, 7, 10, 2, 2, 132, 134, 5, 28, 15, 2, 133, 131, 3, 2, 2, 2, 134, 137, 3, 2, 2, 2, 135, 133, 3, 2, 2, 2, 135, 136, 3, 2, 2, 2, 136, 27, 3, 2, 2, 2, 137, 135, 3, 2, 2, 2, 138, 139, 5, 36, 19, 2, 139, 140, 9, 2, 2, 2, 140, 141, 5, 30, 16, 2, 141, 29, 3, 2, 2, 2, 142, 147, 7, 14, 2, 2, 143, 147, 5, 36, 19, 2, 144, 147, 5, 32, 17, 2, 145, 147, 5, 34, 18, 2, 146, 142, 3, 2, 2, 2, 146, 143, 3, 2, 2, 2, 146, 144, 3, 2, 2, 2, 146, 145, 3, 2, 2, 2, 147, 31, 3, 2, 2, 2, 148, 149, 5, 36, 19, 2, 149, 150, 7, 6, 2, 2, 150, 155, 7, 14, 2, 2, 151, 152, 7, 10, 2, 2, 152, 154, 7, 14, 2, 2, 153, 151, 3, 2, 2, 2, 154, 157, 3, 2, 2, 2, 155, 153, 3, 2, 2, 2, 155, 156, 3, 2, 2, 2, 156, 158, 3, 2, 2, 2, 157, 155, 3, 2, 2, 2, 158, 159, 7, 7, 2, 2, 159, 33, 3, 2, 2, 2, 160, 161, 7, 6, 2, 2, 161, 166, 7, 14, 2, 2, 162, 163, 7, 10, 2, 2, 163, 165, 7, 14, 2, 2, 164, 162, 3, 2, 2, 2, 165, 168, 3, 2, 2, 2, 166, 164, 3, 2, 2, 2, 166, 167, 3, 2, 2, 2, 167, 169, 3, 2, 2, 2, 168, 166, 3, 2, 2, 2, 169, 170, 7, 7, 2, 2, 170, 35, 3, 2, 2, 2, 171, 173, 7, 16, 2, 2, 172, 171, 3, 2, 2, 2, 173, 176, 3, 2, 2, 2, 174, 172, 3, 2, 2, 2, 174, 175, 3, 2, 2, 2, 175, 177, 3, 2, 2, 2, 176, 174, 3, 2, 2, 2, 177, 181, 7, 15, 2, 2, 178, 180, 7, 16, 2, 2, 179, 178, 3, 2, 2, 2, 180, 183, 3, 2, 2, 2, 181, 179, 3, 2, 2, 2, 181, 182, 3, 2, 2, 2, 182, 37, 3, 2, 2, 2, 183, 181, 3, 2, 2, 2, 18, 44, 47, 51, 59, 66, 73, 97, 100, 113, 123, 135, 146, 155, 166, 174, 181] \ No newline at end of file +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 21, 191, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 5, 2, 47, 10, 2, 3, 2, 5, 2, 50, 10, 2, 6, 2, 52, 10, 2, 13, 2, 14, 2, 53, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 5, 4, 62, 10, 4, 3, 5, 3, 5, 3, 5, 6, 5, 67, 10, 5, 13, 5, 14, 5, 68, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 5, 6, 76, 10, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 5, 7, 86, 10, 7, 3, 7, 3, 7, 5, 7, 90, 10, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 7, 9, 106, 10, 9, 12, 9, 14, 9, 109, 11, 9, 5, 9, 111, 10, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 7, 13, 130, 10, 13, 12, 13, 14, 13, 133, 11, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 7, 14, 140, 10, 14, 12, 14, 14, 14, 143, 11, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 7, 16, 152, 10, 16, 12, 16, 14, 16, 155, 11, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 5, 18, 164, 10, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 7, 19, 171, 10, 19, 12, 19, 14, 19, 174, 11, 19, 3, 19, 3, 19, 3, 20, 7, 20, 179, 10, 20, 12, 20, 14, 20, 182, 11, 20, 3, 20, 3, 20, 7, 20, 186, 10, 20, 12, 20, 14, 20, 189, 11, 20, 3, 20, 2, 2, 21, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 2, 3, 3, 2, 14, 15, 2, 190, 2, 51, 3, 2, 2, 2, 4, 57, 3, 2, 2, 2, 6, 61, 3, 2, 2, 2, 8, 63, 3, 2, 2, 2, 10, 75, 3, 2, 2, 2, 12, 79, 3, 2, 2, 2, 14, 93, 3, 2, 2, 2, 16, 99, 3, 2, 2, 2, 18, 114, 3, 2, 2, 2, 20, 118, 3, 2, 2, 2, 22, 122, 3, 2, 2, 2, 24, 126, 3, 2, 2, 2, 26, 136, 3, 2, 2, 2, 28, 146, 3, 2, 2, 2, 30, 148, 3, 2, 2, 2, 32, 156, 3, 2, 2, 2, 34, 163, 3, 2, 2, 2, 36, 165, 3, 2, 2, 2, 38, 180, 3, 2, 2, 2, 40, 41, 7, 3, 2, 2, 41, 42, 5, 38, 20, 2, 42, 43, 7, 4, 2, 2, 43, 44, 7, 20, 2, 2, 44, 46, 5, 4, 3, 2, 45, 47, 7, 19, 2, 2, 46, 45, 3, 2, 2, 2, 46, 47, 3, 2, 2, 2, 47, 49, 3, 2, 2, 2, 48, 50, 7, 21, 2, 2, 49, 48, 3, 2, 2, 2, 49, 50, 3, 2, 2, 2, 50, 52, 3, 2, 2, 2, 51, 40, 3, 2, 2, 2, 52, 53, 3, 2, 2, 2, 53, 51, 3, 2, 2, 2, 53, 54, 3, 2, 2, 2, 54, 55, 3, 2, 2, 2, 55, 56, 7, 2, 2, 3, 56, 3, 3, 2, 2, 2, 57, 58, 5, 6, 4, 2, 58, 5, 3, 2, 2, 2, 59, 62, 5, 10, 6, 2, 60, 62, 5, 8, 5, 2, 61, 59, 3, 2, 2, 2, 61, 60, 3, 2, 2, 2, 62, 7, 3, 2, 2, 2, 63, 64, 7, 13, 2, 2, 64, 66, 7, 20, 2, 2, 65, 67, 5, 6, 4, 2, 66, 65, 3, 2, 2, 2, 67, 68, 3, 2, 2, 2, 68, 66, 3, 2, 2, 2, 68, 69, 3, 2, 2, 2, 69, 70, 3, 2, 2, 2, 70, 71, 7, 21, 2, 2, 71, 9, 3, 2, 2, 2, 72, 76, 5, 14, 8, 2, 73, 76, 5, 12, 7, 2, 74, 76, 5, 16, 9, 2, 75, 72, 3, 2, 2, 2, 75, 73, 3, 2, 2, 2, 75, 74, 3, 2, 2, 2, 76, 77, 3, 2, 2, 2, 77, 78, 7, 19, 2, 2, 78, 11, 3, 2, 2, 2, 79, 80, 7, 5, 2, 2, 80, 81, 5, 38, 20, 2, 81, 82, 7, 6, 2, 2, 82, 85, 5, 26, 14, 2, 83, 84, 7, 7, 2, 2, 84, 86, 5, 20, 11, 2, 85, 83, 3, 2, 2, 2, 85, 86, 3, 2, 2, 2, 86, 89, 3, 2, 2, 2, 87, 88, 7, 7, 2, 2, 88, 90, 5, 22, 12, 2, 89, 87, 3, 2, 2, 2, 89, 90, 3, 2, 2, 2, 90, 91, 3, 2, 2, 2, 91, 92, 7, 8, 2, 2, 92, 13, 3, 2, 2, 2, 93, 94, 7, 9, 2, 2, 94, 95, 5, 38, 20, 2, 95, 96, 7, 6, 2, 2, 96, 97, 5, 24, 13, 2, 97, 98, 7, 8, 2, 2, 98, 15, 3, 2, 2, 2, 99, 100, 7, 10, 2, 2, 100, 101, 5, 38, 20, 2, 101, 110, 7, 6, 2, 2, 102, 107, 5, 18, 10, 2, 103, 104, 7, 7, 2, 2, 104, 106, 5, 18, 10, 2, 105, 103, 3, 2, 2, 2, 106, 109, 3, 2, 2, 2, 107, 105, 3, 2, 2, 2, 107, 108, 3, 2, 2, 2, 108, 111, 3, 2, 2, 2, 109, 107, 3, 2, 2, 2, 110, 102, 3, 2, 2, 2, 110, 111, 3, 2, 2, 2, 111, 112, 3, 2, 2, 2, 112, 113, 7, 8, 2, 2, 113, 17, 3, 2, 2, 2, 114, 115, 5, 28, 15, 2, 115, 116, 7, 15, 2, 2, 116, 117, 5, 24, 13, 2, 117, 19, 3, 2, 2, 2, 118, 119, 7, 11, 2, 2, 119, 120, 7, 15, 2, 2, 120, 121, 7, 16, 2, 2, 121, 21, 3, 2, 2, 2, 122, 123, 7, 12, 2, 2, 123, 124, 7, 15, 2, 2, 124, 125, 7, 16, 2, 2, 125, 23, 3, 2, 2, 2, 126, 127, 5, 38, 20, 2, 127, 131, 7, 6, 2, 2, 128, 130, 5, 30, 16, 2, 129, 128, 3, 2, 2, 2, 130, 133, 3, 2, 2, 2, 131, 129, 3, 2, 2, 2, 131, 132, 3, 2, 2, 2, 132, 134, 3, 2, 2, 2, 133, 131, 3, 2, 2, 2, 134, 135, 7, 8, 2, 2, 135, 25, 3, 2, 2, 2, 136, 137, 5, 38, 20, 2, 137, 141, 7, 6, 2, 2, 138, 140, 5, 30, 16, 2, 139, 138, 3, 2, 2, 2, 140, 143, 3, 2, 2, 2, 141, 139, 3, 2, 2, 2, 141, 142, 3, 2, 2, 2, 142, 144, 3, 2, 2, 2, 143, 141, 3, 2, 2, 2, 144, 145, 7, 8, 2, 2, 145, 27, 3, 2, 2, 2, 146, 147, 5, 38, 20, 2, 147, 29, 3, 2, 2, 2, 148, 153, 5, 32, 17, 2, 149, 150, 7, 7, 2, 2, 150, 152, 5, 32, 17, 2, 151, 149, 3, 2, 2, 2, 152, 155, 3, 2, 2, 2, 153, 151, 3, 2, 2, 2, 153, 154, 3, 2, 2, 2, 154, 31, 3, 2, 2, 2, 155, 153, 3, 2, 2, 2, 156, 157, 5, 38, 20, 2, 157, 158, 9, 2, 2, 2, 158, 159, 5, 34, 18, 2, 159, 33, 3, 2, 2, 2, 160, 164, 7, 16, 2, 2, 161, 164, 5, 38, 20, 2, 162, 164, 5, 36, 19, 2, 163, 160, 3, 2, 2, 2, 163, 161, 3, 2, 2, 2, 163, 162, 3, 2, 2, 2, 164, 35, 3, 2, 2, 2, 165, 166, 5, 38, 20, 2, 166, 167, 7, 6, 2, 2, 167, 172, 7, 16, 2, 2, 168, 169, 7, 7, 2, 2, 169, 171, 7, 16, 2, 2, 170, 168, 3, 2, 2, 2, 171, 174, 3, 2, 2, 2, 172, 170, 3, 2, 2, 2, 172, 173, 3, 2, 2, 2, 173, 175, 3, 2, 2, 2, 174, 172, 3, 2, 2, 2, 175, 176, 7, 8, 2, 2, 176, 37, 3, 2, 2, 2, 177, 179, 7, 18, 2, 2, 178, 177, 3, 2, 2, 2, 179, 182, 3, 2, 2, 2, 180, 178, 3, 2, 2, 2, 180, 181, 3, 2, 2, 2, 181, 183, 3, 2, 2, 2, 182, 180, 3, 2, 2, 2, 183, 187, 7, 17, 2, 2, 184, 186, 7, 18, 2, 2, 185, 184, 3, 2, 2, 2, 186, 189, 3, 2, 2, 2, 187, 185, 3, 2, 2, 2, 187, 188, 3, 2, 2, 2, 188, 39, 3, 2, 2, 2, 189, 187, 3, 2, 2, 2, 19, 46, 49, 53, 61, 68, 75, 85, 89, 107, 110, 131, 141, 153, 163, 172, 180, 187] diff --git a/sv/btree/parser/BTreeDSL.tokens b/sv/btree/parser/BTreeDSL.tokens index 9c853b25..6a4dc39a 100644 --- a/sv/btree/parser/BTreeDSL.tokens +++ b/sv/btree/parser/BTreeDSL.tokens @@ -6,21 +6,25 @@ T__4=5 T__5=6 T__6=7 T__7=8 -OPERATOR=9 -BOP=10 -ATT=11 -FLOAT=12 -WORD=13 -WS=14 -NL=15 -INDENT=16 -DEDENT=17 +T__8=9 +T__9=10 +OPERATOR=11 +BOP=12 +ATT=13 +FLOAT=14 +WORD=15 +WS=16 +NL=17 +INDENT=18 +DEDENT=19 'behaviortree'=1 ':'=2 'condition'=3 '('=4 -')'=5 -'maneuver'=6 -'subtree'=7 -','=8 -'='=11 +','=5 +')'=6 +'maneuver'=7 +'subtree'=8 +'error'=9 +'delay'=10 +'='=13 diff --git a/sv/btree/parser/BTreeDSLLexer.interp b/sv/btree/parser/BTreeDSLLexer.interp index a344f170..7be2ba75 100644 --- a/sv/btree/parser/BTreeDSLLexer.interp +++ b/sv/btree/parser/BTreeDSLLexer.interp @@ -4,10 +4,12 @@ null ':' 'condition' '(' +',' ')' 'maneuver' 'subtree' -',' +'error' +'delay' null null '=' @@ -26,6 +28,8 @@ null null null null +null +null OPERATOR BOP ATT @@ -43,6 +47,8 @@ T__4 T__5 T__6 T__7 +T__8 +T__9 OPERATOR BOP ATT @@ -59,4 +65,4 @@ mode names: DEFAULT_MODE atn: -[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 17, 137, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 5, 10, 87, 10, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 5, 11, 98, 10, 11, 3, 12, 3, 12, 3, 13, 5, 13, 103, 10, 13, 3, 13, 7, 13, 106, 10, 13, 12, 13, 14, 13, 109, 11, 13, 3, 13, 5, 13, 112, 10, 13, 3, 13, 6, 13, 115, 10, 13, 13, 13, 14, 13, 116, 3, 14, 6, 14, 120, 10, 14, 13, 14, 14, 14, 121, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 5, 16, 129, 10, 16, 3, 16, 3, 16, 7, 16, 133, 10, 16, 12, 16, 14, 16, 136, 11, 16, 2, 2, 17, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 3, 2, 8, 4, 2, 62, 62, 64, 64, 4, 2, 45, 45, 47, 47, 3, 2, 50, 59, 3, 2, 48, 48, 5, 2, 67, 92, 97, 97, 99, 124, 4, 2, 11, 11, 34, 34, 2, 149, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 3, 33, 3, 2, 2, 2, 5, 46, 3, 2, 2, 2, 7, 48, 3, 2, 2, 2, 9, 58, 3, 2, 2, 2, 11, 60, 3, 2, 2, 2, 13, 62, 3, 2, 2, 2, 15, 71, 3, 2, 2, 2, 17, 79, 3, 2, 2, 2, 19, 86, 3, 2, 2, 2, 21, 97, 3, 2, 2, 2, 23, 99, 3, 2, 2, 2, 25, 102, 3, 2, 2, 2, 27, 119, 3, 2, 2, 2, 29, 123, 3, 2, 2, 2, 31, 128, 3, 2, 2, 2, 33, 34, 7, 100, 2, 2, 34, 35, 7, 103, 2, 2, 35, 36, 7, 106, 2, 2, 36, 37, 7, 99, 2, 2, 37, 38, 7, 120, 2, 2, 38, 39, 7, 107, 2, 2, 39, 40, 7, 113, 2, 2, 40, 41, 7, 116, 2, 2, 41, 42, 7, 118, 2, 2, 42, 43, 7, 116, 2, 2, 43, 44, 7, 103, 2, 2, 44, 45, 7, 103, 2, 2, 45, 4, 3, 2, 2, 2, 46, 47, 7, 60, 2, 2, 47, 6, 3, 2, 2, 2, 48, 49, 7, 101, 2, 2, 49, 50, 7, 113, 2, 2, 50, 51, 7, 112, 2, 2, 51, 52, 7, 102, 2, 2, 52, 53, 7, 107, 2, 2, 53, 54, 7, 118, 2, 2, 54, 55, 7, 107, 2, 2, 55, 56, 7, 113, 2, 2, 56, 57, 7, 112, 2, 2, 57, 8, 3, 2, 2, 2, 58, 59, 7, 42, 2, 2, 59, 10, 3, 2, 2, 2, 60, 61, 7, 43, 2, 2, 61, 12, 3, 2, 2, 2, 62, 63, 7, 111, 2, 2, 63, 64, 7, 99, 2, 2, 64, 65, 7, 112, 2, 2, 65, 66, 7, 103, 2, 2, 66, 67, 7, 119, 2, 2, 67, 68, 7, 120, 2, 2, 68, 69, 7, 103, 2, 2, 69, 70, 7, 116, 2, 2, 70, 14, 3, 2, 2, 2, 71, 72, 7, 117, 2, 2, 72, 73, 7, 119, 2, 2, 73, 74, 7, 100, 2, 2, 74, 75, 7, 118, 2, 2, 75, 76, 7, 116, 2, 2, 76, 77, 7, 103, 2, 2, 77, 78, 7, 103, 2, 2, 78, 16, 3, 2, 2, 2, 79, 80, 7, 46, 2, 2, 80, 18, 3, 2, 2, 2, 81, 87, 7, 65, 2, 2, 82, 83, 7, 47, 2, 2, 83, 87, 7, 64, 2, 2, 84, 85, 7, 126, 2, 2, 85, 87, 7, 126, 2, 2, 86, 81, 3, 2, 2, 2, 86, 82, 3, 2, 2, 2, 86, 84, 3, 2, 2, 2, 87, 20, 3, 2, 2, 2, 88, 98, 9, 2, 2, 2, 89, 90, 7, 63, 2, 2, 90, 98, 7, 63, 2, 2, 91, 92, 7, 64, 2, 2, 92, 98, 7, 63, 2, 2, 93, 94, 7, 62, 2, 2, 94, 98, 7, 63, 2, 2, 95, 96, 7, 35, 2, 2, 96, 98, 7, 63, 2, 2, 97, 88, 3, 2, 2, 2, 97, 89, 3, 2, 2, 2, 97, 91, 3, 2, 2, 2, 97, 93, 3, 2, 2, 2, 97, 95, 3, 2, 2, 2, 98, 22, 3, 2, 2, 2, 99, 100, 7, 63, 2, 2, 100, 24, 3, 2, 2, 2, 101, 103, 9, 3, 2, 2, 102, 101, 3, 2, 2, 2, 102, 103, 3, 2, 2, 2, 103, 111, 3, 2, 2, 2, 104, 106, 9, 4, 2, 2, 105, 104, 3, 2, 2, 2, 106, 109, 3, 2, 2, 2, 107, 105, 3, 2, 2, 2, 107, 108, 3, 2, 2, 2, 108, 110, 3, 2, 2, 2, 109, 107, 3, 2, 2, 2, 110, 112, 9, 5, 2, 2, 111, 107, 3, 2, 2, 2, 111, 112, 3, 2, 2, 2, 112, 114, 3, 2, 2, 2, 113, 115, 9, 4, 2, 2, 114, 113, 3, 2, 2, 2, 115, 116, 3, 2, 2, 2, 116, 114, 3, 2, 2, 2, 116, 117, 3, 2, 2, 2, 117, 26, 3, 2, 2, 2, 118, 120, 9, 6, 2, 2, 119, 118, 3, 2, 2, 2, 120, 121, 3, 2, 2, 2, 121, 119, 3, 2, 2, 2, 121, 122, 3, 2, 2, 2, 122, 28, 3, 2, 2, 2, 123, 124, 9, 7, 2, 2, 124, 125, 3, 2, 2, 2, 125, 126, 8, 15, 2, 2, 126, 30, 3, 2, 2, 2, 127, 129, 7, 15, 2, 2, 128, 127, 3, 2, 2, 2, 128, 129, 3, 2, 2, 2, 129, 130, 3, 2, 2, 2, 130, 134, 7, 12, 2, 2, 131, 133, 7, 34, 2, 2, 132, 131, 3, 2, 2, 2, 133, 136, 3, 2, 2, 2, 134, 132, 3, 2, 2, 2, 134, 135, 3, 2, 2, 2, 135, 32, 3, 2, 2, 2, 136, 134, 3, 2, 2, 2, 13, 2, 86, 97, 102, 107, 111, 116, 119, 121, 128, 134, 3, 8, 2, 2] \ No newline at end of file +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 19, 153, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 5, 12, 103, 10, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 5, 13, 114, 10, 13, 3, 14, 3, 14, 3, 15, 5, 15, 119, 10, 15, 3, 15, 7, 15, 122, 10, 15, 12, 15, 14, 15, 125, 11, 15, 3, 15, 5, 15, 128, 10, 15, 3, 15, 6, 15, 131, 10, 15, 13, 15, 14, 15, 132, 3, 16, 6, 16, 136, 10, 16, 13, 16, 14, 16, 137, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 5, 18, 145, 10, 18, 3, 18, 3, 18, 7, 18, 149, 10, 18, 12, 18, 14, 18, 152, 11, 18, 2, 2, 19, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 3, 2, 8, 4, 2, 62, 62, 64, 64, 4, 2, 45, 45, 47, 47, 3, 2, 50, 59, 3, 2, 48, 48, 5, 2, 67, 92, 97, 97, 99, 124, 4, 2, 11, 11, 34, 34, 2, 165, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 3, 37, 3, 2, 2, 2, 5, 50, 3, 2, 2, 2, 7, 52, 3, 2, 2, 2, 9, 62, 3, 2, 2, 2, 11, 64, 3, 2, 2, 2, 13, 66, 3, 2, 2, 2, 15, 68, 3, 2, 2, 2, 17, 77, 3, 2, 2, 2, 19, 85, 3, 2, 2, 2, 21, 91, 3, 2, 2, 2, 23, 102, 3, 2, 2, 2, 25, 113, 3, 2, 2, 2, 27, 115, 3, 2, 2, 2, 29, 118, 3, 2, 2, 2, 31, 135, 3, 2, 2, 2, 33, 139, 3, 2, 2, 2, 35, 144, 3, 2, 2, 2, 37, 38, 7, 100, 2, 2, 38, 39, 7, 103, 2, 2, 39, 40, 7, 106, 2, 2, 40, 41, 7, 99, 2, 2, 41, 42, 7, 120, 2, 2, 42, 43, 7, 107, 2, 2, 43, 44, 7, 113, 2, 2, 44, 45, 7, 116, 2, 2, 45, 46, 7, 118, 2, 2, 46, 47, 7, 116, 2, 2, 47, 48, 7, 103, 2, 2, 48, 49, 7, 103, 2, 2, 49, 4, 3, 2, 2, 2, 50, 51, 7, 60, 2, 2, 51, 6, 3, 2, 2, 2, 52, 53, 7, 101, 2, 2, 53, 54, 7, 113, 2, 2, 54, 55, 7, 112, 2, 2, 55, 56, 7, 102, 2, 2, 56, 57, 7, 107, 2, 2, 57, 58, 7, 118, 2, 2, 58, 59, 7, 107, 2, 2, 59, 60, 7, 113, 2, 2, 60, 61, 7, 112, 2, 2, 61, 8, 3, 2, 2, 2, 62, 63, 7, 42, 2, 2, 63, 10, 3, 2, 2, 2, 64, 65, 7, 46, 2, 2, 65, 12, 3, 2, 2, 2, 66, 67, 7, 43, 2, 2, 67, 14, 3, 2, 2, 2, 68, 69, 7, 111, 2, 2, 69, 70, 7, 99, 2, 2, 70, 71, 7, 112, 2, 2, 71, 72, 7, 103, 2, 2, 72, 73, 7, 119, 2, 2, 73, 74, 7, 120, 2, 2, 74, 75, 7, 103, 2, 2, 75, 76, 7, 116, 2, 2, 76, 16, 3, 2, 2, 2, 77, 78, 7, 117, 2, 2, 78, 79, 7, 119, 2, 2, 79, 80, 7, 100, 2, 2, 80, 81, 7, 118, 2, 2, 81, 82, 7, 116, 2, 2, 82, 83, 7, 103, 2, 2, 83, 84, 7, 103, 2, 2, 84, 18, 3, 2, 2, 2, 85, 86, 7, 103, 2, 2, 86, 87, 7, 116, 2, 2, 87, 88, 7, 116, 2, 2, 88, 89, 7, 113, 2, 2, 89, 90, 7, 116, 2, 2, 90, 20, 3, 2, 2, 2, 91, 92, 7, 102, 2, 2, 92, 93, 7, 103, 2, 2, 93, 94, 7, 110, 2, 2, 94, 95, 7, 99, 2, 2, 95, 96, 7, 123, 2, 2, 96, 22, 3, 2, 2, 2, 97, 103, 7, 65, 2, 2, 98, 99, 7, 47, 2, 2, 99, 103, 7, 64, 2, 2, 100, 101, 7, 126, 2, 2, 101, 103, 7, 126, 2, 2, 102, 97, 3, 2, 2, 2, 102, 98, 3, 2, 2, 2, 102, 100, 3, 2, 2, 2, 103, 24, 3, 2, 2, 2, 104, 114, 9, 2, 2, 2, 105, 106, 7, 63, 2, 2, 106, 114, 7, 63, 2, 2, 107, 108, 7, 64, 2, 2, 108, 114, 7, 63, 2, 2, 109, 110, 7, 62, 2, 2, 110, 114, 7, 63, 2, 2, 111, 112, 7, 35, 2, 2, 112, 114, 7, 63, 2, 2, 113, 104, 3, 2, 2, 2, 113, 105, 3, 2, 2, 2, 113, 107, 3, 2, 2, 2, 113, 109, 3, 2, 2, 2, 113, 111, 3, 2, 2, 2, 114, 26, 3, 2, 2, 2, 115, 116, 7, 63, 2, 2, 116, 28, 3, 2, 2, 2, 117, 119, 9, 3, 2, 2, 118, 117, 3, 2, 2, 2, 118, 119, 3, 2, 2, 2, 119, 127, 3, 2, 2, 2, 120, 122, 9, 4, 2, 2, 121, 120, 3, 2, 2, 2, 122, 125, 3, 2, 2, 2, 123, 121, 3, 2, 2, 2, 123, 124, 3, 2, 2, 2, 124, 126, 3, 2, 2, 2, 125, 123, 3, 2, 2, 2, 126, 128, 9, 5, 2, 2, 127, 123, 3, 2, 2, 2, 127, 128, 3, 2, 2, 2, 128, 130, 3, 2, 2, 2, 129, 131, 9, 4, 2, 2, 130, 129, 3, 2, 2, 2, 131, 132, 3, 2, 2, 2, 132, 130, 3, 2, 2, 2, 132, 133, 3, 2, 2, 2, 133, 30, 3, 2, 2, 2, 134, 136, 9, 6, 2, 2, 135, 134, 3, 2, 2, 2, 136, 137, 3, 2, 2, 2, 137, 135, 3, 2, 2, 2, 137, 138, 3, 2, 2, 2, 138, 32, 3, 2, 2, 2, 139, 140, 9, 7, 2, 2, 140, 141, 3, 2, 2, 2, 141, 142, 8, 17, 2, 2, 142, 34, 3, 2, 2, 2, 143, 145, 7, 15, 2, 2, 144, 143, 3, 2, 2, 2, 144, 145, 3, 2, 2, 2, 145, 146, 3, 2, 2, 2, 146, 150, 7, 12, 2, 2, 147, 149, 7, 34, 2, 2, 148, 147, 3, 2, 2, 2, 149, 152, 3, 2, 2, 2, 150, 148, 3, 2, 2, 2, 150, 151, 3, 2, 2, 2, 151, 36, 3, 2, 2, 2, 152, 150, 3, 2, 2, 2, 13, 2, 102, 113, 118, 123, 127, 132, 135, 137, 144, 150, 3, 8, 2, 2] \ No newline at end of file diff --git a/sv/btree/parser/BTreeDSLLexer.py b/sv/btree/parser/BTreeDSLLexer.py index 6e3089a8..bf1b5fb8 100644 --- a/sv/btree/parser/BTreeDSLLexer.py +++ b/sv/btree/parser/BTreeDSLLexer.py @@ -10,53 +10,62 @@ def serializedATN(): with StringIO() as buf: - buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\21") - buf.write("\u0089\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7") + buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\23") + buf.write("\u0099\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7") buf.write("\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r") - buf.write("\4\16\t\16\4\17\t\17\4\20\t\20\3\2\3\2\3\2\3\2\3\2\3\2") - buf.write("\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\3\3\3\3\4\3\4\3\4\3\4\3") - buf.write("\4\3\4\3\4\3\4\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\7\3\7") - buf.write("\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3") - buf.write("\t\3\t\3\n\3\n\3\n\3\n\3\n\5\nW\n\n\3\13\3\13\3\13\3\13") - buf.write("\3\13\3\13\3\13\3\13\3\13\5\13b\n\13\3\f\3\f\3\r\5\rg") - buf.write("\n\r\3\r\7\rj\n\r\f\r\16\rm\13\r\3\r\5\rp\n\r\3\r\6\r") - buf.write("s\n\r\r\r\16\rt\3\16\6\16x\n\16\r\16\16\16y\3\17\3\17") - buf.write("\3\17\3\17\3\20\5\20\u0081\n\20\3\20\3\20\7\20\u0085\n") - buf.write("\20\f\20\16\20\u0088\13\20\2\2\21\3\3\5\4\7\5\t\6\13\7") - buf.write("\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21") - buf.write("\3\2\b\4\2>>@@\4\2--//\3\2\62;\3\2\60\60\5\2C\\aac|\4") - buf.write("\2\13\13\"\"\2\u0095\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2") - buf.write("\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2") - buf.write("\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31") - buf.write("\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\3!\3\2") - buf.write("\2\2\5.\3\2\2\2\7\60\3\2\2\2\t:\3\2\2\2\13<\3\2\2\2\r") - buf.write(">\3\2\2\2\17G\3\2\2\2\21O\3\2\2\2\23V\3\2\2\2\25a\3\2") - buf.write("\2\2\27c\3\2\2\2\31f\3\2\2\2\33w\3\2\2\2\35{\3\2\2\2\37") - buf.write("\u0080\3\2\2\2!\"\7d\2\2\"#\7g\2\2#$\7j\2\2$%\7c\2\2%") - buf.write("&\7x\2\2&\'\7k\2\2\'(\7q\2\2()\7t\2\2)*\7v\2\2*+\7t\2") - buf.write("\2+,\7g\2\2,-\7g\2\2-\4\3\2\2\2./\7<\2\2/\6\3\2\2\2\60") - buf.write("\61\7e\2\2\61\62\7q\2\2\62\63\7p\2\2\63\64\7f\2\2\64\65") - buf.write("\7k\2\2\65\66\7v\2\2\66\67\7k\2\2\678\7q\2\289\7p\2\2") - buf.write("9\b\3\2\2\2:;\7*\2\2;\n\3\2\2\2<=\7+\2\2=\f\3\2\2\2>?") - buf.write("\7o\2\2?@\7c\2\2@A\7p\2\2AB\7g\2\2BC\7w\2\2CD\7x\2\2D") - buf.write("E\7g\2\2EF\7t\2\2F\16\3\2\2\2GH\7u\2\2HI\7w\2\2IJ\7d\2") - buf.write("\2JK\7v\2\2KL\7t\2\2LM\7g\2\2MN\7g\2\2N\20\3\2\2\2OP\7") - buf.write(".\2\2P\22\3\2\2\2QW\7A\2\2RS\7/\2\2SW\7@\2\2TU\7~\2\2") - buf.write("UW\7~\2\2VQ\3\2\2\2VR\3\2\2\2VT\3\2\2\2W\24\3\2\2\2Xb") - buf.write("\t\2\2\2YZ\7?\2\2Zb\7?\2\2[\\\7@\2\2\\b\7?\2\2]^\7>\2") - buf.write("\2^b\7?\2\2_`\7#\2\2`b\7?\2\2aX\3\2\2\2aY\3\2\2\2a[\3") - buf.write("\2\2\2a]\3\2\2\2a_\3\2\2\2b\26\3\2\2\2cd\7?\2\2d\30\3") - buf.write("\2\2\2eg\t\3\2\2fe\3\2\2\2fg\3\2\2\2go\3\2\2\2hj\t\4\2") - buf.write("\2ih\3\2\2\2jm\3\2\2\2ki\3\2\2\2kl\3\2\2\2ln\3\2\2\2m") - buf.write("k\3\2\2\2np\t\5\2\2ok\3\2\2\2op\3\2\2\2pr\3\2\2\2qs\t") - buf.write("\4\2\2rq\3\2\2\2st\3\2\2\2tr\3\2\2\2tu\3\2\2\2u\32\3\2") - buf.write("\2\2vx\t\6\2\2wv\3\2\2\2xy\3\2\2\2yw\3\2\2\2yz\3\2\2\2") - buf.write("z\34\3\2\2\2{|\t\7\2\2|}\3\2\2\2}~\b\17\2\2~\36\3\2\2") - buf.write("\2\177\u0081\7\17\2\2\u0080\177\3\2\2\2\u0080\u0081\3") - buf.write("\2\2\2\u0081\u0082\3\2\2\2\u0082\u0086\7\f\2\2\u0083\u0085") - buf.write("\7\"\2\2\u0084\u0083\3\2\2\2\u0085\u0088\3\2\2\2\u0086") - buf.write("\u0084\3\2\2\2\u0086\u0087\3\2\2\2\u0087 \3\2\2\2\u0088") - buf.write("\u0086\3\2\2\2\r\2Vafkotwy\u0080\u0086\3\b\2\2") + buf.write("\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\3\2") + buf.write("\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\3\3") + buf.write("\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\5\3\5\3\6") + buf.write("\3\6\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\b\3\t\3") + buf.write("\t\3\t\3\t\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3\13") + buf.write("\3\13\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\5\fg\n\f") + buf.write("\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\5\rr\n\r\3\16\3\16") + buf.write("\3\17\5\17w\n\17\3\17\7\17z\n\17\f\17\16\17}\13\17\3\17") + buf.write("\5\17\u0080\n\17\3\17\6\17\u0083\n\17\r\17\16\17\u0084") + buf.write("\3\20\6\20\u0088\n\20\r\20\16\20\u0089\3\21\3\21\3\21") + buf.write("\3\21\3\22\5\22\u0091\n\22\3\22\3\22\7\22\u0095\n\22\f") + buf.write("\22\16\22\u0098\13\22\2\2\23\3\3\5\4\7\5\t\6\13\7\r\b") + buf.write("\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22") + buf.write("#\23\3\2\b\4\2>>@@\4\2--//\3\2\62;\3\2\60\60\5\2C\\aa") + buf.write("c|\4\2\13\13\"\"\2\u00a5\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3") + buf.write("\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2") + buf.write("\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2") + buf.write("\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2") + buf.write("!\3\2\2\2\2#\3\2\2\2\3%\3\2\2\2\5\62\3\2\2\2\7\64\3\2") + buf.write("\2\2\t>\3\2\2\2\13@\3\2\2\2\rB\3\2\2\2\17D\3\2\2\2\21") + buf.write("M\3\2\2\2\23U\3\2\2\2\25[\3\2\2\2\27f\3\2\2\2\31q\3\2") + buf.write("\2\2\33s\3\2\2\2\35v\3\2\2\2\37\u0087\3\2\2\2!\u008b\3") + buf.write("\2\2\2#\u0090\3\2\2\2%&\7d\2\2&\'\7g\2\2\'(\7j\2\2()\7") + buf.write("c\2\2)*\7x\2\2*+\7k\2\2+,\7q\2\2,-\7t\2\2-.\7v\2\2./\7") + buf.write("t\2\2/\60\7g\2\2\60\61\7g\2\2\61\4\3\2\2\2\62\63\7<\2") + buf.write("\2\63\6\3\2\2\2\64\65\7e\2\2\65\66\7q\2\2\66\67\7p\2\2") + buf.write("\678\7f\2\289\7k\2\29:\7v\2\2:;\7k\2\2;<\7q\2\2<=\7p\2") + buf.write("\2=\b\3\2\2\2>?\7*\2\2?\n\3\2\2\2@A\7.\2\2A\f\3\2\2\2") + buf.write("BC\7+\2\2C\16\3\2\2\2DE\7o\2\2EF\7c\2\2FG\7p\2\2GH\7g") + buf.write("\2\2HI\7w\2\2IJ\7x\2\2JK\7g\2\2KL\7t\2\2L\20\3\2\2\2M") + buf.write("N\7u\2\2NO\7w\2\2OP\7d\2\2PQ\7v\2\2QR\7t\2\2RS\7g\2\2") + buf.write("ST\7g\2\2T\22\3\2\2\2UV\7g\2\2VW\7t\2\2WX\7t\2\2XY\7q") + buf.write("\2\2YZ\7t\2\2Z\24\3\2\2\2[\\\7f\2\2\\]\7g\2\2]^\7n\2\2") + buf.write("^_\7c\2\2_`\7{\2\2`\26\3\2\2\2ag\7A\2\2bc\7/\2\2cg\7@") + buf.write("\2\2de\7~\2\2eg\7~\2\2fa\3\2\2\2fb\3\2\2\2fd\3\2\2\2g") + buf.write("\30\3\2\2\2hr\t\2\2\2ij\7?\2\2jr\7?\2\2kl\7@\2\2lr\7?") + buf.write("\2\2mn\7>\2\2nr\7?\2\2op\7#\2\2pr\7?\2\2qh\3\2\2\2qi\3") + buf.write("\2\2\2qk\3\2\2\2qm\3\2\2\2qo\3\2\2\2r\32\3\2\2\2st\7?") + buf.write("\2\2t\34\3\2\2\2uw\t\3\2\2vu\3\2\2\2vw\3\2\2\2w\177\3") + buf.write("\2\2\2xz\t\4\2\2yx\3\2\2\2z}\3\2\2\2{y\3\2\2\2{|\3\2\2") + buf.write("\2|~\3\2\2\2}{\3\2\2\2~\u0080\t\5\2\2\177{\3\2\2\2\177") + buf.write("\u0080\3\2\2\2\u0080\u0082\3\2\2\2\u0081\u0083\t\4\2\2") + buf.write("\u0082\u0081\3\2\2\2\u0083\u0084\3\2\2\2\u0084\u0082\3") + buf.write("\2\2\2\u0084\u0085\3\2\2\2\u0085\36\3\2\2\2\u0086\u0088") + buf.write("\t\6\2\2\u0087\u0086\3\2\2\2\u0088\u0089\3\2\2\2\u0089") + buf.write("\u0087\3\2\2\2\u0089\u008a\3\2\2\2\u008a \3\2\2\2\u008b") + buf.write("\u008c\t\7\2\2\u008c\u008d\3\2\2\2\u008d\u008e\b\21\2") + buf.write("\2\u008e\"\3\2\2\2\u008f\u0091\7\17\2\2\u0090\u008f\3") + buf.write("\2\2\2\u0090\u0091\3\2\2\2\u0091\u0092\3\2\2\2\u0092\u0096") + buf.write("\7\f\2\2\u0093\u0095\7\"\2\2\u0094\u0093\3\2\2\2\u0095") + buf.write("\u0098\3\2\2\2\u0096\u0094\3\2\2\2\u0096\u0097\3\2\2\2") + buf.write("\u0097$\3\2\2\2\u0098\u0096\3\2\2\2\r\2fqv{\177\u0084") + buf.write("\u0087\u0089\u0090\u0096\3\b\2\2") return buf.getvalue() @@ -74,28 +83,30 @@ class BTreeDSLLexer(Lexer): T__5 = 6 T__6 = 7 T__7 = 8 - OPERATOR = 9 - BOP = 10 - ATT = 11 - FLOAT = 12 - WORD = 13 - WS = 14 - NL = 15 + T__8 = 9 + T__9 = 10 + OPERATOR = 11 + BOP = 12 + ATT = 13 + FLOAT = 14 + WORD = 15 + WS = 16 + NL = 17 channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ] modeNames = [ "DEFAULT_MODE" ] literalNames = [ "", - "'behaviortree'", "':'", "'condition'", "'('", "')'", "'maneuver'", - "'subtree'", "','", "'='" ] + "'behaviortree'", "':'", "'condition'", "'('", "','", "')'", + "'maneuver'", "'subtree'", "'error'", "'delay'", "'='" ] symbolicNames = [ "", "OPERATOR", "BOP", "ATT", "FLOAT", "WORD", "WS", "NL" ] ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", - "T__7", "OPERATOR", "BOP", "ATT", "FLOAT", "WORD", "WS", - "NL" ] + "T__7", "T__8", "T__9", "OPERATOR", "BOP", "ATT", "FLOAT", + "WORD", "WS", "NL" ] grammarFileName = "BTreeDSL.g4" diff --git a/sv/btree/parser/BTreeDSLLexer.tokens b/sv/btree/parser/BTreeDSLLexer.tokens index dbec86dd..917f930f 100644 --- a/sv/btree/parser/BTreeDSLLexer.tokens +++ b/sv/btree/parser/BTreeDSLLexer.tokens @@ -6,19 +6,23 @@ T__4=5 T__5=6 T__6=7 T__7=8 -OPERATOR=9 -BOP=10 -ATT=11 -FLOAT=12 -WORD=13 -WS=14 -NL=15 +T__8=9 +T__9=10 +OPERATOR=11 +BOP=12 +ATT=13 +FLOAT=14 +WORD=15 +WS=16 +NL=17 'behaviortree'=1 ':'=2 'condition'=3 '('=4 -')'=5 -'maneuver'=6 -'subtree'=7 -','=8 -'='=11 +','=5 +')'=6 +'maneuver'=7 +'subtree'=8 +'error'=9 +'delay'=10 +'='=13 diff --git a/sv/btree/parser/BTreeDSLListener.py b/sv/btree/parser/BTreeDSLListener.py index e7e501f3..e810435e 100644 --- a/sv/btree/parser/BTreeDSLListener.py +++ b/sv/btree/parser/BTreeDSLListener.py @@ -89,6 +89,24 @@ def exitMidconf(self, ctx:BTreeDSLParser.MidconfContext): pass + # Enter a parse tree produced by BTreeDSLParser#error. + def enterError(self, ctx:BTreeDSLParser.ErrorContext): + pass + + # Exit a parse tree produced by BTreeDSLParser#error. + def exitError(self, ctx:BTreeDSLParser.ErrorContext): + pass + + + # Enter a parse tree produced by BTreeDSLParser#delay. + def enterDelay(self, ctx:BTreeDSLParser.DelayContext): + pass + + # Exit a parse tree produced by BTreeDSLParser#delay. + def exitDelay(self, ctx:BTreeDSLParser.DelayContext): + pass + + # Enter a parse tree produced by BTreeDSLParser#mconfig. def enterMconfig(self, ctx:BTreeDSLParser.MconfigContext): pass diff --git a/sv/btree/parser/BTreeDSLParser.py b/sv/btree/parser/BTreeDSLParser.py index 56b565d5..d38d37c3 100644 --- a/sv/btree/parser/BTreeDSLParser.py +++ b/sv/btree/parser/BTreeDSLParser.py @@ -7,75 +7,78 @@ def serializedATN(): with StringIO() as buf: - buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\23") - buf.write("\u00b9\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7") + buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\25") + buf.write("\u00bf\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7") buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16") buf.write("\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4\23\t\23") - buf.write("\3\2\3\2\3\2\3\2\3\2\3\2\5\2-\n\2\3\2\5\2\60\n\2\6\2\62") - buf.write("\n\2\r\2\16\2\63\3\2\3\2\3\3\3\3\3\4\3\4\5\4<\n\4\3\5") - buf.write("\3\5\3\5\6\5A\n\5\r\5\16\5B\3\5\3\5\3\6\3\6\3\6\5\6J\n") - buf.write("\6\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b") - buf.write("\3\b\3\t\3\t\3\t\3\t\3\t\3\t\7\t`\n\t\f\t\16\tc\13\t\5") - buf.write("\te\n\t\3\t\3\t\3\n\3\n\3\n\3\n\3\13\3\13\3\13\7\13p\n") - buf.write("\13\f\13\16\13s\13\13\3\13\3\13\3\f\3\f\3\f\7\fz\n\f\f") - buf.write("\f\16\f}\13\f\3\f\3\f\3\r\3\r\3\16\3\16\3\16\7\16\u0086") - buf.write("\n\16\f\16\16\16\u0089\13\16\3\17\3\17\3\17\3\17\3\20") - buf.write("\3\20\3\20\3\20\5\20\u0093\n\20\3\21\3\21\3\21\3\21\3") - buf.write("\21\7\21\u009a\n\21\f\21\16\21\u009d\13\21\3\21\3\21\3") - buf.write("\22\3\22\3\22\3\22\7\22\u00a5\n\22\f\22\16\22\u00a8\13") - buf.write("\22\3\22\3\22\3\23\7\23\u00ad\n\23\f\23\16\23\u00b0\13") - buf.write("\23\3\23\3\23\7\23\u00b4\n\23\f\23\16\23\u00b7\13\23\3") - buf.write("\23\2\2\24\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \"$") - buf.write("\2\3\3\2\f\r\2\u00b9\2\61\3\2\2\2\4\67\3\2\2\2\6;\3\2") - buf.write("\2\2\b=\3\2\2\2\nI\3\2\2\2\fM\3\2\2\2\16S\3\2\2\2\20Y") - buf.write("\3\2\2\2\22h\3\2\2\2\24l\3\2\2\2\26v\3\2\2\2\30\u0080") - buf.write("\3\2\2\2\32\u0082\3\2\2\2\34\u008a\3\2\2\2\36\u0092\3") - buf.write("\2\2\2 \u0094\3\2\2\2\"\u00a0\3\2\2\2$\u00ae\3\2\2\2&") - buf.write("\'\7\3\2\2\'(\5$\23\2()\7\4\2\2)*\7\22\2\2*,\5\4\3\2+") - buf.write("-\7\21\2\2,+\3\2\2\2,-\3\2\2\2-/\3\2\2\2.\60\7\23\2\2") - buf.write("/.\3\2\2\2/\60\3\2\2\2\60\62\3\2\2\2\61&\3\2\2\2\62\63") - buf.write("\3\2\2\2\63\61\3\2\2\2\63\64\3\2\2\2\64\65\3\2\2\2\65") - buf.write("\66\7\2\2\3\66\3\3\2\2\2\678\5\6\4\28\5\3\2\2\29<\5\n") - buf.write("\6\2:<\5\b\5\2;9\3\2\2\2;:\3\2\2\2<\7\3\2\2\2=>\7\13\2") - buf.write("\2>@\7\22\2\2?A\5\6\4\2@?\3\2\2\2AB\3\2\2\2B@\3\2\2\2") - buf.write("BC\3\2\2\2CD\3\2\2\2DE\7\23\2\2E\t\3\2\2\2FJ\5\16\b\2") - buf.write("GJ\5\f\7\2HJ\5\20\t\2IF\3\2\2\2IG\3\2\2\2IH\3\2\2\2JK") - buf.write("\3\2\2\2KL\7\21\2\2L\13\3\2\2\2MN\7\5\2\2NO\5$\23\2OP") - buf.write("\7\6\2\2PQ\5\26\f\2QR\7\7\2\2R\r\3\2\2\2ST\7\b\2\2TU\5") - buf.write("$\23\2UV\7\6\2\2VW\5\24\13\2WX\7\7\2\2X\17\3\2\2\2YZ\7") - buf.write("\t\2\2Z[\5$\23\2[d\7\6\2\2\\a\5\22\n\2]^\7\n\2\2^`\5\22") - buf.write("\n\2_]\3\2\2\2`c\3\2\2\2a_\3\2\2\2ab\3\2\2\2be\3\2\2\2") - buf.write("ca\3\2\2\2d\\\3\2\2\2de\3\2\2\2ef\3\2\2\2fg\7\7\2\2g\21") - buf.write("\3\2\2\2hi\5\30\r\2ij\7\r\2\2jk\5\24\13\2k\23\3\2\2\2") - buf.write("lm\5$\23\2mq\7\6\2\2np\5\32\16\2on\3\2\2\2ps\3\2\2\2q") - buf.write("o\3\2\2\2qr\3\2\2\2rt\3\2\2\2sq\3\2\2\2tu\7\7\2\2u\25") - buf.write("\3\2\2\2vw\5$\23\2w{\7\6\2\2xz\5\32\16\2yx\3\2\2\2z}\3") - buf.write("\2\2\2{y\3\2\2\2{|\3\2\2\2|~\3\2\2\2}{\3\2\2\2~\177\7") - buf.write("\7\2\2\177\27\3\2\2\2\u0080\u0081\5$\23\2\u0081\31\3\2") - buf.write("\2\2\u0082\u0087\5\34\17\2\u0083\u0084\7\n\2\2\u0084\u0086") - buf.write("\5\34\17\2\u0085\u0083\3\2\2\2\u0086\u0089\3\2\2\2\u0087") - buf.write("\u0085\3\2\2\2\u0087\u0088\3\2\2\2\u0088\33\3\2\2\2\u0089") - buf.write("\u0087\3\2\2\2\u008a\u008b\5$\23\2\u008b\u008c\t\2\2\2") - buf.write("\u008c\u008d\5\36\20\2\u008d\35\3\2\2\2\u008e\u0093\7") - buf.write("\16\2\2\u008f\u0093\5$\23\2\u0090\u0093\5 \21\2\u0091") - buf.write("\u0093\5\"\22\2\u0092\u008e\3\2\2\2\u0092\u008f\3\2\2") - buf.write("\2\u0092\u0090\3\2\2\2\u0092\u0091\3\2\2\2\u0093\37\3") - buf.write("\2\2\2\u0094\u0095\5$\23\2\u0095\u0096\7\6\2\2\u0096\u009b") - buf.write("\7\16\2\2\u0097\u0098\7\n\2\2\u0098\u009a\7\16\2\2\u0099") - buf.write("\u0097\3\2\2\2\u009a\u009d\3\2\2\2\u009b\u0099\3\2\2\2") - buf.write("\u009b\u009c\3\2\2\2\u009c\u009e\3\2\2\2\u009d\u009b\3") - buf.write("\2\2\2\u009e\u009f\7\7\2\2\u009f!\3\2\2\2\u00a0\u00a1") - buf.write("\7\6\2\2\u00a1\u00a6\7\16\2\2\u00a2\u00a3\7\n\2\2\u00a3") - buf.write("\u00a5\7\16\2\2\u00a4\u00a2\3\2\2\2\u00a5\u00a8\3\2\2") - buf.write("\2\u00a6\u00a4\3\2\2\2\u00a6\u00a7\3\2\2\2\u00a7\u00a9") - buf.write("\3\2\2\2\u00a8\u00a6\3\2\2\2\u00a9\u00aa\7\7\2\2\u00aa") - buf.write("#\3\2\2\2\u00ab\u00ad\7\20\2\2\u00ac\u00ab\3\2\2\2\u00ad") - buf.write("\u00b0\3\2\2\2\u00ae\u00ac\3\2\2\2\u00ae\u00af\3\2\2\2") - buf.write("\u00af\u00b1\3\2\2\2\u00b0\u00ae\3\2\2\2\u00b1\u00b5\7") - buf.write("\17\2\2\u00b2\u00b4\7\20\2\2\u00b3\u00b2\3\2\2\2\u00b4") - buf.write("\u00b7\3\2\2\2\u00b5\u00b3\3\2\2\2\u00b5\u00b6\3\2\2\2") - buf.write("\u00b6%\3\2\2\2\u00b7\u00b5\3\2\2\2\22,/\63;BIadq{\u0087") - buf.write("\u0092\u009b\u00a6\u00ae\u00b5") + buf.write("\4\24\t\24\3\2\3\2\3\2\3\2\3\2\3\2\5\2/\n\2\3\2\5\2\62") + buf.write("\n\2\6\2\64\n\2\r\2\16\2\65\3\2\3\2\3\3\3\3\3\4\3\4\5") + buf.write("\4>\n\4\3\5\3\5\3\5\6\5C\n\5\r\5\16\5D\3\5\3\5\3\6\3\6") + buf.write("\3\6\5\6L\n\6\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\7\5\7V\n\7") + buf.write("\3\7\3\7\5\7Z\n\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\b\3\t") + buf.write("\3\t\3\t\3\t\3\t\3\t\7\tj\n\t\f\t\16\tm\13\t\5\to\n\t") + buf.write("\3\t\3\t\3\n\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3\f\3\f\3") + buf.write("\f\3\f\3\r\3\r\3\r\7\r\u0082\n\r\f\r\16\r\u0085\13\r\3") + buf.write("\r\3\r\3\16\3\16\3\16\7\16\u008c\n\16\f\16\16\16\u008f") + buf.write("\13\16\3\16\3\16\3\17\3\17\3\20\3\20\3\20\7\20\u0098\n") + buf.write("\20\f\20\16\20\u009b\13\20\3\21\3\21\3\21\3\21\3\22\3") + buf.write("\22\3\22\5\22\u00a4\n\22\3\23\3\23\3\23\3\23\3\23\7\23") + buf.write("\u00ab\n\23\f\23\16\23\u00ae\13\23\3\23\3\23\3\24\7\24") + buf.write("\u00b3\n\24\f\24\16\24\u00b6\13\24\3\24\3\24\7\24\u00ba") + buf.write("\n\24\f\24\16\24\u00bd\13\24\3\24\2\2\25\2\4\6\b\n\f\16") + buf.write("\20\22\24\26\30\32\34\36 \"$&\2\3\3\2\16\17\2\u00be\2") + buf.write("\63\3\2\2\2\49\3\2\2\2\6=\3\2\2\2\b?\3\2\2\2\nK\3\2\2") + buf.write("\2\fO\3\2\2\2\16]\3\2\2\2\20c\3\2\2\2\22r\3\2\2\2\24v") + buf.write("\3\2\2\2\26z\3\2\2\2\30~\3\2\2\2\32\u0088\3\2\2\2\34\u0092") + buf.write("\3\2\2\2\36\u0094\3\2\2\2 \u009c\3\2\2\2\"\u00a3\3\2\2") + buf.write("\2$\u00a5\3\2\2\2&\u00b4\3\2\2\2()\7\3\2\2)*\5&\24\2*") + buf.write("+\7\4\2\2+,\7\24\2\2,.\5\4\3\2-/\7\23\2\2.-\3\2\2\2./") + buf.write("\3\2\2\2/\61\3\2\2\2\60\62\7\25\2\2\61\60\3\2\2\2\61\62") + buf.write("\3\2\2\2\62\64\3\2\2\2\63(\3\2\2\2\64\65\3\2\2\2\65\63") + buf.write("\3\2\2\2\65\66\3\2\2\2\66\67\3\2\2\2\678\7\2\2\38\3\3") + buf.write("\2\2\29:\5\6\4\2:\5\3\2\2\2;>\5\n\6\2<>\5\b\5\2=;\3\2") + buf.write("\2\2=<\3\2\2\2>\7\3\2\2\2?@\7\r\2\2@B\7\24\2\2AC\5\6\4") + buf.write("\2BA\3\2\2\2CD\3\2\2\2DB\3\2\2\2DE\3\2\2\2EF\3\2\2\2F") + buf.write("G\7\25\2\2G\t\3\2\2\2HL\5\16\b\2IL\5\f\7\2JL\5\20\t\2") + buf.write("KH\3\2\2\2KI\3\2\2\2KJ\3\2\2\2LM\3\2\2\2MN\7\23\2\2N\13") + buf.write("\3\2\2\2OP\7\5\2\2PQ\5&\24\2QR\7\6\2\2RU\5\32\16\2ST\7") + buf.write("\7\2\2TV\5\24\13\2US\3\2\2\2UV\3\2\2\2VY\3\2\2\2WX\7\7") + buf.write("\2\2XZ\5\26\f\2YW\3\2\2\2YZ\3\2\2\2Z[\3\2\2\2[\\\7\b\2") + buf.write("\2\\\r\3\2\2\2]^\7\t\2\2^_\5&\24\2_`\7\6\2\2`a\5\30\r") + buf.write("\2ab\7\b\2\2b\17\3\2\2\2cd\7\n\2\2de\5&\24\2en\7\6\2\2") + buf.write("fk\5\22\n\2gh\7\7\2\2hj\5\22\n\2ig\3\2\2\2jm\3\2\2\2k") + buf.write("i\3\2\2\2kl\3\2\2\2lo\3\2\2\2mk\3\2\2\2nf\3\2\2\2no\3") + buf.write("\2\2\2op\3\2\2\2pq\7\b\2\2q\21\3\2\2\2rs\5\34\17\2st\7") + buf.write("\17\2\2tu\5\30\r\2u\23\3\2\2\2vw\7\13\2\2wx\7\17\2\2x") + buf.write("y\7\20\2\2y\25\3\2\2\2z{\7\f\2\2{|\7\17\2\2|}\7\20\2\2") + buf.write("}\27\3\2\2\2~\177\5&\24\2\177\u0083\7\6\2\2\u0080\u0082") + buf.write("\5\36\20\2\u0081\u0080\3\2\2\2\u0082\u0085\3\2\2\2\u0083") + buf.write("\u0081\3\2\2\2\u0083\u0084\3\2\2\2\u0084\u0086\3\2\2\2") + buf.write("\u0085\u0083\3\2\2\2\u0086\u0087\7\b\2\2\u0087\31\3\2") + buf.write("\2\2\u0088\u0089\5&\24\2\u0089\u008d\7\6\2\2\u008a\u008c") + buf.write("\5\36\20\2\u008b\u008a\3\2\2\2\u008c\u008f\3\2\2\2\u008d") + buf.write("\u008b\3\2\2\2\u008d\u008e\3\2\2\2\u008e\u0090\3\2\2\2") + buf.write("\u008f\u008d\3\2\2\2\u0090\u0091\7\b\2\2\u0091\33\3\2") + buf.write("\2\2\u0092\u0093\5&\24\2\u0093\35\3\2\2\2\u0094\u0099") + buf.write("\5 \21\2\u0095\u0096\7\7\2\2\u0096\u0098\5 \21\2\u0097") + buf.write("\u0095\3\2\2\2\u0098\u009b\3\2\2\2\u0099\u0097\3\2\2\2") + buf.write("\u0099\u009a\3\2\2\2\u009a\37\3\2\2\2\u009b\u0099\3\2") + buf.write("\2\2\u009c\u009d\5&\24\2\u009d\u009e\t\2\2\2\u009e\u009f") + buf.write("\5\"\22\2\u009f!\3\2\2\2\u00a0\u00a4\7\20\2\2\u00a1\u00a4") + buf.write("\5&\24\2\u00a2\u00a4\5$\23\2\u00a3\u00a0\3\2\2\2\u00a3") + buf.write("\u00a1\3\2\2\2\u00a3\u00a2\3\2\2\2\u00a4#\3\2\2\2\u00a5") + buf.write("\u00a6\5&\24\2\u00a6\u00a7\7\6\2\2\u00a7\u00ac\7\20\2") + buf.write("\2\u00a8\u00a9\7\7\2\2\u00a9\u00ab\7\20\2\2\u00aa\u00a8") + buf.write("\3\2\2\2\u00ab\u00ae\3\2\2\2\u00ac\u00aa\3\2\2\2\u00ac") + buf.write("\u00ad\3\2\2\2\u00ad\u00af\3\2\2\2\u00ae\u00ac\3\2\2\2") + buf.write("\u00af\u00b0\7\b\2\2\u00b0%\3\2\2\2\u00b1\u00b3\7\22\2") + buf.write("\2\u00b2\u00b1\3\2\2\2\u00b3\u00b6\3\2\2\2\u00b4\u00b2") + buf.write("\3\2\2\2\u00b4\u00b5\3\2\2\2\u00b5\u00b7\3\2\2\2\u00b6") + buf.write("\u00b4\3\2\2\2\u00b7\u00bb\7\21\2\2\u00b8\u00ba\7\22\2") + buf.write("\2\u00b9\u00b8\3\2\2\2\u00ba\u00bd\3\2\2\2\u00bb\u00b9") + buf.write("\3\2\2\2\u00bb\u00bc\3\2\2\2\u00bc\'\3\2\2\2\u00bd\u00bb") + buf.write("\3\2\2\2\23.\61\65=DKUYkn\u0083\u008d\u0099\u00a3\u00ac") + buf.write("\u00b4\u00bb") return buf.getvalue() @@ -90,13 +93,14 @@ class BTreeDSLParser ( Parser ): sharedContextCache = PredictionContextCache() literalNames = [ "", "'behaviortree'", "':'", "'condition'", - "'('", "')'", "'maneuver'", "'subtree'", "','", "", - "", "'='" ] + "'('", "','", "')'", "'maneuver'", "'subtree'", "'error'", + "'delay'", "", "", "'='" ] symbolicNames = [ "", "", "", "", "", "", "", "", - "", "OPERATOR", "BOP", "ATT", "FLOAT", "WORD", - "WS", "NL", "INDENT", "DEDENT" ] + "", "", "", "OPERATOR", + "BOP", "ATT", "FLOAT", "WORD", "WS", "NL", "INDENT", + "DEDENT" ] RULE_behaviorTree = 0 RULE_rootNode = 1 @@ -107,20 +111,21 @@ class BTreeDSLParser ( Parser ): RULE_maneuver = 6 RULE_subtree = 7 RULE_midconf = 8 - RULE_mconfig = 9 - RULE_cconfig = 10 - RULE_mid = 11 - RULE_params = 12 - RULE_bexpr = 13 - RULE_value = 14 - RULE_func = 15 - RULE_tupl = 16 - RULE_name = 17 + RULE_error = 9 + RULE_delay = 10 + RULE_mconfig = 11 + RULE_cconfig = 12 + RULE_mid = 13 + RULE_params = 14 + RULE_bexpr = 15 + RULE_value = 16 + RULE_func = 17 + RULE_name = 18 ruleNames = [ "behaviorTree", "rootNode", "node", "nodeComposition", "leafNode", "condition", "maneuver", "subtree", "midconf", - "mconfig", "cconfig", "mid", "params", "bexpr", "value", - "func", "tupl", "name" ] + "error", "delay", "mconfig", "cconfig", "mid", "params", + "bexpr", "value", "func", "name" ] EOF = Token.EOF T__0=1 @@ -131,15 +136,17 @@ class BTreeDSLParser ( Parser ): T__5=6 T__6=7 T__7=8 - OPERATOR=9 - BOP=10 - ATT=11 - FLOAT=12 - WORD=13 - WS=14 - NL=15 - INDENT=16 - DEDENT=17 + T__8=9 + T__9=10 + OPERATOR=11 + BOP=12 + ATT=13 + FLOAT=14 + WORD=15 + WS=16 + NL=17 + INDENT=18 + DEDENT=19 def __init__(self, input:TokenStream, output:TextIO = sys.stdout): super().__init__(input, output) @@ -211,43 +218,43 @@ def behaviorTree(self): self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 47 + self.state = 49 self._errHandler.sync(self) _la = self._input.LA(1) while True: - self.state = 36 + self.state = 38 self.match(BTreeDSLParser.T__0) - self.state = 37 + self.state = 39 self.name() - self.state = 38 + self.state = 40 self.match(BTreeDSLParser.T__1) - self.state = 39 + self.state = 41 self.match(BTreeDSLParser.INDENT) - self.state = 40 - self.rootNode() self.state = 42 + self.rootNode() + self.state = 44 self._errHandler.sync(self) _la = self._input.LA(1) if _la==BTreeDSLParser.NL: - self.state = 41 + self.state = 43 self.match(BTreeDSLParser.NL) - self.state = 45 + self.state = 47 self._errHandler.sync(self) _la = self._input.LA(1) if _la==BTreeDSLParser.DEDENT: - self.state = 44 + self.state = 46 self.match(BTreeDSLParser.DEDENT) - self.state = 49 + self.state = 51 self._errHandler.sync(self) _la = self._input.LA(1) if not (_la==BTreeDSLParser.T__0): break - self.state = 51 + self.state = 53 self.match(BTreeDSLParser.EOF) except RecognitionException as re: localctx.exception = re @@ -287,7 +294,7 @@ def rootNode(self): self.enterRule(localctx, 2, self.RULE_rootNode) try: self.enterOuterAlt(localctx, 1) - self.state = 53 + self.state = 55 self.node() except RecognitionException as re: localctx.exception = re @@ -330,17 +337,17 @@ def node(self): localctx = BTreeDSLParser.NodeContext(self, self._ctx, self.state) self.enterRule(localctx, 4, self.RULE_node) try: - self.state = 57 + self.state = 59 self._errHandler.sync(self) token = self._input.LA(1) - if token in [BTreeDSLParser.T__2, BTreeDSLParser.T__5, BTreeDSLParser.T__6]: + if token in [BTreeDSLParser.T__2, BTreeDSLParser.T__6, BTreeDSLParser.T__7]: self.enterOuterAlt(localctx, 1) - self.state = 55 + self.state = 57 self.leafNode() pass elif token in [BTreeDSLParser.OPERATOR]: self.enterOuterAlt(localctx, 2) - self.state = 56 + self.state = 58 self.nodeComposition() pass else: @@ -397,23 +404,23 @@ def nodeComposition(self): self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 59 + self.state = 61 self.match(BTreeDSLParser.OPERATOR) - self.state = 60 + self.state = 62 self.match(BTreeDSLParser.INDENT) - self.state = 62 + self.state = 64 self._errHandler.sync(self) _la = self._input.LA(1) while True: - self.state = 61 + self.state = 63 self.node() - self.state = 64 + self.state = 66 self._errHandler.sync(self) _la = self._input.LA(1) - if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << BTreeDSLParser.T__2) | (1 << BTreeDSLParser.T__5) | (1 << BTreeDSLParser.T__6) | (1 << BTreeDSLParser.OPERATOR))) != 0)): + if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << BTreeDSLParser.T__2) | (1 << BTreeDSLParser.T__6) | (1 << BTreeDSLParser.T__7) | (1 << BTreeDSLParser.OPERATOR))) != 0)): break - self.state = 66 + self.state = 68 self.match(BTreeDSLParser.DEDENT) except RecognitionException as re: localctx.exception = re @@ -464,25 +471,25 @@ def leafNode(self): self.enterRule(localctx, 8, self.RULE_leafNode) try: self.enterOuterAlt(localctx, 1) - self.state = 71 + self.state = 73 self._errHandler.sync(self) token = self._input.LA(1) - if token in [BTreeDSLParser.T__5]: - self.state = 68 + if token in [BTreeDSLParser.T__6]: + self.state = 70 self.maneuver() pass elif token in [BTreeDSLParser.T__2]: - self.state = 69 + self.state = 71 self.condition() pass - elif token in [BTreeDSLParser.T__6]: - self.state = 70 + elif token in [BTreeDSLParser.T__7]: + self.state = 72 self.subtree() pass else: raise NoViableAltException(self) - self.state = 73 + self.state = 75 self.match(BTreeDSLParser.NL) except RecognitionException as re: localctx.exception = re @@ -506,6 +513,14 @@ def cconfig(self): return self.getTypedRuleContext(BTreeDSLParser.CconfigContext,0) + def error(self): + return self.getTypedRuleContext(BTreeDSLParser.ErrorContext,0) + + + def delay(self): + return self.getTypedRuleContext(BTreeDSLParser.DelayContext,0) + + def getRuleIndex(self): return BTreeDSLParser.RULE_condition @@ -524,18 +539,40 @@ def condition(self): localctx = BTreeDSLParser.ConditionContext(self, self._ctx, self.state) self.enterRule(localctx, 10, self.RULE_condition) + self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 75 + self.state = 77 self.match(BTreeDSLParser.T__2) - self.state = 76 + self.state = 78 self.name() - self.state = 77 + self.state = 79 self.match(BTreeDSLParser.T__3) - self.state = 78 + self.state = 80 self.cconfig() - self.state = 79 - self.match(BTreeDSLParser.T__4) + self.state = 83 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,6,self._ctx) + if la_ == 1: + self.state = 81 + self.match(BTreeDSLParser.T__4) + self.state = 82 + self.error() + + + self.state = 87 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==BTreeDSLParser.T__4: + self.state = 85 + self.match(BTreeDSLParser.T__4) + self.state = 86 + self.delay() + + + self.state = 89 + self.match(BTreeDSLParser.T__5) + except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -578,16 +615,16 @@ def maneuver(self): self.enterRule(localctx, 12, self.RULE_maneuver) try: self.enterOuterAlt(localctx, 1) - self.state = 81 - self.match(BTreeDSLParser.T__5) - self.state = 82 + self.state = 91 + self.match(BTreeDSLParser.T__6) + self.state = 92 self.name() - self.state = 83 + self.state = 93 self.match(BTreeDSLParser.T__3) - self.state = 84 + self.state = 94 self.mconfig() - self.state = 85 - self.match(BTreeDSLParser.T__4) + self.state = 95 + self.match(BTreeDSLParser.T__5) except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -634,34 +671,34 @@ def subtree(self): self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 87 - self.match(BTreeDSLParser.T__6) - self.state = 88 + self.state = 97 + self.match(BTreeDSLParser.T__7) + self.state = 98 self.name() - self.state = 89 + self.state = 99 self.match(BTreeDSLParser.T__3) - self.state = 98 + self.state = 108 self._errHandler.sync(self) _la = self._input.LA(1) if _la==BTreeDSLParser.WORD or _la==BTreeDSLParser.WS: - self.state = 90 + self.state = 100 self.midconf() - self.state = 95 + self.state = 105 self._errHandler.sync(self) _la = self._input.LA(1) - while _la==BTreeDSLParser.T__7: - self.state = 91 - self.match(BTreeDSLParser.T__7) - self.state = 92 + while _la==BTreeDSLParser.T__4: + self.state = 101 + self.match(BTreeDSLParser.T__4) + self.state = 102 self.midconf() - self.state = 97 + self.state = 107 self._errHandler.sync(self) _la = self._input.LA(1) - self.state = 100 - self.match(BTreeDSLParser.T__4) + self.state = 110 + self.match(BTreeDSLParser.T__5) except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -707,11 +744,11 @@ def midconf(self): self.enterRule(localctx, 16, self.RULE_midconf) try: self.enterOuterAlt(localctx, 1) - self.state = 102 + self.state = 112 self.mid() - self.state = 103 + self.state = 113 self.match(BTreeDSLParser.ATT) - self.state = 104 + self.state = 114 self.mconfig() except RecognitionException as re: localctx.exception = re @@ -721,6 +758,98 @@ def midconf(self): self.exitRule() return localctx + class ErrorContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def ATT(self): + return self.getToken(BTreeDSLParser.ATT, 0) + + def FLOAT(self): + return self.getToken(BTreeDSLParser.FLOAT, 0) + + def getRuleIndex(self): + return BTreeDSLParser.RULE_error + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterError" ): + listener.enterError(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitError" ): + listener.exitError(self) + + + + + def error(self): + + localctx = BTreeDSLParser.ErrorContext(self, self._ctx, self.state) + self.enterRule(localctx, 18, self.RULE_error) + try: + self.enterOuterAlt(localctx, 1) + self.state = 116 + self.match(BTreeDSLParser.T__8) + self.state = 117 + self.match(BTreeDSLParser.ATT) + self.state = 118 + self.match(BTreeDSLParser.FLOAT) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class DelayContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def ATT(self): + return self.getToken(BTreeDSLParser.ATT, 0) + + def FLOAT(self): + return self.getToken(BTreeDSLParser.FLOAT, 0) + + def getRuleIndex(self): + return BTreeDSLParser.RULE_delay + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterDelay" ): + listener.enterDelay(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitDelay" ): + listener.exitDelay(self) + + + + + def delay(self): + + localctx = BTreeDSLParser.DelayContext(self, self._ctx, self.state) + self.enterRule(localctx, 20, self.RULE_delay) + try: + self.enterOuterAlt(localctx, 1) + self.state = 120 + self.match(BTreeDSLParser.T__9) + self.state = 121 + self.match(BTreeDSLParser.ATT) + self.state = 122 + self.match(BTreeDSLParser.FLOAT) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + class MconfigContext(ParserRuleContext): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): @@ -755,26 +884,26 @@ def exitRule(self, listener:ParseTreeListener): def mconfig(self): localctx = BTreeDSLParser.MconfigContext(self, self._ctx, self.state) - self.enterRule(localctx, 18, self.RULE_mconfig) + self.enterRule(localctx, 22, self.RULE_mconfig) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 106 + self.state = 124 self.name() - self.state = 107 + self.state = 125 self.match(BTreeDSLParser.T__3) - self.state = 111 + self.state = 129 self._errHandler.sync(self) _la = self._input.LA(1) while _la==BTreeDSLParser.WORD or _la==BTreeDSLParser.WS: - self.state = 108 + self.state = 126 self.params() - self.state = 113 + self.state = 131 self._errHandler.sync(self) _la = self._input.LA(1) - self.state = 114 - self.match(BTreeDSLParser.T__4) + self.state = 132 + self.match(BTreeDSLParser.T__5) except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -817,26 +946,26 @@ def exitRule(self, listener:ParseTreeListener): def cconfig(self): localctx = BTreeDSLParser.CconfigContext(self, self._ctx, self.state) - self.enterRule(localctx, 20, self.RULE_cconfig) + self.enterRule(localctx, 24, self.RULE_cconfig) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 116 + self.state = 134 self.name() - self.state = 117 + self.state = 135 self.match(BTreeDSLParser.T__3) - self.state = 121 + self.state = 139 self._errHandler.sync(self) _la = self._input.LA(1) while _la==BTreeDSLParser.WORD or _la==BTreeDSLParser.WS: - self.state = 118 + self.state = 136 self.params() - self.state = 123 + self.state = 141 self._errHandler.sync(self) _la = self._input.LA(1) - self.state = 124 - self.match(BTreeDSLParser.T__4) + self.state = 142 + self.match(BTreeDSLParser.T__5) except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -872,10 +1001,10 @@ def exitRule(self, listener:ParseTreeListener): def mid(self): localctx = BTreeDSLParser.MidContext(self, self._ctx, self.state) - self.enterRule(localctx, 22, self.RULE_mid) + self.enterRule(localctx, 26, self.RULE_mid) try: self.enterOuterAlt(localctx, 1) - self.state = 126 + self.state = 144 self.name() except RecognitionException as re: localctx.exception = re @@ -915,21 +1044,21 @@ def exitRule(self, listener:ParseTreeListener): def params(self): localctx = BTreeDSLParser.ParamsContext(self, self._ctx, self.state) - self.enterRule(localctx, 24, self.RULE_params) + self.enterRule(localctx, 28, self.RULE_params) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 128 + self.state = 146 self.bexpr() - self.state = 133 + self.state = 151 self._errHandler.sync(self) _la = self._input.LA(1) - while _la==BTreeDSLParser.T__7: - self.state = 129 - self.match(BTreeDSLParser.T__7) - self.state = 130 + while _la==BTreeDSLParser.T__4: + self.state = 147 + self.match(BTreeDSLParser.T__4) + self.state = 148 self.bexpr() - self.state = 135 + self.state = 153 self._errHandler.sync(self) _la = self._input.LA(1) @@ -978,20 +1107,20 @@ def exitRule(self, listener:ParseTreeListener): def bexpr(self): localctx = BTreeDSLParser.BexprContext(self, self._ctx, self.state) - self.enterRule(localctx, 26, self.RULE_bexpr) + self.enterRule(localctx, 30, self.RULE_bexpr) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 136 + self.state = 154 self.name() - self.state = 137 + self.state = 155 _la = self._input.LA(1) if not(_la==BTreeDSLParser.BOP or _la==BTreeDSLParser.ATT): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) self.consume() - self.state = 138 + self.state = 156 self.value() except RecognitionException as re: localctx.exception = re @@ -1039,26 +1168,26 @@ def exitRule(self, listener:ParseTreeListener): def value(self): localctx = BTreeDSLParser.ValueContext(self, self._ctx, self.state) - self.enterRule(localctx, 28, self.RULE_value) + self.enterRule(localctx, 32, self.RULE_value) try: - self.state = 144 + self.state = 161 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,11,self._ctx) + la_ = self._interp.adaptivePredict(self._input,13,self._ctx) if la_ == 1: self.enterOuterAlt(localctx, 1) - self.state = 140 + self.state = 158 self.match(BTreeDSLParser.FLOAT) pass elif la_ == 2: self.enterOuterAlt(localctx, 2) - self.state = 141 + self.state = 159 self.name() pass elif la_ == 3: self.enterOuterAlt(localctx, 3) - self.state = 142 + self.state = 160 self.func() pass @@ -1110,89 +1239,30 @@ def exitRule(self, listener:ParseTreeListener): def func(self): localctx = BTreeDSLParser.FuncContext(self, self._ctx, self.state) - self.enterRule(localctx, 30, self.RULE_func) + self.enterRule(localctx, 34, self.RULE_func) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 146 + self.state = 163 self.name() - self.state = 147 - self.match(BTreeDSLParser.T__3) - self.state = 148 - self.match(BTreeDSLParser.FLOAT) - self.state = 153 - self._errHandler.sync(self) - _la = self._input.LA(1) - while _la==BTreeDSLParser.T__7: - self.state = 149 - self.match(BTreeDSLParser.T__7) - self.state = 150 - self.match(BTreeDSLParser.FLOAT) - self.state = 155 - self._errHandler.sync(self) - _la = self._input.LA(1) - - self.state = 156 - self.match(BTreeDSLParser.T__4) - except RecognitionException as re: - localctx.exception = re - self._errHandler.reportError(self, re) - self._errHandler.recover(self, re) - finally: - self.exitRule() - return localctx - - class TuplContext(ParserRuleContext): - - def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): - super().__init__(parent, invokingState) - self.parser = parser - - def FLOAT(self, i:int=None): - if i is None: - return self.getTokens(BTreeDSLParser.FLOAT) - else: - return self.getToken(BTreeDSLParser.FLOAT, i) - - def getRuleIndex(self): - return BTreeDSLParser.RULE_tupl - - def enterRule(self, listener:ParseTreeListener): - if hasattr( listener, "enterTupl" ): - listener.enterTupl(self) - - def exitRule(self, listener:ParseTreeListener): - if hasattr( listener, "exitTupl" ): - listener.exitTupl(self) - - - - - def tupl(self): - - localctx = BTreeDSLParser.TuplContext(self, self._ctx, self.state) - self.enterRule(localctx, 32, self.RULE_tupl) - self._la = 0 # Token type - try: - self.enterOuterAlt(localctx, 1) - self.state = 158 + self.state = 164 self.match(BTreeDSLParser.T__3) - self.state = 159 + self.state = 165 self.match(BTreeDSLParser.FLOAT) - self.state = 164 + self.state = 170 self._errHandler.sync(self) _la = self._input.LA(1) - while _la==BTreeDSLParser.T__7: - self.state = 160 - self.match(BTreeDSLParser.T__7) - self.state = 161 - self.match(BTreeDSLParser.FLOAT) + while _la==BTreeDSLParser.T__4: self.state = 166 + self.match(BTreeDSLParser.T__4) + self.state = 167 + self.match(BTreeDSLParser.FLOAT) + self.state = 172 self._errHandler.sync(self) _la = self._input.LA(1) - self.state = 167 - self.match(BTreeDSLParser.T__4) + self.state = 173 + self.match(BTreeDSLParser.T__5) except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -1233,32 +1303,32 @@ def exitRule(self, listener:ParseTreeListener): def name(self): localctx = BTreeDSLParser.NameContext(self, self._ctx, self.state) - self.enterRule(localctx, 34, self.RULE_name) + self.enterRule(localctx, 36, self.RULE_name) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 172 + self.state = 178 self._errHandler.sync(self) _la = self._input.LA(1) while _la==BTreeDSLParser.WS: - self.state = 169 + self.state = 175 self.match(BTreeDSLParser.WS) - self.state = 174 + self.state = 180 self._errHandler.sync(self) _la = self._input.LA(1) - self.state = 175 + self.state = 181 self.match(BTreeDSLParser.WORD) - self.state = 179 + self.state = 185 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,15,self._ctx) + _alt = self._interp.adaptivePredict(self._input,16,self._ctx) while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: if _alt==1: - self.state = 176 + self.state = 182 self.match(BTreeDSLParser.WS) - self.state = 181 + self.state = 187 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,15,self._ctx) + _alt = self._interp.adaptivePredict(self._input,16,self._ctx) except RecognitionException as re: localctx.exception = re diff --git a/test_btreeparser.py b/test_btreeparser.py index 6fc6906b..dbc09d20 100644 --- a/test_btreeparser.py +++ b/test_btreeparser.py @@ -10,23 +10,25 @@ def main(): path= "scenarios/trees/" - scenarios = ["drive_scenario_tree.btree", "fast_drive_scenario_tree.btree", "impatient_drive_scenario_tree.btree", "lane_change_scenario_tree.btree"] + scenarios = ["drive_tree.btree","drive_scenario_tree.btree", "fast_drive_scenario_tree.btree", "impatient_drive_scenario_tree.btree", "lane_change_scenario_tree.btree"] for scenario in scenarios: + print("***** Testing " + scenario + " *****") try: in_file = open(path+scenario, 'r') src = in_file.read() lexer = BTreeDSLLexer(InputStream(src)) parser = BTreeDSLParser(CommonTokenStream(lexer)) tree = parser.behaviorTree() - listener = BTreeParser.BTreeListener(vid=1,name="a") - ParseTreeWalker().walk(listener, tree) - tree = listener.getTreeStr() - print(tree) + #listener = BTreeParser(vid=1,bmodel=None) + #ParseTreeWalker().walk(listener, tree) + #tree = tree.getTreeStr() + #print(tree) except: raise RuntimeError("Failed at "+ scenario) finally: print("Scenario " + scenario + " passed!") + print("**************" + len(scenario)*"*" + "*****") return if __name__ == '__main__':