The invention discloses an intermediate code generation method and device for quantum program compiling. The method comprises the steps of obtaining that a source code of a quantum program is obtained;, wherein the logic structure of the source code at least comprises a quantum branch structure, a quantum circulation structure and a quantum logic gate; carrying out lexical analysis on the source code, and segmenting the source code into a plurality of grammatical unit tokens; performing grammatical analysis on all tokens, and constructing an abstract syntax tree AST; wherein the AST comprisesa root node, a plurality of sub-tree nodes and a plurality of leaf nodes, the root node and the sub-tree nodes comprise grammar rule information, and the leaf nodes comprise token information; and according to the node information of the AST and a preset construction rule, constructing an intermediate code corresponding to the source code. By utilizing the embodiment of the invention, repeated labor can be avoided, and resource occupation is reduced.