private static bool inferEndObject(IEnumerable <RhsGroup> groups, ref CodeMix code) { IEnumerable <RhsSymbol> symbols = groups.Select(it => it.GetSymbols()).Flatten(); if (symbols.Any(it => it.IsError)) { return(true); } if (symbols.Count() != 1) { symbols = symbols.Where(it => it.ObjName != null); } if (symbols.Count() != 1) { return(false); } RhsSymbol symbol = symbols.Single(); // underscore is not magic -- it is a nice shortcut in grammar file, but awful when reading the output code // thus we change it to something more readable, and since it is automatic, we can do the change (because why not) // this replacement is rather useful only for NLT developer(s) if (symbol.ObjName == null || symbol.ObjName == "_") { symbol.ResetUserObjName(); code = new CodeMix(CodeMix.ObjectInferComment).AddBody(new CodeBody().AddPlaceholder(symbol.SymbolName)); } else { code = new CodeMix(CodeMix.ObjectInferComment).AddBody(new CodeBody().AddIdentifier(symbol.ObjName)); } return(true); }
public string GetTypeNameOfSymbol(RhsSymbol symbol) { return(GetTypeNameOfSymbol(symbol.SymbolName)); }