diff --git a/crates/oq3_syntax/src/tests/ast_src.rs b/crates/oq3_syntax/src/tests/ast_src.rs index 75e944a..43e80ea 100644 --- a/crates/oq3_syntax/src/tests/ast_src.rs +++ b/crates/oq3_syntax/src/tests/ast_src.rs @@ -14,105 +14,105 @@ pub(crate) struct KindsSrc<'a> { pub(crate) const KINDS_SRC: KindsSrc<'_> = KindsSrc { punct: &[ - ("++", "DOUBLE_PLUS"), - (";", "SEMICOLON"), - (",", "COMMA"), - ("(", "L_PAREN"), - (")", "R_PAREN"), - ("{", "L_CURLY"), - ("}", "R_CURLY"), - ("[", "L_BRACK"), - ("]", "R_BRACK"), - ("<", "L_ANGLE"), - (">", "R_ANGLE"), - ("@", "AT"), + ("!", "BANG"), + ("!=", "NEQ"), ("#", "POUND"), - ("~", "TILDE"), - ("?", "QUESTION"), ("$", "DOLLAR"), + ("%", "PERCENT"), + ("%=", "PERCENTEQ"), ("&", "AMP"), - ("|", "PIPE"), - ("+", "PLUS"), + ("&&", "AMP2"), + ("&=", "AMPEQ"), + ("(", "L_PAREN"), + (")", "R_PAREN"), ("*", "STAR"), - ("/", "SLASH"), - ("^", "CARET"), - ("%", "PERCENT"), - ("_", "UNDERSCORE"), + ("*=", "STAREQ"), + ("+", "PLUS"), + ("++", "DOUBLE_PLUS"), + ("+=", "PLUSEQ"), + (",", "COMMA"), + ("-", "MINUS"), + ("-=", "MINUSEQ"), + ("->", "THIN_ARROW"), (".", "DOT"), ("..", "DOT2"), ("...", "DOT3"), ("..=", "DOT2EQ"), + ("/", "SLASH"), + ("/=", "SLASHEQ"), (":", "COLON"), ("::", "COLON2"), + (";", "SEMICOLON"), + ("<", "L_ANGLE"), + ("<<", "SHL"), + ("<<=", "SHLEQ"), + ("<=", "LTEQ"), ("=", "EQ"), ("==", "EQ2"), ("=>", "FAT_ARROW"), - ("!", "BANG"), - ("!=", "NEQ"), - ("-", "MINUS"), - ("->", "THIN_ARROW"), - ("<=", "LTEQ"), + (">", "R_ANGLE"), (">=", "GTEQ"), - ("+=", "PLUSEQ"), - ("-=", "MINUSEQ"), - ("|=", "PIPEEQ"), - ("&=", "AMPEQ"), - ("^=", "CARETEQ"), - ("/=", "SLASHEQ"), - ("*=", "STAREQ"), - ("%=", "PERCENTEQ"), - ("&&", "AMP2"), - ("||", "PIPE2"), - ("<<", "SHL"), (">>", "SHR"), - ("<<=", "SHLEQ"), (">>=", "SHREQ"), + ("?", "QUESTION"), + ("@", "AT"), + ("[", "L_BRACK"), + ("]", "R_BRACK"), + ("^", "CARET"), + ("^=", "CARETEQ"), + ("_", "UNDERSCORE"), + ("{", "L_CURLY"), + ("|", "PIPE"), + ("|=", "PIPEEQ"), + ("||", "PIPE2"), + ("}", "R_CURLY"), + ("~", "TILDE"), ], keywords: &[ "OPENQASM", - "include", - "pragma", - "def", - "defcalgrammar", + "barrier", + "box", "cal", + "const", + "def", "defcal", - "gate", + "defcalgrammar", "delay", - "reset", - "measure", - "let", - "box", "extern", - "const", - "barrier", + "gate", "gphase", // This is a slight hack because a `gphase` call has unique syntax. + "include", + "let", + "measure", + "pragma", + "reset", // Flow control - "if", + "break", + "case", + "continue", + "default", "else", + "end", "for", + "if", "in", - "while", - "continue", "return", - "break", - "end", "switch", - "case", - "default", + "while", // Types + "array", + "creg", "input", - "output", - "readonly", "mutable", + "output", "qreg", - "creg", "qubit", + "readonly", "void", - "array", // Gate modifiers "ctrl", - "negctrl", "inv", + "negctrl", "pow", // I suppose these are literals "false", @@ -121,113 +121,113 @@ pub(crate) const KINDS_SRC: KindsSrc<'_> = KindsSrc { // GJL: try introducing scalar_types to help parse var declarations. May not be useful // sourcegen_ast.rs can convert these to upper snake case. scalar_types: &[ - "float", "int", "uint", "complex", "bool", "bit", "duration", "stretch", "angle", + "angle", "bit", "bool", "complex", "duration", "float", "int", "stretch", "uint", ], // These are already upper snake case. literals: &[ - "INT_NUMBER", - "FLOAT_NUMBER", - "CHAR", + "BIT_STRING", "BYTE", + "CHAR", + "FLOAT_NUMBER", + "INT_NUMBER", "STRING", - "BIT_STRING", ], tokens: &[ + "ANNOTATION", + "COMMENT", "ERROR", - "IDENT", "HARDWAREIDENT", - "WHITESPACE", - "COMMENT", + "IDENT", "PRAGMA", - "ANNOTATION", + "WHITESPACE", ], nodes: &[ - "SOURCE_FILE", - "GATE", - "DEF_CAL", - "DELAY_STMT", + "ANNOTATION_STATEMENT", + "BARRIER", "CAL", + "CONST", + "DEF", + "DEF_CAL", "DEF_CAL_GRAMMAR", + "DELAY_STMT", + "GATE", "MEASURE", - "BARRIER", - "DEF", - "RESET", - "CONST", "PRAGMA_STATEMENT", - "ANNOTATION_STATEMENT", + "RESET", + "SOURCE_FILE", "TIMING_LITERAL", // atoms - "TUPLE_EXPR", "ARRAY_EXPR", - "PAREN_EXPR", - "IF_STMT", - "WHILE_STMT", - "FOR_STMT", - "FOR_ITERABLE", - "END_STMT", - "CONTINUE_STMT", - "BREAK_STMT", "BLOCK_EXPR", - "STMT_LIST", - "RETURN_EXPR", - "LET_STMT", "BOX_EXPR", - "SWITCH_CASE_STMT", + "BREAK_STMT", "CASE_EXPR", + "CONTINUE_STMT", + "END_STMT", + "END_STMT", + "FOR_ITERABLE", + "FOR_STMT", + "LET_STMT", + "PAREN_EXPR", + "RETURN_EXPR", + "STMT_LIST", + "SWITCH_CASE_STMT", + "TUPLE_EXPR", + "WHILE_STMT", // postfix "CALL_EXPR", + "CAST_EXPRESSION", "GATE_CALL_EXPR", - "MODIFIED_GATE_CALL_EXPR", "G_PHASE_CALL_EXPR", - "CAST_EXPRESSION", "INDEX_EXPR", + "MODIFIED_GATE_CALL_EXPR", // unary - "PREFIX_EXPR", - "RANGE_EXPR", + "ARG_LIST", "BIN_EXPR", + "DECLARATION", + "EXPR_STMT", + "FILE_PATH", + "INCLUDE", "LITERAL", "NAME", - "EXPR_STMT", - "TYPE", + "PARAM", "PARAM_LIST", - "TYPED_PARAM_LIST", + "PREFIX_EXPR", "QUBIT_LIST", - "FILE_PATH", - "PARAM", + "RANGE_EXPR", + "TYPE", "TYPED_PARAM", - "ARG_LIST", + "TYPED_PARAM_LIST", "VERSION", "VERSION_STRING", - "INCLUDE", - "DECLARATION", // From ANTLR grammar - "DESIGNATOR", - "SCALAR_TYPE", - "ARRAY_TYPE", - "QUBIT_TYPE", - "EXPRESSION_LIST", - "RETURN_SIGNATURE", - "SET_EXPRESSION", "ALIAS_DECLARATION_STATEMENT", - "INDEX_OPERATOR", - "INDEX_KIND", - "INDEXED_IDENTIFIER", - "IDENTIFIER", "ARRAY_LITERAL", - "HARDWARE_QUBIT", - "CLASSICAL_DECLARATION_STATEMENT", + "ARRAY_TYPE", "ASSIGNMENT_STMT", - "I_O_DECLARATION_STATEMENT", + "CLASSICAL_DECLARATION_STATEMENT", + "DESIGNATOR", + "EXPRESSION_LIST", "GATE_OPERAND", + "HARDWARE_QUBIT", + "IDENTIFIER", + "INDEXED_IDENTIFIER", + "INDEX_KIND", + "INDEX_OPERATOR", + "I_O_DECLARATION_STATEMENT", "MEASURE_EXPRESSION", "OLD_STYLE_DECLARATION_STATEMENT", "QUANTUM_DECLARATION_STATEMENT", + "QUBIT_TYPE", + "RETURN_SIGNATURE", + "SCALAR_TYPE", + "SET_EXPRESSION", // Gate modifiers - "INV_MODIFIER", - "POW_MODIFIER", "CTRL_MODIFIER", - "NEG_CTRL_MODIFIER", + "INV_MODIFIER", "MODIFIER", + "NEG_CTRL_MODIFIER", + "POW_MODIFIER", ], };