diff --git a/grammar/MetaPrompt.g4 b/grammar/MetaPrompt.g4 index 6694983..f85be81 100644 --- a/grammar/MetaPrompt.g4 +++ b/grammar/MetaPrompt.g4 @@ -2,11 +2,8 @@ grammar MetaPrompt; prompt: exprs EOF ; exprs: expr*? ; -exprs1: expr+? ; -expr: LB expr1 RB +expr: meta_body | text - | RB - | LB | COMMENT_KW | META_PROMPT | EQ_KW @@ -19,23 +16,18 @@ expr: LB expr1 RB | WITH_KW ; -expr1 - : meta_body - | exprs - ; - meta_body - : IF_KW exprs THEN_KW exprs ELSE_KW exprs - | IF_KW exprs THEN_KW exprs - | CHOOSE_KW exprs option+ default_option? - | USE named_parameters - | META_PROMPT exprs - | COMMENT_KW exprs - | var_assignment + : IF_KW exprs THEN_KW exprs ELSE_KW exprs RB + | IF_KW exprs THEN_KW exprs RB + | CHOOSE_KW exprs option+ default_option? RB + | USE named_parameters RB + | META_PROMPT exprs RB + | COMMENT_KW exprs RB + | LB var_assignment RB | var_optional_assignment - | VAR_NAME - | CALL call_arg1 call_arg* - | CALL call_arg* + | LB VAR_NAME RB + | CALL call_arg1 call_arg* RB + | CALL call_arg* RB ; var_assignment @@ -43,7 +35,7 @@ var_assignment ; var_optional_assignment - : VAR_NAME EQ_OPTIONAL_KW exprs + : LB VAR_NAME EQ_OPTIONAL_KW exprs RB ; call_arg1 @@ -74,17 +66,17 @@ LB : '['; RB : ']'; EQ_KW : '=' ; EQ_OPTIONAL_KW : '?=' ; -META_PROMPT : [a-zA-Z_]?[a-zA-Z0-9_]* '$' ; -COMMENT_KW : '#' ; +META_PROMPT : LB [a-zA-Z_]?[a-zA-Z0-9_]* '$' ; +COMMENT_KW : LB '#' ; CHAR : ( ESCAPED | .); fragment ESCAPED : ESCAPE ESCAPEE; -fragment ESCAPEE : (LB | ESCAPE); +fragment ESCAPEE : (LB | ESCAPE | RB); fragment ESCAPE : '\\'; -USE : ':use' WS+ [a-zA-Z0-9/_.-]+ WS*; -CALL : '@' [a-zA-Z_][a-zA-Z0-9_]* WS*; +USE : LB ':use' WS+ [a-zA-Z0-9/_.-]+ WS*; +CALL : LB '@' [a-zA-Z_][a-zA-Z0-9_]* WS*; fragment WS : ' '|'\n'; -IF_KW : ':if' ; -CHOOSE_KW : ':choose' ; +IF_KW : LB ':if' ; +CHOOSE_KW : LB ':choose' ; OPTION_KW : ':option' ; WITH_KW : ':with' ; DEFAULT_KW : ':default' ; diff --git a/python/src/parse_metaprompt.py b/python/src/parse_metaprompt.py index a4a102c..c3d29e2 100644 --- a/python/src/parse_metaprompt.py +++ b/python/src/parse_metaprompt.py @@ -18,21 +18,12 @@ def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e): raise Exception(f"Syntax error at line {line}:{column} - {msg}") -_pattern = r"\\([\[\\])(\[)?" +_pattern = r"\\([\[\\\]])" def _escape_pattern(match): first = match.group(1) - second = match.group(2) - if second is None: - if first == "\\": - return "\\\\" - elif first == "[": - return "[" - else: - raise ValueError("Invariant violation: _escape_pattern") - else: - return match.group(1) + return first def _process_escaping(string): @@ -52,35 +43,18 @@ def visitExprs(self, ctx: MetaPromptParser.ExprsContext): exprs = [] for expr in ctx.expr(): expr_items = self.visit(expr) - exprs.extend(expr_items) - return _process_expr_list(exprs) - - def visitExprs1(self, ctx: MetaPromptParser.Exprs1Context): - exprs = [] - for expr in ctx.expr(): - expr_items = self.visit(expr) - exprs.extend(expr_items) + exprs.append(expr_items) return _process_expr_list(exprs) def visitExpr(self, ctx: MetaPromptParser.ExprContext): - exprs = [] if ctx.text() is not None: - exprs.append(self.visit(ctx.text())) - if ctx.expr1() is not None: - expr1 = self.visit(ctx.expr1()) - if expr1["type"] == "meta": - exprs.append(expr1["meta"]) - elif expr1["type"] == "exprs": - exprs.append({"type": "text", "text": "["}) - for child in expr1["exprs"]: - exprs.append(child) - exprs.append({"type": "text", "text": "]"}) + return self.visit(ctx.text()) + if ctx.meta_body() is not None: + return self.visit(ctx.meta_body()) else: # a token is in a standalone position and should be # treaded as text for part in [ - ctx.RB(), - ctx.LB(), ctx.COMMENT_KW(), ctx.META_PROMPT(), ctx.EQ_KW(), @@ -93,15 +67,7 @@ def visitExpr(self, ctx: MetaPromptParser.ExprContext): ctx.WITH_KW(), ]: if part is not None: - exprs.append({"type": "text", "text": part.getText()}) - - return _process_expr_list(exprs) - - def visitExpr1(self, ctx: MetaPromptParser.Expr1Context): - if ctx.meta_body() is not None: - return {"type": "meta", "meta": self.visit(ctx.meta_body())} - else: - return {"type": "exprs", "exprs": self.visit(ctx.exprs())} + return {"type": "text", "text": part.getText()} def visitVar_optional_assignment( self, ctx: MetaPromptParser.Var_optional_assignmentContext @@ -193,7 +159,7 @@ def visitMeta_body(self, ctx: MetaPromptParser.Meta_bodyContext): } elif ctx.USE() is not None: - module_name = ctx.USE().getText().removeprefix(":use").strip() + module_name = ctx.USE().getText().removeprefix("[:use").strip() parameters = self.visit(ctx.named_parameters()) return { "type": "use", @@ -202,7 +168,7 @@ def visitMeta_body(self, ctx: MetaPromptParser.Meta_bodyContext): } elif ctx.CALL() is not None: - function_name = ctx.CALL().getText().removeprefix("@").strip() + function_name = ctx.CALL().getText().removeprefix("[@").strip() positional_args = [] named_args = {} @@ -260,7 +226,7 @@ def use_arg(arg): "type": "meta", "exprs": _process_expr_list(exprs), } - chat_id = ctx.META_PROMPT().getText()[:-1] + chat_id = ctx.META_PROMPT().getText()[1:-1] if chat_id != "": res["chat"] = chat_id return res diff --git a/python/src/parser/MetaPrompt.interp b/python/src/parser/MetaPrompt.interp index 08e3beb..fd1df1d 100644 --- a/python/src/parser/MetaPrompt.interp +++ b/python/src/parser/MetaPrompt.interp @@ -5,12 +5,12 @@ null '=' '?=' null -'#' null null null -':if' -':choose' +null +null +null ':option' ':with' ':default' @@ -43,9 +43,7 @@ VAR_NAME rule names: prompt exprs -exprs1 expr -expr1 meta_body var_assignment var_optional_assignment @@ -58,4 +56,4 @@ text atn: -[4, 1, 18, 150, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 1, 0, 1, 0, 1, 0, 1, 1, 5, 1, 33, 8, 1, 10, 1, 12, 1, 36, 9, 1, 1, 2, 4, 2, 39, 8, 2, 11, 2, 12, 2, 40, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 60, 8, 3, 1, 4, 1, 4, 3, 4, 64, 8, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 4, 5, 81, 8, 5, 11, 5, 12, 5, 82, 1, 5, 3, 5, 86, 8, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 5, 5, 100, 8, 5, 10, 5, 12, 5, 103, 9, 5, 1, 5, 1, 5, 5, 5, 107, 8, 5, 10, 5, 12, 5, 110, 9, 5, 3, 5, 112, 8, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 3, 8, 124, 8, 8, 1, 9, 1, 9, 1, 9, 3, 9, 129, 8, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 12, 5, 12, 140, 8, 12, 10, 12, 12, 12, 143, 9, 12, 1, 13, 4, 13, 146, 8, 13, 11, 13, 12, 13, 147, 1, 13, 2, 34, 40, 0, 14, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 0, 0, 169, 0, 28, 1, 0, 0, 0, 2, 34, 1, 0, 0, 0, 4, 38, 1, 0, 0, 0, 6, 59, 1, 0, 0, 0, 8, 63, 1, 0, 0, 0, 10, 111, 1, 0, 0, 0, 12, 113, 1, 0, 0, 0, 14, 117, 1, 0, 0, 0, 16, 123, 1, 0, 0, 0, 18, 128, 1, 0, 0, 0, 20, 130, 1, 0, 0, 0, 22, 135, 1, 0, 0, 0, 24, 141, 1, 0, 0, 0, 26, 145, 1, 0, 0, 0, 28, 29, 3, 2, 1, 0, 29, 30, 5, 0, 0, 1, 30, 1, 1, 0, 0, 0, 31, 33, 3, 6, 3, 0, 32, 31, 1, 0, 0, 0, 33, 36, 1, 0, 0, 0, 34, 35, 1, 0, 0, 0, 34, 32, 1, 0, 0, 0, 35, 3, 1, 0, 0, 0, 36, 34, 1, 0, 0, 0, 37, 39, 3, 6, 3, 0, 38, 37, 1, 0, 0, 0, 39, 40, 1, 0, 0, 0, 40, 41, 1, 0, 0, 0, 40, 38, 1, 0, 0, 0, 41, 5, 1, 0, 0, 0, 42, 43, 5, 1, 0, 0, 43, 44, 3, 8, 4, 0, 44, 45, 5, 2, 0, 0, 45, 60, 1, 0, 0, 0, 46, 60, 3, 26, 13, 0, 47, 60, 5, 2, 0, 0, 48, 60, 5, 1, 0, 0, 49, 60, 5, 6, 0, 0, 50, 60, 5, 5, 0, 0, 51, 60, 5, 3, 0, 0, 52, 60, 5, 18, 0, 0, 53, 60, 5, 11, 0, 0, 54, 60, 5, 12, 0, 0, 55, 60, 5, 14, 0, 0, 56, 60, 5, 15, 0, 0, 57, 60, 5, 9, 0, 0, 58, 60, 5, 13, 0, 0, 59, 42, 1, 0, 0, 0, 59, 46, 1, 0, 0, 0, 59, 47, 1, 0, 0, 0, 59, 48, 1, 0, 0, 0, 59, 49, 1, 0, 0, 0, 59, 50, 1, 0, 0, 0, 59, 51, 1, 0, 0, 0, 59, 52, 1, 0, 0, 0, 59, 53, 1, 0, 0, 0, 59, 54, 1, 0, 0, 0, 59, 55, 1, 0, 0, 0, 59, 56, 1, 0, 0, 0, 59, 57, 1, 0, 0, 0, 59, 58, 1, 0, 0, 0, 60, 7, 1, 0, 0, 0, 61, 64, 3, 10, 5, 0, 62, 64, 3, 2, 1, 0, 63, 61, 1, 0, 0, 0, 63, 62, 1, 0, 0, 0, 64, 9, 1, 0, 0, 0, 65, 66, 5, 10, 0, 0, 66, 67, 3, 2, 1, 0, 67, 68, 5, 16, 0, 0, 68, 69, 3, 2, 1, 0, 69, 70, 5, 17, 0, 0, 70, 71, 3, 2, 1, 0, 71, 112, 1, 0, 0, 0, 72, 73, 5, 10, 0, 0, 73, 74, 3, 2, 1, 0, 74, 75, 5, 16, 0, 0, 75, 76, 3, 2, 1, 0, 76, 112, 1, 0, 0, 0, 77, 78, 5, 11, 0, 0, 78, 80, 3, 2, 1, 0, 79, 81, 3, 20, 10, 0, 80, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 80, 1, 0, 0, 0, 82, 83, 1, 0, 0, 0, 83, 85, 1, 0, 0, 0, 84, 86, 3, 22, 11, 0, 85, 84, 1, 0, 0, 0, 85, 86, 1, 0, 0, 0, 86, 112, 1, 0, 0, 0, 87, 88, 5, 8, 0, 0, 88, 112, 3, 24, 12, 0, 89, 90, 5, 5, 0, 0, 90, 112, 3, 2, 1, 0, 91, 92, 5, 6, 0, 0, 92, 112, 3, 2, 1, 0, 93, 112, 3, 12, 6, 0, 94, 112, 3, 14, 7, 0, 95, 112, 5, 18, 0, 0, 96, 97, 5, 9, 0, 0, 97, 101, 3, 16, 8, 0, 98, 100, 3, 18, 9, 0, 99, 98, 1, 0, 0, 0, 100, 103, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 101, 102, 1, 0, 0, 0, 102, 112, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, 104, 108, 5, 9, 0, 0, 105, 107, 3, 18, 9, 0, 106, 105, 1, 0, 0, 0, 107, 110, 1, 0, 0, 0, 108, 106, 1, 0, 0, 0, 108, 109, 1, 0, 0, 0, 109, 112, 1, 0, 0, 0, 110, 108, 1, 0, 0, 0, 111, 65, 1, 0, 0, 0, 111, 72, 1, 0, 0, 0, 111, 77, 1, 0, 0, 0, 111, 87, 1, 0, 0, 0, 111, 89, 1, 0, 0, 0, 111, 91, 1, 0, 0, 0, 111, 93, 1, 0, 0, 0, 111, 94, 1, 0, 0, 0, 111, 95, 1, 0, 0, 0, 111, 96, 1, 0, 0, 0, 111, 104, 1, 0, 0, 0, 112, 11, 1, 0, 0, 0, 113, 114, 5, 18, 0, 0, 114, 115, 5, 3, 0, 0, 115, 116, 3, 2, 1, 0, 116, 13, 1, 0, 0, 0, 117, 118, 5, 18, 0, 0, 118, 119, 5, 4, 0, 0, 119, 120, 3, 2, 1, 0, 120, 15, 1, 0, 0, 0, 121, 124, 3, 12, 6, 0, 122, 124, 3, 2, 1, 0, 123, 121, 1, 0, 0, 0, 123, 122, 1, 0, 0, 0, 124, 17, 1, 0, 0, 0, 125, 129, 3, 12, 6, 0, 126, 127, 5, 13, 0, 0, 127, 129, 3, 2, 1, 0, 128, 125, 1, 0, 0, 0, 128, 126, 1, 0, 0, 0, 129, 19, 1, 0, 0, 0, 130, 131, 5, 12, 0, 0, 131, 132, 3, 2, 1, 0, 132, 133, 5, 15, 0, 0, 133, 134, 3, 2, 1, 0, 134, 21, 1, 0, 0, 0, 135, 136, 5, 14, 0, 0, 136, 137, 3, 2, 1, 0, 137, 23, 1, 0, 0, 0, 138, 140, 3, 12, 6, 0, 139, 138, 1, 0, 0, 0, 140, 143, 1, 0, 0, 0, 141, 139, 1, 0, 0, 0, 141, 142, 1, 0, 0, 0, 142, 25, 1, 0, 0, 0, 143, 141, 1, 0, 0, 0, 144, 146, 5, 7, 0, 0, 145, 144, 1, 0, 0, 0, 146, 147, 1, 0, 0, 0, 147, 145, 1, 0, 0, 0, 147, 148, 1, 0, 0, 0, 148, 27, 1, 0, 0, 0, 13, 34, 40, 59, 63, 82, 85, 101, 108, 111, 123, 128, 141, 147] \ No newline at end of file +[4, 1, 18, 152, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 1, 0, 1, 0, 1, 0, 1, 1, 5, 1, 29, 8, 1, 10, 1, 12, 1, 32, 9, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 46, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 4, 3, 65, 8, 3, 11, 3, 12, 3, 66, 1, 3, 3, 3, 70, 8, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 97, 8, 3, 10, 3, 12, 3, 100, 9, 3, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 106, 8, 3, 10, 3, 12, 3, 109, 9, 3, 1, 3, 3, 3, 112, 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 3, 6, 126, 8, 6, 1, 7, 1, 7, 1, 7, 3, 7, 131, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 10, 5, 10, 142, 8, 10, 10, 10, 12, 10, 145, 9, 10, 1, 11, 4, 11, 148, 8, 11, 11, 11, 12, 11, 149, 1, 11, 1, 30, 0, 12, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 0, 0, 169, 0, 24, 1, 0, 0, 0, 2, 30, 1, 0, 0, 0, 4, 45, 1, 0, 0, 0, 6, 111, 1, 0, 0, 0, 8, 113, 1, 0, 0, 0, 10, 117, 1, 0, 0, 0, 12, 125, 1, 0, 0, 0, 14, 130, 1, 0, 0, 0, 16, 132, 1, 0, 0, 0, 18, 137, 1, 0, 0, 0, 20, 143, 1, 0, 0, 0, 22, 147, 1, 0, 0, 0, 24, 25, 3, 2, 1, 0, 25, 26, 5, 0, 0, 1, 26, 1, 1, 0, 0, 0, 27, 29, 3, 4, 2, 0, 28, 27, 1, 0, 0, 0, 29, 32, 1, 0, 0, 0, 30, 31, 1, 0, 0, 0, 30, 28, 1, 0, 0, 0, 31, 3, 1, 0, 0, 0, 32, 30, 1, 0, 0, 0, 33, 46, 3, 6, 3, 0, 34, 46, 3, 22, 11, 0, 35, 46, 5, 6, 0, 0, 36, 46, 5, 5, 0, 0, 37, 46, 5, 3, 0, 0, 38, 46, 5, 18, 0, 0, 39, 46, 5, 11, 0, 0, 40, 46, 5, 12, 0, 0, 41, 46, 5, 14, 0, 0, 42, 46, 5, 15, 0, 0, 43, 46, 5, 9, 0, 0, 44, 46, 5, 13, 0, 0, 45, 33, 1, 0, 0, 0, 45, 34, 1, 0, 0, 0, 45, 35, 1, 0, 0, 0, 45, 36, 1, 0, 0, 0, 45, 37, 1, 0, 0, 0, 45, 38, 1, 0, 0, 0, 45, 39, 1, 0, 0, 0, 45, 40, 1, 0, 0, 0, 45, 41, 1, 0, 0, 0, 45, 42, 1, 0, 0, 0, 45, 43, 1, 0, 0, 0, 45, 44, 1, 0, 0, 0, 46, 5, 1, 0, 0, 0, 47, 48, 5, 10, 0, 0, 48, 49, 3, 2, 1, 0, 49, 50, 5, 16, 0, 0, 50, 51, 3, 2, 1, 0, 51, 52, 5, 17, 0, 0, 52, 53, 3, 2, 1, 0, 53, 54, 5, 2, 0, 0, 54, 112, 1, 0, 0, 0, 55, 56, 5, 10, 0, 0, 56, 57, 3, 2, 1, 0, 57, 58, 5, 16, 0, 0, 58, 59, 3, 2, 1, 0, 59, 60, 5, 2, 0, 0, 60, 112, 1, 0, 0, 0, 61, 62, 5, 11, 0, 0, 62, 64, 3, 2, 1, 0, 63, 65, 3, 16, 8, 0, 64, 63, 1, 0, 0, 0, 65, 66, 1, 0, 0, 0, 66, 64, 1, 0, 0, 0, 66, 67, 1, 0, 0, 0, 67, 69, 1, 0, 0, 0, 68, 70, 3, 18, 9, 0, 69, 68, 1, 0, 0, 0, 69, 70, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 72, 5, 2, 0, 0, 72, 112, 1, 0, 0, 0, 73, 74, 5, 8, 0, 0, 74, 75, 3, 20, 10, 0, 75, 76, 5, 2, 0, 0, 76, 112, 1, 0, 0, 0, 77, 78, 5, 5, 0, 0, 78, 79, 3, 2, 1, 0, 79, 80, 5, 2, 0, 0, 80, 112, 1, 0, 0, 0, 81, 82, 5, 6, 0, 0, 82, 83, 3, 2, 1, 0, 83, 84, 5, 2, 0, 0, 84, 112, 1, 0, 0, 0, 85, 86, 5, 1, 0, 0, 86, 87, 3, 8, 4, 0, 87, 88, 5, 2, 0, 0, 88, 112, 1, 0, 0, 0, 89, 112, 3, 10, 5, 0, 90, 91, 5, 1, 0, 0, 91, 92, 5, 18, 0, 0, 92, 112, 5, 2, 0, 0, 93, 94, 5, 9, 0, 0, 94, 98, 3, 12, 6, 0, 95, 97, 3, 14, 7, 0, 96, 95, 1, 0, 0, 0, 97, 100, 1, 0, 0, 0, 98, 96, 1, 0, 0, 0, 98, 99, 1, 0, 0, 0, 99, 101, 1, 0, 0, 0, 100, 98, 1, 0, 0, 0, 101, 102, 5, 2, 0, 0, 102, 112, 1, 0, 0, 0, 103, 107, 5, 9, 0, 0, 104, 106, 3, 14, 7, 0, 105, 104, 1, 0, 0, 0, 106, 109, 1, 0, 0, 0, 107, 105, 1, 0, 0, 0, 107, 108, 1, 0, 0, 0, 108, 110, 1, 0, 0, 0, 109, 107, 1, 0, 0, 0, 110, 112, 5, 2, 0, 0, 111, 47, 1, 0, 0, 0, 111, 55, 1, 0, 0, 0, 111, 61, 1, 0, 0, 0, 111, 73, 1, 0, 0, 0, 111, 77, 1, 0, 0, 0, 111, 81, 1, 0, 0, 0, 111, 85, 1, 0, 0, 0, 111, 89, 1, 0, 0, 0, 111, 90, 1, 0, 0, 0, 111, 93, 1, 0, 0, 0, 111, 103, 1, 0, 0, 0, 112, 7, 1, 0, 0, 0, 113, 114, 5, 18, 0, 0, 114, 115, 5, 3, 0, 0, 115, 116, 3, 2, 1, 0, 116, 9, 1, 0, 0, 0, 117, 118, 5, 1, 0, 0, 118, 119, 5, 18, 0, 0, 119, 120, 5, 4, 0, 0, 120, 121, 3, 2, 1, 0, 121, 122, 5, 2, 0, 0, 122, 11, 1, 0, 0, 0, 123, 126, 3, 8, 4, 0, 124, 126, 3, 2, 1, 0, 125, 123, 1, 0, 0, 0, 125, 124, 1, 0, 0, 0, 126, 13, 1, 0, 0, 0, 127, 131, 3, 8, 4, 0, 128, 129, 5, 13, 0, 0, 129, 131, 3, 2, 1, 0, 130, 127, 1, 0, 0, 0, 130, 128, 1, 0, 0, 0, 131, 15, 1, 0, 0, 0, 132, 133, 5, 12, 0, 0, 133, 134, 3, 2, 1, 0, 134, 135, 5, 15, 0, 0, 135, 136, 3, 2, 1, 0, 136, 17, 1, 0, 0, 0, 137, 138, 5, 14, 0, 0, 138, 139, 3, 2, 1, 0, 139, 19, 1, 0, 0, 0, 140, 142, 3, 8, 4, 0, 141, 140, 1, 0, 0, 0, 142, 145, 1, 0, 0, 0, 143, 141, 1, 0, 0, 0, 143, 144, 1, 0, 0, 0, 144, 21, 1, 0, 0, 0, 145, 143, 1, 0, 0, 0, 146, 148, 5, 7, 0, 0, 147, 146, 1, 0, 0, 0, 148, 149, 1, 0, 0, 0, 149, 147, 1, 0, 0, 0, 149, 150, 1, 0, 0, 0, 150, 23, 1, 0, 0, 0, 11, 30, 45, 66, 69, 98, 107, 111, 125, 130, 143, 149] \ No newline at end of file diff --git a/python/src/parser/MetaPrompt.tokens b/python/src/parser/MetaPrompt.tokens index 8e644ab..b738699 100644 --- a/python/src/parser/MetaPrompt.tokens +++ b/python/src/parser/MetaPrompt.tokens @@ -20,9 +20,6 @@ VAR_NAME=18 ']'=2 '='=3 '?='=4 -'#'=6 -':if'=10 -':choose'=11 ':option'=12 ':with'=13 ':default'=14 diff --git a/python/src/parser/MetaPromptLexer.interp b/python/src/parser/MetaPromptLexer.interp index 4e87365..eecaf35 100644 --- a/python/src/parser/MetaPromptLexer.interp +++ b/python/src/parser/MetaPromptLexer.interp @@ -5,12 +5,12 @@ null '=' '?=' null -'#' null null null -':if' -':choose' +null +null +null ':option' ':with' ':default' @@ -72,4 +72,4 @@ mode names: DEFAULT_MODE atn: -[4, 0, 18, 176, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 4, 3, 4, 56, 8, 4, 1, 4, 5, 4, 59, 8, 4, 10, 4, 12, 4, 62, 9, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 3, 6, 70, 8, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 3, 8, 77, 8, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 4, 10, 87, 8, 10, 11, 10, 12, 10, 88, 1, 10, 4, 10, 92, 8, 10, 11, 10, 12, 10, 93, 1, 10, 5, 10, 97, 8, 10, 10, 10, 12, 10, 100, 9, 10, 1, 11, 1, 11, 1, 11, 5, 11, 105, 8, 11, 10, 11, 12, 11, 108, 9, 11, 1, 11, 5, 11, 111, 8, 11, 10, 11, 12, 11, 114, 9, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 5, 21, 172, 8, 21, 10, 21, 12, 21, 175, 9, 21, 0, 0, 22, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 0, 17, 0, 19, 0, 21, 8, 23, 9, 25, 0, 27, 10, 29, 11, 31, 12, 33, 13, 35, 14, 37, 15, 39, 16, 41, 17, 43, 18, 1, 0, 4, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 4, 0, 45, 57, 65, 90, 95, 95, 97, 122, 2, 0, 10, 10, 32, 32, 181, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 1, 45, 1, 0, 0, 0, 3, 47, 1, 0, 0, 0, 5, 49, 1, 0, 0, 0, 7, 51, 1, 0, 0, 0, 9, 55, 1, 0, 0, 0, 11, 65, 1, 0, 0, 0, 13, 69, 1, 0, 0, 0, 15, 71, 1, 0, 0, 0, 17, 76, 1, 0, 0, 0, 19, 78, 1, 0, 0, 0, 21, 80, 1, 0, 0, 0, 23, 101, 1, 0, 0, 0, 25, 115, 1, 0, 0, 0, 27, 117, 1, 0, 0, 0, 29, 121, 1, 0, 0, 0, 31, 129, 1, 0, 0, 0, 33, 137, 1, 0, 0, 0, 35, 143, 1, 0, 0, 0, 37, 152, 1, 0, 0, 0, 39, 156, 1, 0, 0, 0, 41, 162, 1, 0, 0, 0, 43, 168, 1, 0, 0, 0, 45, 46, 5, 91, 0, 0, 46, 2, 1, 0, 0, 0, 47, 48, 5, 93, 0, 0, 48, 4, 1, 0, 0, 0, 49, 50, 5, 61, 0, 0, 50, 6, 1, 0, 0, 0, 51, 52, 5, 63, 0, 0, 52, 53, 5, 61, 0, 0, 53, 8, 1, 0, 0, 0, 54, 56, 7, 0, 0, 0, 55, 54, 1, 0, 0, 0, 55, 56, 1, 0, 0, 0, 56, 60, 1, 0, 0, 0, 57, 59, 7, 1, 0, 0, 58, 57, 1, 0, 0, 0, 59, 62, 1, 0, 0, 0, 60, 58, 1, 0, 0, 0, 60, 61, 1, 0, 0, 0, 61, 63, 1, 0, 0, 0, 62, 60, 1, 0, 0, 0, 63, 64, 5, 36, 0, 0, 64, 10, 1, 0, 0, 0, 65, 66, 5, 35, 0, 0, 66, 12, 1, 0, 0, 0, 67, 70, 3, 15, 7, 0, 68, 70, 9, 0, 0, 0, 69, 67, 1, 0, 0, 0, 69, 68, 1, 0, 0, 0, 70, 14, 1, 0, 0, 0, 71, 72, 3, 19, 9, 0, 72, 73, 3, 17, 8, 0, 73, 16, 1, 0, 0, 0, 74, 77, 3, 1, 0, 0, 75, 77, 3, 19, 9, 0, 76, 74, 1, 0, 0, 0, 76, 75, 1, 0, 0, 0, 77, 18, 1, 0, 0, 0, 78, 79, 5, 92, 0, 0, 79, 20, 1, 0, 0, 0, 80, 81, 5, 58, 0, 0, 81, 82, 5, 117, 0, 0, 82, 83, 5, 115, 0, 0, 83, 84, 5, 101, 0, 0, 84, 86, 1, 0, 0, 0, 85, 87, 3, 25, 12, 0, 86, 85, 1, 0, 0, 0, 87, 88, 1, 0, 0, 0, 88, 86, 1, 0, 0, 0, 88, 89, 1, 0, 0, 0, 89, 91, 1, 0, 0, 0, 90, 92, 7, 2, 0, 0, 91, 90, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 91, 1, 0, 0, 0, 93, 94, 1, 0, 0, 0, 94, 98, 1, 0, 0, 0, 95, 97, 3, 25, 12, 0, 96, 95, 1, 0, 0, 0, 97, 100, 1, 0, 0, 0, 98, 96, 1, 0, 0, 0, 98, 99, 1, 0, 0, 0, 99, 22, 1, 0, 0, 0, 100, 98, 1, 0, 0, 0, 101, 102, 5, 64, 0, 0, 102, 106, 7, 0, 0, 0, 103, 105, 7, 1, 0, 0, 104, 103, 1, 0, 0, 0, 105, 108, 1, 0, 0, 0, 106, 104, 1, 0, 0, 0, 106, 107, 1, 0, 0, 0, 107, 112, 1, 0, 0, 0, 108, 106, 1, 0, 0, 0, 109, 111, 3, 25, 12, 0, 110, 109, 1, 0, 0, 0, 111, 114, 1, 0, 0, 0, 112, 110, 1, 0, 0, 0, 112, 113, 1, 0, 0, 0, 113, 24, 1, 0, 0, 0, 114, 112, 1, 0, 0, 0, 115, 116, 7, 3, 0, 0, 116, 26, 1, 0, 0, 0, 117, 118, 5, 58, 0, 0, 118, 119, 5, 105, 0, 0, 119, 120, 5, 102, 0, 0, 120, 28, 1, 0, 0, 0, 121, 122, 5, 58, 0, 0, 122, 123, 5, 99, 0, 0, 123, 124, 5, 104, 0, 0, 124, 125, 5, 111, 0, 0, 125, 126, 5, 111, 0, 0, 126, 127, 5, 115, 0, 0, 127, 128, 5, 101, 0, 0, 128, 30, 1, 0, 0, 0, 129, 130, 5, 58, 0, 0, 130, 131, 5, 111, 0, 0, 131, 132, 5, 112, 0, 0, 132, 133, 5, 116, 0, 0, 133, 134, 5, 105, 0, 0, 134, 135, 5, 111, 0, 0, 135, 136, 5, 110, 0, 0, 136, 32, 1, 0, 0, 0, 137, 138, 5, 58, 0, 0, 138, 139, 5, 119, 0, 0, 139, 140, 5, 105, 0, 0, 140, 141, 5, 116, 0, 0, 141, 142, 5, 104, 0, 0, 142, 34, 1, 0, 0, 0, 143, 144, 5, 58, 0, 0, 144, 145, 5, 100, 0, 0, 145, 146, 5, 101, 0, 0, 146, 147, 5, 102, 0, 0, 147, 148, 5, 97, 0, 0, 148, 149, 5, 117, 0, 0, 149, 150, 5, 108, 0, 0, 150, 151, 5, 116, 0, 0, 151, 36, 1, 0, 0, 0, 152, 153, 5, 58, 0, 0, 153, 154, 5, 105, 0, 0, 154, 155, 5, 115, 0, 0, 155, 38, 1, 0, 0, 0, 156, 157, 5, 58, 0, 0, 157, 158, 5, 116, 0, 0, 158, 159, 5, 104, 0, 0, 159, 160, 5, 101, 0, 0, 160, 161, 5, 110, 0, 0, 161, 40, 1, 0, 0, 0, 162, 163, 5, 58, 0, 0, 163, 164, 5, 101, 0, 0, 164, 165, 5, 108, 0, 0, 165, 166, 5, 115, 0, 0, 166, 167, 5, 101, 0, 0, 167, 42, 1, 0, 0, 0, 168, 169, 5, 58, 0, 0, 169, 173, 7, 0, 0, 0, 170, 172, 7, 1, 0, 0, 171, 170, 1, 0, 0, 0, 172, 175, 1, 0, 0, 0, 173, 171, 1, 0, 0, 0, 173, 174, 1, 0, 0, 0, 174, 44, 1, 0, 0, 0, 175, 173, 1, 0, 0, 0, 11, 0, 55, 60, 69, 76, 88, 93, 98, 106, 112, 173, 0] \ No newline at end of file +[4, 0, 18, 183, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 3, 4, 57, 8, 4, 1, 4, 5, 4, 60, 8, 4, 10, 4, 12, 4, 63, 9, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 3, 6, 72, 8, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 3, 8, 80, 8, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 4, 10, 91, 8, 10, 11, 10, 12, 10, 92, 1, 10, 4, 10, 96, 8, 10, 11, 10, 12, 10, 97, 1, 10, 5, 10, 101, 8, 10, 10, 10, 12, 10, 104, 9, 10, 1, 11, 1, 11, 1, 11, 1, 11, 5, 11, 110, 8, 11, 10, 11, 12, 11, 113, 9, 11, 1, 11, 5, 11, 116, 8, 11, 10, 11, 12, 11, 119, 9, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 5, 21, 179, 8, 21, 10, 21, 12, 21, 182, 9, 21, 0, 0, 22, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 0, 17, 0, 19, 0, 21, 8, 23, 9, 25, 0, 27, 10, 29, 11, 31, 12, 33, 13, 35, 14, 37, 15, 39, 16, 41, 17, 43, 18, 1, 0, 4, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 4, 0, 45, 57, 65, 90, 95, 95, 97, 122, 2, 0, 10, 10, 32, 32, 189, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 1, 45, 1, 0, 0, 0, 3, 47, 1, 0, 0, 0, 5, 49, 1, 0, 0, 0, 7, 51, 1, 0, 0, 0, 9, 54, 1, 0, 0, 0, 11, 66, 1, 0, 0, 0, 13, 71, 1, 0, 0, 0, 15, 73, 1, 0, 0, 0, 17, 79, 1, 0, 0, 0, 19, 81, 1, 0, 0, 0, 21, 83, 1, 0, 0, 0, 23, 105, 1, 0, 0, 0, 25, 120, 1, 0, 0, 0, 27, 122, 1, 0, 0, 0, 29, 127, 1, 0, 0, 0, 31, 136, 1, 0, 0, 0, 33, 144, 1, 0, 0, 0, 35, 150, 1, 0, 0, 0, 37, 159, 1, 0, 0, 0, 39, 163, 1, 0, 0, 0, 41, 169, 1, 0, 0, 0, 43, 175, 1, 0, 0, 0, 45, 46, 5, 91, 0, 0, 46, 2, 1, 0, 0, 0, 47, 48, 5, 93, 0, 0, 48, 4, 1, 0, 0, 0, 49, 50, 5, 61, 0, 0, 50, 6, 1, 0, 0, 0, 51, 52, 5, 63, 0, 0, 52, 53, 5, 61, 0, 0, 53, 8, 1, 0, 0, 0, 54, 56, 3, 1, 0, 0, 55, 57, 7, 0, 0, 0, 56, 55, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 61, 1, 0, 0, 0, 58, 60, 7, 1, 0, 0, 59, 58, 1, 0, 0, 0, 60, 63, 1, 0, 0, 0, 61, 59, 1, 0, 0, 0, 61, 62, 1, 0, 0, 0, 62, 64, 1, 0, 0, 0, 63, 61, 1, 0, 0, 0, 64, 65, 5, 36, 0, 0, 65, 10, 1, 0, 0, 0, 66, 67, 3, 1, 0, 0, 67, 68, 5, 35, 0, 0, 68, 12, 1, 0, 0, 0, 69, 72, 3, 15, 7, 0, 70, 72, 9, 0, 0, 0, 71, 69, 1, 0, 0, 0, 71, 70, 1, 0, 0, 0, 72, 14, 1, 0, 0, 0, 73, 74, 3, 19, 9, 0, 74, 75, 3, 17, 8, 0, 75, 16, 1, 0, 0, 0, 76, 80, 3, 1, 0, 0, 77, 80, 3, 19, 9, 0, 78, 80, 3, 3, 1, 0, 79, 76, 1, 0, 0, 0, 79, 77, 1, 0, 0, 0, 79, 78, 1, 0, 0, 0, 80, 18, 1, 0, 0, 0, 81, 82, 5, 92, 0, 0, 82, 20, 1, 0, 0, 0, 83, 84, 3, 1, 0, 0, 84, 85, 5, 58, 0, 0, 85, 86, 5, 117, 0, 0, 86, 87, 5, 115, 0, 0, 87, 88, 5, 101, 0, 0, 88, 90, 1, 0, 0, 0, 89, 91, 3, 25, 12, 0, 90, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 90, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 95, 1, 0, 0, 0, 94, 96, 7, 2, 0, 0, 95, 94, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 102, 1, 0, 0, 0, 99, 101, 3, 25, 12, 0, 100, 99, 1, 0, 0, 0, 101, 104, 1, 0, 0, 0, 102, 100, 1, 0, 0, 0, 102, 103, 1, 0, 0, 0, 103, 22, 1, 0, 0, 0, 104, 102, 1, 0, 0, 0, 105, 106, 3, 1, 0, 0, 106, 107, 5, 64, 0, 0, 107, 111, 7, 0, 0, 0, 108, 110, 7, 1, 0, 0, 109, 108, 1, 0, 0, 0, 110, 113, 1, 0, 0, 0, 111, 109, 1, 0, 0, 0, 111, 112, 1, 0, 0, 0, 112, 117, 1, 0, 0, 0, 113, 111, 1, 0, 0, 0, 114, 116, 3, 25, 12, 0, 115, 114, 1, 0, 0, 0, 116, 119, 1, 0, 0, 0, 117, 115, 1, 0, 0, 0, 117, 118, 1, 0, 0, 0, 118, 24, 1, 0, 0, 0, 119, 117, 1, 0, 0, 0, 120, 121, 7, 3, 0, 0, 121, 26, 1, 0, 0, 0, 122, 123, 3, 1, 0, 0, 123, 124, 5, 58, 0, 0, 124, 125, 5, 105, 0, 0, 125, 126, 5, 102, 0, 0, 126, 28, 1, 0, 0, 0, 127, 128, 3, 1, 0, 0, 128, 129, 5, 58, 0, 0, 129, 130, 5, 99, 0, 0, 130, 131, 5, 104, 0, 0, 131, 132, 5, 111, 0, 0, 132, 133, 5, 111, 0, 0, 133, 134, 5, 115, 0, 0, 134, 135, 5, 101, 0, 0, 135, 30, 1, 0, 0, 0, 136, 137, 5, 58, 0, 0, 137, 138, 5, 111, 0, 0, 138, 139, 5, 112, 0, 0, 139, 140, 5, 116, 0, 0, 140, 141, 5, 105, 0, 0, 141, 142, 5, 111, 0, 0, 142, 143, 5, 110, 0, 0, 143, 32, 1, 0, 0, 0, 144, 145, 5, 58, 0, 0, 145, 146, 5, 119, 0, 0, 146, 147, 5, 105, 0, 0, 147, 148, 5, 116, 0, 0, 148, 149, 5, 104, 0, 0, 149, 34, 1, 0, 0, 0, 150, 151, 5, 58, 0, 0, 151, 152, 5, 100, 0, 0, 152, 153, 5, 101, 0, 0, 153, 154, 5, 102, 0, 0, 154, 155, 5, 97, 0, 0, 155, 156, 5, 117, 0, 0, 156, 157, 5, 108, 0, 0, 157, 158, 5, 116, 0, 0, 158, 36, 1, 0, 0, 0, 159, 160, 5, 58, 0, 0, 160, 161, 5, 105, 0, 0, 161, 162, 5, 115, 0, 0, 162, 38, 1, 0, 0, 0, 163, 164, 5, 58, 0, 0, 164, 165, 5, 116, 0, 0, 165, 166, 5, 104, 0, 0, 166, 167, 5, 101, 0, 0, 167, 168, 5, 110, 0, 0, 168, 40, 1, 0, 0, 0, 169, 170, 5, 58, 0, 0, 170, 171, 5, 101, 0, 0, 171, 172, 5, 108, 0, 0, 172, 173, 5, 115, 0, 0, 173, 174, 5, 101, 0, 0, 174, 42, 1, 0, 0, 0, 175, 176, 5, 58, 0, 0, 176, 180, 7, 0, 0, 0, 177, 179, 7, 1, 0, 0, 178, 177, 1, 0, 0, 0, 179, 182, 1, 0, 0, 0, 180, 178, 1, 0, 0, 0, 180, 181, 1, 0, 0, 0, 181, 44, 1, 0, 0, 0, 182, 180, 1, 0, 0, 0, 11, 0, 56, 61, 71, 79, 92, 97, 102, 111, 117, 180, 0] \ No newline at end of file diff --git a/python/src/parser/MetaPromptLexer.py b/python/src/parser/MetaPromptLexer.py index 35069a3..fedb671 100644 --- a/python/src/parser/MetaPromptLexer.py +++ b/python/src/parser/MetaPromptLexer.py @@ -10,67 +10,70 @@ def serializedATN(): return [ - 4,0,18,176,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5, + 4,0,18,183,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5, 2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2, 13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7, - 19,2,20,7,20,2,21,7,21,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,3,1,4,3, - 4,56,8,4,1,4,5,4,59,8,4,10,4,12,4,62,9,4,1,4,1,4,1,5,1,5,1,6,1,6, - 3,6,70,8,6,1,7,1,7,1,7,1,8,1,8,3,8,77,8,8,1,9,1,9,1,10,1,10,1,10, - 1,10,1,10,1,10,4,10,87,8,10,11,10,12,10,88,1,10,4,10,92,8,10,11, - 10,12,10,93,1,10,5,10,97,8,10,10,10,12,10,100,9,10,1,11,1,11,1,11, - 5,11,105,8,11,10,11,12,11,108,9,11,1,11,5,11,111,8,11,10,11,12,11, - 114,9,11,1,12,1,12,1,13,1,13,1,13,1,13,1,14,1,14,1,14,1,14,1,14, - 1,14,1,14,1,14,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,16,1,16, - 1,16,1,16,1,16,1,16,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17, - 1,18,1,18,1,18,1,18,1,19,1,19,1,19,1,19,1,19,1,19,1,20,1,20,1,20, - 1,20,1,20,1,20,1,21,1,21,1,21,5,21,172,8,21,10,21,12,21,175,9,21, - 0,0,22,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,0,17,0,19,0,21,8,23,9,25, - 0,27,10,29,11,31,12,33,13,35,14,37,15,39,16,41,17,43,18,1,0,4,3, - 0,65,90,95,95,97,122,4,0,48,57,65,90,95,95,97,122,4,0,45,57,65,90, - 95,95,97,122,2,0,10,10,32,32,181,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0, - 0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,21,1,0,0, - 0,0,23,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0, - 0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0, - 0,1,45,1,0,0,0,3,47,1,0,0,0,5,49,1,0,0,0,7,51,1,0,0,0,9,55,1,0,0, - 0,11,65,1,0,0,0,13,69,1,0,0,0,15,71,1,0,0,0,17,76,1,0,0,0,19,78, - 1,0,0,0,21,80,1,0,0,0,23,101,1,0,0,0,25,115,1,0,0,0,27,117,1,0,0, - 0,29,121,1,0,0,0,31,129,1,0,0,0,33,137,1,0,0,0,35,143,1,0,0,0,37, - 152,1,0,0,0,39,156,1,0,0,0,41,162,1,0,0,0,43,168,1,0,0,0,45,46,5, - 91,0,0,46,2,1,0,0,0,47,48,5,93,0,0,48,4,1,0,0,0,49,50,5,61,0,0,50, - 6,1,0,0,0,51,52,5,63,0,0,52,53,5,61,0,0,53,8,1,0,0,0,54,56,7,0,0, - 0,55,54,1,0,0,0,55,56,1,0,0,0,56,60,1,0,0,0,57,59,7,1,0,0,58,57, - 1,0,0,0,59,62,1,0,0,0,60,58,1,0,0,0,60,61,1,0,0,0,61,63,1,0,0,0, - 62,60,1,0,0,0,63,64,5,36,0,0,64,10,1,0,0,0,65,66,5,35,0,0,66,12, - 1,0,0,0,67,70,3,15,7,0,68,70,9,0,0,0,69,67,1,0,0,0,69,68,1,0,0,0, - 70,14,1,0,0,0,71,72,3,19,9,0,72,73,3,17,8,0,73,16,1,0,0,0,74,77, - 3,1,0,0,75,77,3,19,9,0,76,74,1,0,0,0,76,75,1,0,0,0,77,18,1,0,0,0, - 78,79,5,92,0,0,79,20,1,0,0,0,80,81,5,58,0,0,81,82,5,117,0,0,82,83, - 5,115,0,0,83,84,5,101,0,0,84,86,1,0,0,0,85,87,3,25,12,0,86,85,1, - 0,0,0,87,88,1,0,0,0,88,86,1,0,0,0,88,89,1,0,0,0,89,91,1,0,0,0,90, - 92,7,2,0,0,91,90,1,0,0,0,92,93,1,0,0,0,93,91,1,0,0,0,93,94,1,0,0, - 0,94,98,1,0,0,0,95,97,3,25,12,0,96,95,1,0,0,0,97,100,1,0,0,0,98, - 96,1,0,0,0,98,99,1,0,0,0,99,22,1,0,0,0,100,98,1,0,0,0,101,102,5, - 64,0,0,102,106,7,0,0,0,103,105,7,1,0,0,104,103,1,0,0,0,105,108,1, - 0,0,0,106,104,1,0,0,0,106,107,1,0,0,0,107,112,1,0,0,0,108,106,1, - 0,0,0,109,111,3,25,12,0,110,109,1,0,0,0,111,114,1,0,0,0,112,110, - 1,0,0,0,112,113,1,0,0,0,113,24,1,0,0,0,114,112,1,0,0,0,115,116,7, - 3,0,0,116,26,1,0,0,0,117,118,5,58,0,0,118,119,5,105,0,0,119,120, - 5,102,0,0,120,28,1,0,0,0,121,122,5,58,0,0,122,123,5,99,0,0,123,124, - 5,104,0,0,124,125,5,111,0,0,125,126,5,111,0,0,126,127,5,115,0,0, - 127,128,5,101,0,0,128,30,1,0,0,0,129,130,5,58,0,0,130,131,5,111, - 0,0,131,132,5,112,0,0,132,133,5,116,0,0,133,134,5,105,0,0,134,135, - 5,111,0,0,135,136,5,110,0,0,136,32,1,0,0,0,137,138,5,58,0,0,138, - 139,5,119,0,0,139,140,5,105,0,0,140,141,5,116,0,0,141,142,5,104, - 0,0,142,34,1,0,0,0,143,144,5,58,0,0,144,145,5,100,0,0,145,146,5, - 101,0,0,146,147,5,102,0,0,147,148,5,97,0,0,148,149,5,117,0,0,149, - 150,5,108,0,0,150,151,5,116,0,0,151,36,1,0,0,0,152,153,5,58,0,0, - 153,154,5,105,0,0,154,155,5,115,0,0,155,38,1,0,0,0,156,157,5,58, - 0,0,157,158,5,116,0,0,158,159,5,104,0,0,159,160,5,101,0,0,160,161, - 5,110,0,0,161,40,1,0,0,0,162,163,5,58,0,0,163,164,5,101,0,0,164, - 165,5,108,0,0,165,166,5,115,0,0,166,167,5,101,0,0,167,42,1,0,0,0, - 168,169,5,58,0,0,169,173,7,0,0,0,170,172,7,1,0,0,171,170,1,0,0,0, - 172,175,1,0,0,0,173,171,1,0,0,0,173,174,1,0,0,0,174,44,1,0,0,0,175, - 173,1,0,0,0,11,0,55,60,69,76,88,93,98,106,112,173,0 + 19,2,20,7,20,2,21,7,21,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,3,1,4,1, + 4,3,4,57,8,4,1,4,5,4,60,8,4,10,4,12,4,63,9,4,1,4,1,4,1,5,1,5,1,5, + 1,6,1,6,3,6,72,8,6,1,7,1,7,1,7,1,8,1,8,1,8,3,8,80,8,8,1,9,1,9,1, + 10,1,10,1,10,1,10,1,10,1,10,1,10,4,10,91,8,10,11,10,12,10,92,1,10, + 4,10,96,8,10,11,10,12,10,97,1,10,5,10,101,8,10,10,10,12,10,104,9, + 10,1,11,1,11,1,11,1,11,5,11,110,8,11,10,11,12,11,113,9,11,1,11,5, + 11,116,8,11,10,11,12,11,119,9,11,1,12,1,12,1,13,1,13,1,13,1,13,1, + 13,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,14,1,15,1,15,1,15,1, + 15,1,15,1,15,1,15,1,15,1,16,1,16,1,16,1,16,1,16,1,16,1,17,1,17,1, + 17,1,17,1,17,1,17,1,17,1,17,1,17,1,18,1,18,1,18,1,18,1,19,1,19,1, + 19,1,19,1,19,1,19,1,20,1,20,1,20,1,20,1,20,1,20,1,21,1,21,1,21,5, + 21,179,8,21,10,21,12,21,182,9,21,0,0,22,1,1,3,2,5,3,7,4,9,5,11,6, + 13,7,15,0,17,0,19,0,21,8,23,9,25,0,27,10,29,11,31,12,33,13,35,14, + 37,15,39,16,41,17,43,18,1,0,4,3,0,65,90,95,95,97,122,4,0,48,57,65, + 90,95,95,97,122,4,0,45,57,65,90,95,95,97,122,2,0,10,10,32,32,189, + 0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11, + 1,0,0,0,0,13,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,27,1,0,0,0,0,29, + 1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39, + 1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,1,45,1,0,0,0,3,47,1,0,0,0,5,49, + 1,0,0,0,7,51,1,0,0,0,9,54,1,0,0,0,11,66,1,0,0,0,13,71,1,0,0,0,15, + 73,1,0,0,0,17,79,1,0,0,0,19,81,1,0,0,0,21,83,1,0,0,0,23,105,1,0, + 0,0,25,120,1,0,0,0,27,122,1,0,0,0,29,127,1,0,0,0,31,136,1,0,0,0, + 33,144,1,0,0,0,35,150,1,0,0,0,37,159,1,0,0,0,39,163,1,0,0,0,41,169, + 1,0,0,0,43,175,1,0,0,0,45,46,5,91,0,0,46,2,1,0,0,0,47,48,5,93,0, + 0,48,4,1,0,0,0,49,50,5,61,0,0,50,6,1,0,0,0,51,52,5,63,0,0,52,53, + 5,61,0,0,53,8,1,0,0,0,54,56,3,1,0,0,55,57,7,0,0,0,56,55,1,0,0,0, + 56,57,1,0,0,0,57,61,1,0,0,0,58,60,7,1,0,0,59,58,1,0,0,0,60,63,1, + 0,0,0,61,59,1,0,0,0,61,62,1,0,0,0,62,64,1,0,0,0,63,61,1,0,0,0,64, + 65,5,36,0,0,65,10,1,0,0,0,66,67,3,1,0,0,67,68,5,35,0,0,68,12,1,0, + 0,0,69,72,3,15,7,0,70,72,9,0,0,0,71,69,1,0,0,0,71,70,1,0,0,0,72, + 14,1,0,0,0,73,74,3,19,9,0,74,75,3,17,8,0,75,16,1,0,0,0,76,80,3,1, + 0,0,77,80,3,19,9,0,78,80,3,3,1,0,79,76,1,0,0,0,79,77,1,0,0,0,79, + 78,1,0,0,0,80,18,1,0,0,0,81,82,5,92,0,0,82,20,1,0,0,0,83,84,3,1, + 0,0,84,85,5,58,0,0,85,86,5,117,0,0,86,87,5,115,0,0,87,88,5,101,0, + 0,88,90,1,0,0,0,89,91,3,25,12,0,90,89,1,0,0,0,91,92,1,0,0,0,92,90, + 1,0,0,0,92,93,1,0,0,0,93,95,1,0,0,0,94,96,7,2,0,0,95,94,1,0,0,0, + 96,97,1,0,0,0,97,95,1,0,0,0,97,98,1,0,0,0,98,102,1,0,0,0,99,101, + 3,25,12,0,100,99,1,0,0,0,101,104,1,0,0,0,102,100,1,0,0,0,102,103, + 1,0,0,0,103,22,1,0,0,0,104,102,1,0,0,0,105,106,3,1,0,0,106,107,5, + 64,0,0,107,111,7,0,0,0,108,110,7,1,0,0,109,108,1,0,0,0,110,113,1, + 0,0,0,111,109,1,0,0,0,111,112,1,0,0,0,112,117,1,0,0,0,113,111,1, + 0,0,0,114,116,3,25,12,0,115,114,1,0,0,0,116,119,1,0,0,0,117,115, + 1,0,0,0,117,118,1,0,0,0,118,24,1,0,0,0,119,117,1,0,0,0,120,121,7, + 3,0,0,121,26,1,0,0,0,122,123,3,1,0,0,123,124,5,58,0,0,124,125,5, + 105,0,0,125,126,5,102,0,0,126,28,1,0,0,0,127,128,3,1,0,0,128,129, + 5,58,0,0,129,130,5,99,0,0,130,131,5,104,0,0,131,132,5,111,0,0,132, + 133,5,111,0,0,133,134,5,115,0,0,134,135,5,101,0,0,135,30,1,0,0,0, + 136,137,5,58,0,0,137,138,5,111,0,0,138,139,5,112,0,0,139,140,5,116, + 0,0,140,141,5,105,0,0,141,142,5,111,0,0,142,143,5,110,0,0,143,32, + 1,0,0,0,144,145,5,58,0,0,145,146,5,119,0,0,146,147,5,105,0,0,147, + 148,5,116,0,0,148,149,5,104,0,0,149,34,1,0,0,0,150,151,5,58,0,0, + 151,152,5,100,0,0,152,153,5,101,0,0,153,154,5,102,0,0,154,155,5, + 97,0,0,155,156,5,117,0,0,156,157,5,108,0,0,157,158,5,116,0,0,158, + 36,1,0,0,0,159,160,5,58,0,0,160,161,5,105,0,0,161,162,5,115,0,0, + 162,38,1,0,0,0,163,164,5,58,0,0,164,165,5,116,0,0,165,166,5,104, + 0,0,166,167,5,101,0,0,167,168,5,110,0,0,168,40,1,0,0,0,169,170,5, + 58,0,0,170,171,5,101,0,0,171,172,5,108,0,0,172,173,5,115,0,0,173, + 174,5,101,0,0,174,42,1,0,0,0,175,176,5,58,0,0,176,180,7,0,0,0,177, + 179,7,1,0,0,178,177,1,0,0,0,179,182,1,0,0,0,180,178,1,0,0,0,180, + 181,1,0,0,0,181,44,1,0,0,0,182,180,1,0,0,0,11,0,56,61,71,79,92,97, + 102,111,117,180,0 ] class MetaPromptLexer(Lexer): @@ -103,8 +106,8 @@ class MetaPromptLexer(Lexer): modeNames = [ "DEFAULT_MODE" ] literalNames = [ "", - "'['", "']'", "'='", "'?='", "'#'", "':if'", "':choose'", "':option'", - "':with'", "':default'", "':is'", "':then'", "':else'" ] + "'['", "']'", "'='", "'?='", "':option'", "':with'", "':default'", + "':is'", "':then'", "':else'" ] symbolicNames = [ "", "LB", "RB", "EQ_KW", "EQ_OPTIONAL_KW", "META_PROMPT", "COMMENT_KW", diff --git a/python/src/parser/MetaPromptLexer.tokens b/python/src/parser/MetaPromptLexer.tokens index 8e644ab..b738699 100644 --- a/python/src/parser/MetaPromptLexer.tokens +++ b/python/src/parser/MetaPromptLexer.tokens @@ -20,9 +20,6 @@ VAR_NAME=18 ']'=2 '='=3 '?='=4 -'#'=6 -':if'=10 -':choose'=11 ':option'=12 ':with'=13 ':default'=14 diff --git a/python/src/parser/MetaPromptListener.py b/python/src/parser/MetaPromptListener.py index 1a9c8d4..6340d1e 100644 --- a/python/src/parser/MetaPromptListener.py +++ b/python/src/parser/MetaPromptListener.py @@ -26,15 +26,6 @@ def exitExprs(self, ctx:MetaPromptParser.ExprsContext): pass - # Enter a parse tree produced by MetaPromptParser#exprs1. - def enterExprs1(self, ctx:MetaPromptParser.Exprs1Context): - pass - - # Exit a parse tree produced by MetaPromptParser#exprs1. - def exitExprs1(self, ctx:MetaPromptParser.Exprs1Context): - pass - - # Enter a parse tree produced by MetaPromptParser#expr. def enterExpr(self, ctx:MetaPromptParser.ExprContext): pass @@ -44,15 +35,6 @@ def exitExpr(self, ctx:MetaPromptParser.ExprContext): pass - # Enter a parse tree produced by MetaPromptParser#expr1. - def enterExpr1(self, ctx:MetaPromptParser.Expr1Context): - pass - - # Exit a parse tree produced by MetaPromptParser#expr1. - def exitExpr1(self, ctx:MetaPromptParser.Expr1Context): - pass - - # Enter a parse tree produced by MetaPromptParser#meta_body. def enterMeta_body(self, ctx:MetaPromptParser.Meta_bodyContext): pass diff --git a/python/src/parser/MetaPromptParser.py b/python/src/parser/MetaPromptParser.py index 96644a3..6bb9bc0 100644 --- a/python/src/parser/MetaPromptParser.py +++ b/python/src/parser/MetaPromptParser.py @@ -10,58 +10,58 @@ def serializedATN(): return [ - 4,1,18,150,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7, - 6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13, - 1,0,1,0,1,0,1,1,5,1,33,8,1,10,1,12,1,36,9,1,1,2,4,2,39,8,2,11,2, - 12,2,40,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, - 1,3,1,3,1,3,3,3,60,8,3,1,4,1,4,3,4,64,8,4,1,5,1,5,1,5,1,5,1,5,1, - 5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,4,5,81,8,5,11,5,12,5,82,1, - 5,3,5,86,8,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,5,5, - 100,8,5,10,5,12,5,103,9,5,1,5,1,5,5,5,107,8,5,10,5,12,5,110,9,5, - 3,5,112,8,5,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,8,1,8,3,8,124,8,8, - 1,9,1,9,1,9,3,9,129,8,9,1,10,1,10,1,10,1,10,1,10,1,11,1,11,1,11, - 1,12,5,12,140,8,12,10,12,12,12,143,9,12,1,13,4,13,146,8,13,11,13, - 12,13,147,1,13,2,34,40,0,14,0,2,4,6,8,10,12,14,16,18,20,22,24,26, - 0,0,169,0,28,1,0,0,0,2,34,1,0,0,0,4,38,1,0,0,0,6,59,1,0,0,0,8,63, - 1,0,0,0,10,111,1,0,0,0,12,113,1,0,0,0,14,117,1,0,0,0,16,123,1,0, - 0,0,18,128,1,0,0,0,20,130,1,0,0,0,22,135,1,0,0,0,24,141,1,0,0,0, - 26,145,1,0,0,0,28,29,3,2,1,0,29,30,5,0,0,1,30,1,1,0,0,0,31,33,3, - 6,3,0,32,31,1,0,0,0,33,36,1,0,0,0,34,35,1,0,0,0,34,32,1,0,0,0,35, - 3,1,0,0,0,36,34,1,0,0,0,37,39,3,6,3,0,38,37,1,0,0,0,39,40,1,0,0, - 0,40,41,1,0,0,0,40,38,1,0,0,0,41,5,1,0,0,0,42,43,5,1,0,0,43,44,3, - 8,4,0,44,45,5,2,0,0,45,60,1,0,0,0,46,60,3,26,13,0,47,60,5,2,0,0, - 48,60,5,1,0,0,49,60,5,6,0,0,50,60,5,5,0,0,51,60,5,3,0,0,52,60,5, - 18,0,0,53,60,5,11,0,0,54,60,5,12,0,0,55,60,5,14,0,0,56,60,5,15,0, - 0,57,60,5,9,0,0,58,60,5,13,0,0,59,42,1,0,0,0,59,46,1,0,0,0,59,47, - 1,0,0,0,59,48,1,0,0,0,59,49,1,0,0,0,59,50,1,0,0,0,59,51,1,0,0,0, - 59,52,1,0,0,0,59,53,1,0,0,0,59,54,1,0,0,0,59,55,1,0,0,0,59,56,1, - 0,0,0,59,57,1,0,0,0,59,58,1,0,0,0,60,7,1,0,0,0,61,64,3,10,5,0,62, - 64,3,2,1,0,63,61,1,0,0,0,63,62,1,0,0,0,64,9,1,0,0,0,65,66,5,10,0, - 0,66,67,3,2,1,0,67,68,5,16,0,0,68,69,3,2,1,0,69,70,5,17,0,0,70,71, - 3,2,1,0,71,112,1,0,0,0,72,73,5,10,0,0,73,74,3,2,1,0,74,75,5,16,0, - 0,75,76,3,2,1,0,76,112,1,0,0,0,77,78,5,11,0,0,78,80,3,2,1,0,79,81, - 3,20,10,0,80,79,1,0,0,0,81,82,1,0,0,0,82,80,1,0,0,0,82,83,1,0,0, - 0,83,85,1,0,0,0,84,86,3,22,11,0,85,84,1,0,0,0,85,86,1,0,0,0,86,112, - 1,0,0,0,87,88,5,8,0,0,88,112,3,24,12,0,89,90,5,5,0,0,90,112,3,2, - 1,0,91,92,5,6,0,0,92,112,3,2,1,0,93,112,3,12,6,0,94,112,3,14,7,0, - 95,112,5,18,0,0,96,97,5,9,0,0,97,101,3,16,8,0,98,100,3,18,9,0,99, - 98,1,0,0,0,100,103,1,0,0,0,101,99,1,0,0,0,101,102,1,0,0,0,102,112, - 1,0,0,0,103,101,1,0,0,0,104,108,5,9,0,0,105,107,3,18,9,0,106,105, - 1,0,0,0,107,110,1,0,0,0,108,106,1,0,0,0,108,109,1,0,0,0,109,112, - 1,0,0,0,110,108,1,0,0,0,111,65,1,0,0,0,111,72,1,0,0,0,111,77,1,0, - 0,0,111,87,1,0,0,0,111,89,1,0,0,0,111,91,1,0,0,0,111,93,1,0,0,0, - 111,94,1,0,0,0,111,95,1,0,0,0,111,96,1,0,0,0,111,104,1,0,0,0,112, - 11,1,0,0,0,113,114,5,18,0,0,114,115,5,3,0,0,115,116,3,2,1,0,116, - 13,1,0,0,0,117,118,5,18,0,0,118,119,5,4,0,0,119,120,3,2,1,0,120, - 15,1,0,0,0,121,124,3,12,6,0,122,124,3,2,1,0,123,121,1,0,0,0,123, - 122,1,0,0,0,124,17,1,0,0,0,125,129,3,12,6,0,126,127,5,13,0,0,127, - 129,3,2,1,0,128,125,1,0,0,0,128,126,1,0,0,0,129,19,1,0,0,0,130,131, - 5,12,0,0,131,132,3,2,1,0,132,133,5,15,0,0,133,134,3,2,1,0,134,21, - 1,0,0,0,135,136,5,14,0,0,136,137,3,2,1,0,137,23,1,0,0,0,138,140, - 3,12,6,0,139,138,1,0,0,0,140,143,1,0,0,0,141,139,1,0,0,0,141,142, - 1,0,0,0,142,25,1,0,0,0,143,141,1,0,0,0,144,146,5,7,0,0,145,144,1, - 0,0,0,146,147,1,0,0,0,147,145,1,0,0,0,147,148,1,0,0,0,148,27,1,0, - 0,0,13,34,40,59,63,82,85,101,108,111,123,128,141,147 + 4,1,18,152,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7, + 6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,1,0,1,0,1,0,1,1,5, + 1,29,8,1,10,1,12,1,32,9,1,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1, + 2,1,2,1,2,3,2,46,8,2,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, + 1,3,1,3,1,3,1,3,1,3,1,3,4,3,65,8,3,11,3,12,3,66,1,3,3,3,70,8,3,1, + 3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1, + 3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,5,3,97,8,3,10,3,12,3,100,9,3,1, + 3,1,3,1,3,1,3,5,3,106,8,3,10,3,12,3,109,9,3,1,3,3,3,112,8,3,1,4, + 1,4,1,4,1,4,1,5,1,5,1,5,1,5,1,5,1,5,1,6,1,6,3,6,126,8,6,1,7,1,7, + 1,7,3,7,131,8,7,1,8,1,8,1,8,1,8,1,8,1,9,1,9,1,9,1,10,5,10,142,8, + 10,10,10,12,10,145,9,10,1,11,4,11,148,8,11,11,11,12,11,149,1,11, + 1,30,0,12,0,2,4,6,8,10,12,14,16,18,20,22,0,0,169,0,24,1,0,0,0,2, + 30,1,0,0,0,4,45,1,0,0,0,6,111,1,0,0,0,8,113,1,0,0,0,10,117,1,0,0, + 0,12,125,1,0,0,0,14,130,1,0,0,0,16,132,1,0,0,0,18,137,1,0,0,0,20, + 143,1,0,0,0,22,147,1,0,0,0,24,25,3,2,1,0,25,26,5,0,0,1,26,1,1,0, + 0,0,27,29,3,4,2,0,28,27,1,0,0,0,29,32,1,0,0,0,30,31,1,0,0,0,30,28, + 1,0,0,0,31,3,1,0,0,0,32,30,1,0,0,0,33,46,3,6,3,0,34,46,3,22,11,0, + 35,46,5,6,0,0,36,46,5,5,0,0,37,46,5,3,0,0,38,46,5,18,0,0,39,46,5, + 11,0,0,40,46,5,12,0,0,41,46,5,14,0,0,42,46,5,15,0,0,43,46,5,9,0, + 0,44,46,5,13,0,0,45,33,1,0,0,0,45,34,1,0,0,0,45,35,1,0,0,0,45,36, + 1,0,0,0,45,37,1,0,0,0,45,38,1,0,0,0,45,39,1,0,0,0,45,40,1,0,0,0, + 45,41,1,0,0,0,45,42,1,0,0,0,45,43,1,0,0,0,45,44,1,0,0,0,46,5,1,0, + 0,0,47,48,5,10,0,0,48,49,3,2,1,0,49,50,5,16,0,0,50,51,3,2,1,0,51, + 52,5,17,0,0,52,53,3,2,1,0,53,54,5,2,0,0,54,112,1,0,0,0,55,56,5,10, + 0,0,56,57,3,2,1,0,57,58,5,16,0,0,58,59,3,2,1,0,59,60,5,2,0,0,60, + 112,1,0,0,0,61,62,5,11,0,0,62,64,3,2,1,0,63,65,3,16,8,0,64,63,1, + 0,0,0,65,66,1,0,0,0,66,64,1,0,0,0,66,67,1,0,0,0,67,69,1,0,0,0,68, + 70,3,18,9,0,69,68,1,0,0,0,69,70,1,0,0,0,70,71,1,0,0,0,71,72,5,2, + 0,0,72,112,1,0,0,0,73,74,5,8,0,0,74,75,3,20,10,0,75,76,5,2,0,0,76, + 112,1,0,0,0,77,78,5,5,0,0,78,79,3,2,1,0,79,80,5,2,0,0,80,112,1,0, + 0,0,81,82,5,6,0,0,82,83,3,2,1,0,83,84,5,2,0,0,84,112,1,0,0,0,85, + 86,5,1,0,0,86,87,3,8,4,0,87,88,5,2,0,0,88,112,1,0,0,0,89,112,3,10, + 5,0,90,91,5,1,0,0,91,92,5,18,0,0,92,112,5,2,0,0,93,94,5,9,0,0,94, + 98,3,12,6,0,95,97,3,14,7,0,96,95,1,0,0,0,97,100,1,0,0,0,98,96,1, + 0,0,0,98,99,1,0,0,0,99,101,1,0,0,0,100,98,1,0,0,0,101,102,5,2,0, + 0,102,112,1,0,0,0,103,107,5,9,0,0,104,106,3,14,7,0,105,104,1,0,0, + 0,106,109,1,0,0,0,107,105,1,0,0,0,107,108,1,0,0,0,108,110,1,0,0, + 0,109,107,1,0,0,0,110,112,5,2,0,0,111,47,1,0,0,0,111,55,1,0,0,0, + 111,61,1,0,0,0,111,73,1,0,0,0,111,77,1,0,0,0,111,81,1,0,0,0,111, + 85,1,0,0,0,111,89,1,0,0,0,111,90,1,0,0,0,111,93,1,0,0,0,111,103, + 1,0,0,0,112,7,1,0,0,0,113,114,5,18,0,0,114,115,5,3,0,0,115,116,3, + 2,1,0,116,9,1,0,0,0,117,118,5,1,0,0,118,119,5,18,0,0,119,120,5,4, + 0,0,120,121,3,2,1,0,121,122,5,2,0,0,122,11,1,0,0,0,123,126,3,8,4, + 0,124,126,3,2,1,0,125,123,1,0,0,0,125,124,1,0,0,0,126,13,1,0,0,0, + 127,131,3,8,4,0,128,129,5,13,0,0,129,131,3,2,1,0,130,127,1,0,0,0, + 130,128,1,0,0,0,131,15,1,0,0,0,132,133,5,12,0,0,133,134,3,2,1,0, + 134,135,5,15,0,0,135,136,3,2,1,0,136,17,1,0,0,0,137,138,5,14,0,0, + 138,139,3,2,1,0,139,19,1,0,0,0,140,142,3,8,4,0,141,140,1,0,0,0,142, + 145,1,0,0,0,143,141,1,0,0,0,143,144,1,0,0,0,144,21,1,0,0,0,145,143, + 1,0,0,0,146,148,5,7,0,0,147,146,1,0,0,0,148,149,1,0,0,0,149,147, + 1,0,0,0,149,150,1,0,0,0,150,23,1,0,0,0,11,30,45,66,69,98,107,111, + 125,130,143,149 ] class MetaPromptParser ( Parser ): @@ -75,8 +75,8 @@ class MetaPromptParser ( Parser ): sharedContextCache = PredictionContextCache() literalNames = [ "", "'['", "']'", "'='", "'?='", "", - "'#'", "", "", "", "':if'", - "':choose'", "':option'", "':with'", "':default'", + "", "", "", "", + "", "", "':option'", "':with'", "':default'", "':is'", "':then'", "':else'" ] symbolicNames = [ "", "LB", "RB", "EQ_KW", "EQ_OPTIONAL_KW", @@ -86,23 +86,20 @@ class MetaPromptParser ( Parser ): RULE_prompt = 0 RULE_exprs = 1 - RULE_exprs1 = 2 - RULE_expr = 3 - RULE_expr1 = 4 - RULE_meta_body = 5 - RULE_var_assignment = 6 - RULE_var_optional_assignment = 7 - RULE_call_arg1 = 8 - RULE_call_arg = 9 - RULE_option = 10 - RULE_default_option = 11 - RULE_named_parameters = 12 - RULE_text = 13 - - ruleNames = [ "prompt", "exprs", "exprs1", "expr", "expr1", "meta_body", - "var_assignment", "var_optional_assignment", "call_arg1", - "call_arg", "option", "default_option", "named_parameters", - "text" ] + RULE_expr = 2 + RULE_meta_body = 3 + RULE_var_assignment = 4 + RULE_var_optional_assignment = 5 + RULE_call_arg1 = 6 + RULE_call_arg = 7 + RULE_option = 8 + RULE_default_option = 9 + RULE_named_parameters = 10 + RULE_text = 11 + + ruleNames = [ "prompt", "exprs", "expr", "meta_body", "var_assignment", + "var_optional_assignment", "call_arg1", "call_arg", "option", + "default_option", "named_parameters", "text" ] EOF = Token.EOF LB=1 @@ -173,9 +170,9 @@ def prompt(self): self.enterRule(localctx, 0, self.RULE_prompt) try: self.enterOuterAlt(localctx, 1) - self.state = 28 + self.state = 24 self.exprs() - self.state = 29 + self.state = 25 self.match(MetaPromptParser.EOF) except RecognitionException as re: localctx.exception = re @@ -226,14 +223,14 @@ def exprs(self): self.enterRule(localctx, 2, self.RULE_exprs) try: self.enterOuterAlt(localctx, 1) - self.state = 34 + self.state = 30 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input,0,self._ctx) while _alt!=1 and _alt!=ATN.INVALID_ALT_NUMBER: if _alt==1+1: - self.state = 31 + self.state = 27 self.expr() - self.state = 36 + self.state = 32 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input,0,self._ctx) @@ -246,69 +243,6 @@ def exprs(self): return localctx - class Exprs1Context(ParserRuleContext): - __slots__ = 'parser' - - def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): - super().__init__(parent, invokingState) - self.parser = parser - - def expr(self, i:int=None): - if i is None: - return self.getTypedRuleContexts(MetaPromptParser.ExprContext) - else: - return self.getTypedRuleContext(MetaPromptParser.ExprContext,i) - - - def getRuleIndex(self): - return MetaPromptParser.RULE_exprs1 - - def enterRule(self, listener:ParseTreeListener): - if hasattr( listener, "enterExprs1" ): - listener.enterExprs1(self) - - def exitRule(self, listener:ParseTreeListener): - if hasattr( listener, "exitExprs1" ): - listener.exitExprs1(self) - - def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitExprs1" ): - return visitor.visitExprs1(self) - else: - return visitor.visitChildren(self) - - - - - def exprs1(self): - - localctx = MetaPromptParser.Exprs1Context(self, self._ctx, self.state) - self.enterRule(localctx, 4, self.RULE_exprs1) - try: - self.enterOuterAlt(localctx, 1) - self.state = 38 - self._errHandler.sync(self) - _alt = 1+1 - while _alt!=1 and _alt!=ATN.INVALID_ALT_NUMBER: - if _alt == 1+1: - self.state = 37 - self.expr() - - else: - raise NoViableAltException(self) - self.state = 40 - self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,1,self._ctx) - - except RecognitionException as re: - localctx.exception = re - self._errHandler.reportError(self, re) - self._errHandler.recover(self, re) - finally: - self.exitRule() - return localctx - - class ExprContext(ParserRuleContext): __slots__ = 'parser' @@ -316,15 +250,9 @@ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser - def LB(self): - return self.getToken(MetaPromptParser.LB, 0) - - def expr1(self): - return self.getTypedRuleContext(MetaPromptParser.Expr1Context,0) - + def meta_body(self): + return self.getTypedRuleContext(MetaPromptParser.Meta_bodyContext,0) - def RB(self): - return self.getToken(MetaPromptParser.RB, 0) def text(self): return self.getTypedRuleContext(MetaPromptParser.TextContext,0) @@ -383,96 +311,80 @@ def accept(self, visitor:ParseTreeVisitor): def expr(self): localctx = MetaPromptParser.ExprContext(self, self._ctx, self.state) - self.enterRule(localctx, 6, self.RULE_expr) + self.enterRule(localctx, 4, self.RULE_expr) try: - self.state = 59 + self.state = 45 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,2,self._ctx) + la_ = self._interp.adaptivePredict(self._input,1,self._ctx) if la_ == 1: self.enterOuterAlt(localctx, 1) - self.state = 42 - self.match(MetaPromptParser.LB) - self.state = 43 - self.expr1() - self.state = 44 - self.match(MetaPromptParser.RB) + self.state = 33 + self.meta_body() pass elif la_ == 2: self.enterOuterAlt(localctx, 2) - self.state = 46 + self.state = 34 self.text() pass elif la_ == 3: self.enterOuterAlt(localctx, 3) - self.state = 47 - self.match(MetaPromptParser.RB) + self.state = 35 + self.match(MetaPromptParser.COMMENT_KW) pass elif la_ == 4: self.enterOuterAlt(localctx, 4) - self.state = 48 - self.match(MetaPromptParser.LB) + self.state = 36 + self.match(MetaPromptParser.META_PROMPT) pass elif la_ == 5: self.enterOuterAlt(localctx, 5) - self.state = 49 - self.match(MetaPromptParser.COMMENT_KW) + self.state = 37 + self.match(MetaPromptParser.EQ_KW) pass elif la_ == 6: self.enterOuterAlt(localctx, 6) - self.state = 50 - self.match(MetaPromptParser.META_PROMPT) + self.state = 38 + self.match(MetaPromptParser.VAR_NAME) pass elif la_ == 7: self.enterOuterAlt(localctx, 7) - self.state = 51 - self.match(MetaPromptParser.EQ_KW) + self.state = 39 + self.match(MetaPromptParser.CHOOSE_KW) pass elif la_ == 8: self.enterOuterAlt(localctx, 8) - self.state = 52 - self.match(MetaPromptParser.VAR_NAME) + self.state = 40 + self.match(MetaPromptParser.OPTION_KW) pass elif la_ == 9: self.enterOuterAlt(localctx, 9) - self.state = 53 - self.match(MetaPromptParser.CHOOSE_KW) + self.state = 41 + self.match(MetaPromptParser.DEFAULT_KW) pass elif la_ == 10: self.enterOuterAlt(localctx, 10) - self.state = 54 - self.match(MetaPromptParser.OPTION_KW) + self.state = 42 + self.match(MetaPromptParser.IS_KW) pass elif la_ == 11: self.enterOuterAlt(localctx, 11) - self.state = 55 - self.match(MetaPromptParser.DEFAULT_KW) + self.state = 43 + self.match(MetaPromptParser.CALL) pass elif la_ == 12: self.enterOuterAlt(localctx, 12) - self.state = 56 - self.match(MetaPromptParser.IS_KW) - pass - - elif la_ == 13: - self.enterOuterAlt(localctx, 13) - self.state = 57 - self.match(MetaPromptParser.CALL) - pass - - elif la_ == 14: - self.enterOuterAlt(localctx, 14) - self.state = 58 + self.state = 44 self.match(MetaPromptParser.WITH_KW) pass @@ -486,71 +398,6 @@ def expr(self): return localctx - class Expr1Context(ParserRuleContext): - __slots__ = 'parser' - - def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): - super().__init__(parent, invokingState) - self.parser = parser - - def meta_body(self): - return self.getTypedRuleContext(MetaPromptParser.Meta_bodyContext,0) - - - def exprs(self): - return self.getTypedRuleContext(MetaPromptParser.ExprsContext,0) - - - def getRuleIndex(self): - return MetaPromptParser.RULE_expr1 - - def enterRule(self, listener:ParseTreeListener): - if hasattr( listener, "enterExpr1" ): - listener.enterExpr1(self) - - def exitRule(self, listener:ParseTreeListener): - if hasattr( listener, "exitExpr1" ): - listener.exitExpr1(self) - - def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitExpr1" ): - return visitor.visitExpr1(self) - else: - return visitor.visitChildren(self) - - - - - def expr1(self): - - localctx = MetaPromptParser.Expr1Context(self, self._ctx, self.state) - self.enterRule(localctx, 8, self.RULE_expr1) - try: - self.state = 63 - self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,3,self._ctx) - if la_ == 1: - self.enterOuterAlt(localctx, 1) - self.state = 61 - self.meta_body() - pass - - elif la_ == 2: - self.enterOuterAlt(localctx, 2) - self.state = 62 - self.exprs() - pass - - - except RecognitionException as re: - localctx.exception = re - self._errHandler.reportError(self, re) - self._errHandler.recover(self, re) - finally: - self.exitRule() - return localctx - - class Meta_bodyContext(ParserRuleContext): __slots__ = 'parser' @@ -574,6 +421,9 @@ def THEN_KW(self): def ELSE_KW(self): return self.getToken(MetaPromptParser.ELSE_KW, 0) + def RB(self): + return self.getToken(MetaPromptParser.RB, 0) + def CHOOSE_KW(self): return self.getToken(MetaPromptParser.CHOOSE_KW, 0) @@ -601,6 +451,9 @@ def META_PROMPT(self): def COMMENT_KW(self): return self.getToken(MetaPromptParser.COMMENT_KW, 0) + def LB(self): + return self.getToken(MetaPromptParser.LB, 0) + def var_assignment(self): return self.getTypedRuleContext(MetaPromptParser.Var_assignmentContext,0) @@ -649,142 +502,166 @@ def accept(self, visitor:ParseTreeVisitor): def meta_body(self): localctx = MetaPromptParser.Meta_bodyContext(self, self._ctx, self.state) - self.enterRule(localctx, 10, self.RULE_meta_body) + self.enterRule(localctx, 6, self.RULE_meta_body) self._la = 0 # Token type try: self.state = 111 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,8,self._ctx) + la_ = self._interp.adaptivePredict(self._input,6,self._ctx) if la_ == 1: self.enterOuterAlt(localctx, 1) - self.state = 65 + self.state = 47 self.match(MetaPromptParser.IF_KW) - self.state = 66 + self.state = 48 self.exprs() - self.state = 67 + self.state = 49 self.match(MetaPromptParser.THEN_KW) - self.state = 68 + self.state = 50 self.exprs() - self.state = 69 + self.state = 51 self.match(MetaPromptParser.ELSE_KW) - self.state = 70 + self.state = 52 self.exprs() + self.state = 53 + self.match(MetaPromptParser.RB) pass elif la_ == 2: self.enterOuterAlt(localctx, 2) - self.state = 72 + self.state = 55 self.match(MetaPromptParser.IF_KW) - self.state = 73 + self.state = 56 self.exprs() - self.state = 74 + self.state = 57 self.match(MetaPromptParser.THEN_KW) - self.state = 75 + self.state = 58 self.exprs() + self.state = 59 + self.match(MetaPromptParser.RB) pass elif la_ == 3: self.enterOuterAlt(localctx, 3) - self.state = 77 + self.state = 61 self.match(MetaPromptParser.CHOOSE_KW) - self.state = 78 + self.state = 62 self.exprs() - self.state = 80 + self.state = 64 self._errHandler.sync(self) _la = self._input.LA(1) while True: - self.state = 79 + self.state = 63 self.option() - self.state = 82 + self.state = 66 self._errHandler.sync(self) _la = self._input.LA(1) if not (_la==12): break - self.state = 85 + self.state = 69 self._errHandler.sync(self) _la = self._input.LA(1) if _la==14: - self.state = 84 + self.state = 68 self.default_option() + self.state = 71 + self.match(MetaPromptParser.RB) pass elif la_ == 4: self.enterOuterAlt(localctx, 4) - self.state = 87 + self.state = 73 self.match(MetaPromptParser.USE) - self.state = 88 + self.state = 74 self.named_parameters() + self.state = 75 + self.match(MetaPromptParser.RB) pass elif la_ == 5: self.enterOuterAlt(localctx, 5) - self.state = 89 + self.state = 77 self.match(MetaPromptParser.META_PROMPT) - self.state = 90 + self.state = 78 self.exprs() + self.state = 79 + self.match(MetaPromptParser.RB) pass elif la_ == 6: self.enterOuterAlt(localctx, 6) - self.state = 91 + self.state = 81 self.match(MetaPromptParser.COMMENT_KW) - self.state = 92 + self.state = 82 self.exprs() + self.state = 83 + self.match(MetaPromptParser.RB) pass elif la_ == 7: self.enterOuterAlt(localctx, 7) - self.state = 93 + self.state = 85 + self.match(MetaPromptParser.LB) + self.state = 86 self.var_assignment() + self.state = 87 + self.match(MetaPromptParser.RB) pass elif la_ == 8: self.enterOuterAlt(localctx, 8) - self.state = 94 + self.state = 89 self.var_optional_assignment() pass elif la_ == 9: self.enterOuterAlt(localctx, 9) - self.state = 95 + self.state = 90 + self.match(MetaPromptParser.LB) + self.state = 91 self.match(MetaPromptParser.VAR_NAME) + self.state = 92 + self.match(MetaPromptParser.RB) pass elif la_ == 10: self.enterOuterAlt(localctx, 10) - self.state = 96 + self.state = 93 self.match(MetaPromptParser.CALL) - self.state = 97 + self.state = 94 self.call_arg1() - self.state = 101 + self.state = 98 self._errHandler.sync(self) _la = self._input.LA(1) while _la==13 or _la==18: - self.state = 98 + self.state = 95 self.call_arg() - self.state = 103 + self.state = 100 self._errHandler.sync(self) _la = self._input.LA(1) + self.state = 101 + self.match(MetaPromptParser.RB) pass elif la_ == 11: self.enterOuterAlt(localctx, 11) - self.state = 104 + self.state = 103 self.match(MetaPromptParser.CALL) - self.state = 108 + self.state = 107 self._errHandler.sync(self) _la = self._input.LA(1) while _la==13 or _la==18: - self.state = 105 + self.state = 104 self.call_arg() - self.state = 110 + self.state = 109 self._errHandler.sync(self) _la = self._input.LA(1) + self.state = 110 + self.match(MetaPromptParser.RB) pass @@ -837,7 +714,7 @@ def accept(self, visitor:ParseTreeVisitor): def var_assignment(self): localctx = MetaPromptParser.Var_assignmentContext(self, self._ctx, self.state) - self.enterRule(localctx, 12, self.RULE_var_assignment) + self.enterRule(localctx, 8, self.RULE_var_assignment) try: self.enterOuterAlt(localctx, 1) self.state = 113 @@ -862,6 +739,9 @@ def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): super().__init__(parent, invokingState) self.parser = parser + def LB(self): + return self.getToken(MetaPromptParser.LB, 0) + def VAR_NAME(self): return self.getToken(MetaPromptParser.VAR_NAME, 0) @@ -872,6 +752,9 @@ def exprs(self): return self.getTypedRuleContext(MetaPromptParser.ExprsContext,0) + def RB(self): + return self.getToken(MetaPromptParser.RB, 0) + def getRuleIndex(self): return MetaPromptParser.RULE_var_optional_assignment @@ -895,15 +778,19 @@ def accept(self, visitor:ParseTreeVisitor): def var_optional_assignment(self): localctx = MetaPromptParser.Var_optional_assignmentContext(self, self._ctx, self.state) - self.enterRule(localctx, 14, self.RULE_var_optional_assignment) + self.enterRule(localctx, 10, self.RULE_var_optional_assignment) try: self.enterOuterAlt(localctx, 1) self.state = 117 - self.match(MetaPromptParser.VAR_NAME) + self.match(MetaPromptParser.LB) self.state = 118 - self.match(MetaPromptParser.EQ_OPTIONAL_KW) + self.match(MetaPromptParser.VAR_NAME) self.state = 119 + self.match(MetaPromptParser.EQ_OPTIONAL_KW) + self.state = 120 self.exprs() + self.state = 121 + self.match(MetaPromptParser.RB) except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -951,20 +838,20 @@ def accept(self, visitor:ParseTreeVisitor): def call_arg1(self): localctx = MetaPromptParser.Call_arg1Context(self, self._ctx, self.state) - self.enterRule(localctx, 16, self.RULE_call_arg1) + self.enterRule(localctx, 12, self.RULE_call_arg1) try: - self.state = 123 + self.state = 125 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,9,self._ctx) + la_ = self._interp.adaptivePredict(self._input,7,self._ctx) if la_ == 1: self.enterOuterAlt(localctx, 1) - self.state = 121 + self.state = 123 self.var_assignment() pass elif la_ == 2: self.enterOuterAlt(localctx, 2) - self.state = 122 + self.state = 124 self.exprs() pass @@ -1019,21 +906,21 @@ def accept(self, visitor:ParseTreeVisitor): def call_arg(self): localctx = MetaPromptParser.Call_argContext(self, self._ctx, self.state) - self.enterRule(localctx, 18, self.RULE_call_arg) + self.enterRule(localctx, 14, self.RULE_call_arg) try: - self.state = 128 + self.state = 130 self._errHandler.sync(self) token = self._input.LA(1) if token in [18]: self.enterOuterAlt(localctx, 1) - self.state = 125 + self.state = 127 self.var_assignment() pass elif token in [13]: self.enterOuterAlt(localctx, 2) - self.state = 126 + self.state = 128 self.match(MetaPromptParser.WITH_KW) - self.state = 127 + self.state = 129 self.exprs() pass else: @@ -1091,16 +978,16 @@ def accept(self, visitor:ParseTreeVisitor): def option(self): localctx = MetaPromptParser.OptionContext(self, self._ctx, self.state) - self.enterRule(localctx, 20, self.RULE_option) + self.enterRule(localctx, 16, self.RULE_option) try: self.enterOuterAlt(localctx, 1) - self.state = 130 + self.state = 132 self.match(MetaPromptParser.OPTION_KW) - self.state = 131 + self.state = 133 self.exprs() - self.state = 132 + self.state = 134 self.match(MetaPromptParser.IS_KW) - self.state = 133 + self.state = 135 self.exprs() except RecognitionException as re: localctx.exception = re @@ -1148,12 +1035,12 @@ def accept(self, visitor:ParseTreeVisitor): def default_option(self): localctx = MetaPromptParser.Default_optionContext(self, self._ctx, self.state) - self.enterRule(localctx, 22, self.RULE_default_option) + self.enterRule(localctx, 18, self.RULE_default_option) try: self.enterOuterAlt(localctx, 1) - self.state = 135 + self.state = 137 self.match(MetaPromptParser.DEFAULT_KW) - self.state = 136 + self.state = 138 self.exprs() except RecognitionException as re: localctx.exception = re @@ -1201,17 +1088,17 @@ def accept(self, visitor:ParseTreeVisitor): def named_parameters(self): localctx = MetaPromptParser.Named_parametersContext(self, self._ctx, self.state) - self.enterRule(localctx, 24, self.RULE_named_parameters) + self.enterRule(localctx, 20, self.RULE_named_parameters) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 141 + self.state = 143 self._errHandler.sync(self) _la = self._input.LA(1) while _la==18: - self.state = 138 + self.state = 140 self.var_assignment() - self.state = 143 + self.state = 145 self._errHandler.sync(self) _la = self._input.LA(1) @@ -1260,22 +1147,22 @@ def accept(self, visitor:ParseTreeVisitor): def text(self): localctx = MetaPromptParser.TextContext(self, self._ctx, self.state) - self.enterRule(localctx, 26, self.RULE_text) + self.enterRule(localctx, 22, self.RULE_text) try: self.enterOuterAlt(localctx, 1) - self.state = 145 + self.state = 147 self._errHandler.sync(self) _alt = 1 while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: if _alt == 1: - self.state = 144 + self.state = 146 self.match(MetaPromptParser.CHAR) else: raise NoViableAltException(self) - self.state = 147 + self.state = 149 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,12,self._ctx) + _alt = self._interp.adaptivePredict(self._input,10,self._ctx) except RecognitionException as re: localctx.exception = re diff --git a/python/src/parser/MetaPromptVisitor.py b/python/src/parser/MetaPromptVisitor.py index e872947..e7c71ff 100644 --- a/python/src/parser/MetaPromptVisitor.py +++ b/python/src/parser/MetaPromptVisitor.py @@ -19,21 +19,11 @@ def visitExprs(self, ctx:MetaPromptParser.ExprsContext): return self.visitChildren(ctx) - # Visit a parse tree produced by MetaPromptParser#exprs1. - def visitExprs1(self, ctx:MetaPromptParser.Exprs1Context): - return self.visitChildren(ctx) - - # Visit a parse tree produced by MetaPromptParser#expr. def visitExpr(self, ctx:MetaPromptParser.ExprContext): return self.visitChildren(ctx) - # Visit a parse tree produced by MetaPromptParser#expr1. - def visitExpr1(self, ctx:MetaPromptParser.Expr1Context): - return self.visitChildren(ctx) - - # Visit a parse tree produced by MetaPromptParser#meta_body. def visitMeta_body(self, ctx:MetaPromptParser.Meta_bodyContext): return self.visitChildren(ctx) diff --git a/python/tests/test_parser.py b/python/tests/test_parser.py index 4300e0f..d62ee85 100644 --- a/python/tests/test_parser.py +++ b/python/tests/test_parser.py @@ -112,7 +112,7 @@ def test_escaping_1(): def test_escaping_2(): - result = parse("\\[:foo]") + result = parse("\\[:foo\\]") assert result == [t("[:foo]")] @@ -132,8 +132,9 @@ def test_escaping_3(): def test_escaping_4(): - result = parse("\\\\[") - assert result == [t("\\\\[")] + bs="\\" + result = parse(f"{bs}{bs}{bs}[") + assert result == [t(f"{bs}[")] def test_escaping_5(): @@ -206,27 +207,27 @@ def test_if_nested(): def test_dummy_meta(): - result = parse("[test]") + result = parse("\[test\]") assert result == [t("[test]")] def test_dummy_meta2(): - result = parse("[[]]") + result = parse("\\[\\[\\]\\]") assert result == [t("[[]]")] def test_dummy_meta3(): - result = parse("[a") - assert result == [t("[a")] + result = parse("\\[a") + assert result == [t("\\[a")] def test_dummy_meta4(): - result = parse("[[][]]") + result = parse("\\[\\[\\]\\[\\]\\]") assert result == [t("[[][]]")] def test_meta2(): - result = parse("[$ []]") + result = parse("[$ \\[\\]]") assert result == [meta([t(" []")])] @@ -331,7 +332,7 @@ def test_use_nested(): def test_use_nested_2(): - result = parse("[:use foo :asd=[hiiii [:use bar :qux=asd]] hiii :foo=bar]") + result = parse("[:use foo :asd=\\[hiiii [:use bar :qux=asd]\\] hiii :foo=bar]") assert result == [ { "type": "use",