// public static void Generate( // this NeuCodeGenerator generator, // Node node) { // switch (node) { // /// // case NeuNode neuNode: // generator.Generate(neuNode); // return; // /// // case NeuToken token: // generator.Generate(token); // return; // /// // default: // throw new Exception(); // } // } // public static void Generate( // this NeuCodeGenerator generator, // NeuNode node) { // switch (node) { // case NeuDeclaration decl: // generator.Generate(decl); // return; // /// // case NeuFuncSignature funcSig: // generator.Generate(funcSig); // return; // /// // default: // throw new Exception(); // } // } // public static void Generate( // this NeuCodeGenerator generator, // NeuFuncSignature funcSignature) { // throw new Exception(); // } // public static void Generate( // this NeuCodeGenerator generator, // NeuDeclaration decl) { // switch (decl) { // case NeuFuncDecl funcDecl: // generator.Generate(funcDecl); // return; // /// // default: // throw new Exception(); // } // } // public static void Generate( // this NeuCodeGenerator generator, // NeuFuncDecl funcDecl) { // foreach (var child in funcDecl.Children) { // generator.Generate(child); // } // // throw new Exception(); // } public static void Generate( this NeuCodeGenerator generator, NeuToken token) { switch (token) { case NeuPunc p: generator.Generate(p); return; /// case NeuKeyword keyword: generator.Generate(keyword); return; /// case NeuIdentifier id: generator.Generate(id); return; /// default: throw new Exception(); } }
public static NeuBinaryOperatorType?ToNeuBinaryOperatorType( NeuToken token) { switch (token) { case NeuPunc p when p.PuncType == NeuPuncType.Asterisk: return(NeuBinaryOperatorType.Multiply); /// case NeuPunc p when p.PuncType == NeuPuncType.Slash: return(NeuBinaryOperatorType.Divide); /// case NeuPunc p when p.PuncType == NeuPuncType.Plus: return(NeuBinaryOperatorType.Add); /// case NeuPunc p when p.PuncType == NeuPuncType.Hyphen: return(NeuBinaryOperatorType.Subtract); /// default: return(null); } }
public static NeuAssignOperatorType?ToNeuAssignOperatorType( NeuToken token) { switch (token) { case NeuPunc p when p.PuncType == NeuPuncType.Equal: return(NeuAssignOperatorType.Assign); /// default: return(null); } }
public static NeuUnaryOperatorType?ToNeuUnaryOperatorType( NeuToken token) { switch (token) { case NeuKeyword k when k.KeywordType == NeuKeywordType.SizeOf: return(NeuUnaryOperatorType.SizeOf); /// default: return(null); } }
public static NeuBinaryOperator?ToNeuBinaryOperator( NeuToken token) { switch (ToNeuBinaryOperatorType(token)) { case NeuBinaryOperatorType t: return(new NeuBinaryOperator( source: token.Source, start: token.Start, end: token.End, operatorType: t)); /// default: return(null); } }
public static NeuUnaryOperatorType?ToNeuPostfixOperatorType( NeuToken token) { switch (token) { case NeuPunc p when p.PuncType == NeuPuncType.PlusPlus: return(NeuUnaryOperatorType.Increment); /// case NeuPunc p when p.PuncType == NeuPuncType.HyphenHyphen: return(NeuUnaryOperatorType.Decrement); /// default: return(null); } }