Esempio n. 1
0
        public float Query(IContext context, string line)
        {
            NaturalLanguageParser nlp = new NaturalLanguageParser(line);

            if (nlp.StatementType == StatementType.Invalid_Statement)
            {
                throw new QueryGalaxyException("Invalid query", line, null);
            }

            try
            {
                if (processors.ContainsKey(nlp.StatementType))
                {
                    IStatementProcessor statementProcessor = processors[nlp.StatementType];
                    return(statementProcessor.ProcessStatement(context, line));
                }
                else
                {
                    throw new QueryGalaxyException("No processor defined", line, null);
                }
            }

            catch (ArithmeticException ae)
            {
                throw new QueryGalaxyException("The unit passed is not a valid Galactic Unit", line, null, ae);
            }
        }
Esempio n. 2
0
        private static string GetCodeFrom(string statement)
        {
            IStatementProcessor processor = GetProcessorFor(statement);

            if (processor == null)
            {
                return(statement);
            }

            return(processor.GetInfoFor(statement).ToCode());
        }