001package gudusoft.gsqlparser; 002 003import gudusoft.gsqlparser.nodes.ENodeType; 004import gudusoft.gsqlparser.nodes.TDummy; 005import gudusoft.gsqlparser.nodes.TNodeFactory; 006 007/** 008 * Minimal {@link TCustomParser} implementation for Power Query M. 009 * 010 * <p>{@link #yyparse()} synthesises a single {@link TDummy} root node 011 * covering the entire statement token span and reports success. The real 012 * M-language document parsing happens inside 013 * {@link gudusoft.gsqlparser.stmt.powerquery.TPowerQueryDocumentStmt#doParseStatement} 014 * via {@code gudusoft.gsqlparser.parser.powerquery.PowerQueryDocumentParser}. 015 * 016 * <p>Naming: uses {@code PowerQueryGrammarParser} instead of 017 * {@code TParserPowerQuery} to avoid the project's generated-file hook 018 * (see {@code .claude/hooks/protect-generated-files.sh}). 019 */ 020public class PowerQueryGrammarParser extends TCustomParser { 021 022 static { 023 if (TBaseType.enterprise_edition || TBaseType.powerquery_edition) { 024 // No yacc table to load. 025 } 026 } 027 028 public PowerQueryGrammarParser(TSourceTokenList sourcetokens) { 029 super(EDbVendor.dbvpowerquery); 030 this.sourcetokenlist = sourcetokens; 031 } 032 033 @Override 034 public int yyparse() { 035 if (this.nf == null) { 036 this.nf = new TNodeFactory(dbvendor); 037 } 038 TDummy dummy = (TDummy) nf.createNode(ENodeType.T_Dummy.getId()); 039 if (sourcetokenlist != null && sourcetokenlist.size() > 0) { 040 dummy.setStartToken(sourcetokenlist.get(0)); 041 dummy.setEndToken(sourcetokenlist.get(sourcetokenlist.size() - 1)); 042 } 043 this.rootNode = dummy; 044 return 0; 045 } 046}