public void Update_Reservation()
        {
            reservation r    = EntityFactory.Reservation;
            term        term = EntityFactory.Term;

            if (r != null && term != null)
            {
                tbClientSearch.Text      = r.client.ToString();
                tbEventSearch.Text       = r._event.name;
                tbEventPrice.DataContext = r;

                tbHallSearch.Text     = term.hall.name;
                txtCalendar.Text      = term.rental_date.ToShortDateString();
                calendar.SelectedDate = term.rental_date;

                expander.DataContext = term;

                itemDatagrid.Items.Clear();
                foreach (item_list i in term.items)
                {
                    itemDatagrid.Items.Add(i);
                }
                notes.Text = term.note;

                foreach (var t in r.terms)
                {
                    termDatagrid.Items.Add(t);
                }
                ChangeTerm          = true;
                expander.IsExpanded = true;
                Keyboard.ClearFocus();
            }
        }
Esempio n. 2
0
            public multi(string line)
            {
                //先分割成多個 basic
                string[] parts = line.Split(';');
                basics = new IRunnable[parts.Length];

                //然後就每一個 basic 進行分類
                for (int i = 0; i < parts.Length; i++)
                {
                    if (IsComment(parts[i]))
                    {
                        basics[i] = new empty();
                    }
                    else if (IsTerm(parts[i]))
                    {
                        basics[i] = new term(parts[i].Trim());
                    }
                    else if (IsExec(parts[i]))
                    {
                        basics[i] = new exec(parts[i].Trim());
                    }
                    else
                    {
                        basics[i] = new decla(parts[i].Trim());
                    }
                }
            }
Esempio n. 3
0
 public IActionResult Create(term term, string returnUrl = null)
 {
     if (ModelState.IsValid)
     {
         repository.AddEntity(term);
         return(RedirectToLocal(returnUrl));
     }
     ViewBag.dataTypes     = new SelectList(this.repository.GetDataTypes(), "id", "title");
     ViewData["ReturnUrl"] = returnUrl;
     return(View(term));
 }
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            int count = int.Parse(textBox5.Text);

            ListTerm.Clear();
            for (int i = 1; i < count + 1; i++)
            {
                term temp = new term();
                temp.value_term = i;
                ListTerm.Add(temp);
            }
            dataGrid.ItemsSource = null;
            dataGrid.ItemsSource = ListTerm;
        }
Esempio n. 5
0
        public IActionResult Edit(int id, term term, string returnUrl = null)
        {
            if (id != term.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                this.repository.UpdateEntity(term);
                return(RedirectToLocal(returnUrl));
            }
            ViewBag.dataTypes     = new SelectList(this.repository.GetDataTypes(), "id", "title");
            ViewData["ReturnUrl"] = returnUrl;
            return(View(term));
        }
 private void btnAccept_Click(object sender, RoutedEventArgs e)
 {
     if (currentRow != null)
     {
         term newTerm = currentRow.Item as term;
         datagrid.Items.Remove(newTerm);
         datagrid.Items.Refresh();
         term.Delete(newTerm.id);
         tbDelete.Text = "Uspješno ste obrisali podatke o terminu!";
     }
     else
     {
         tbDelete.Text = "Podaci o terminu nisu obrisani!";
     }
     btnAccept.Visibility = btnCancel.Visibility = Visibility.Collapsed;
 }
Esempio n. 7
0
    /// <summary>For cases of "give someone the thing", we must back up and add "to" to the "someone"</summary>
    static void HandleSwappedDirectandIndirectObjects(multimethod method_being_constructed, string prep, fiveforms verb, bool isSubject)
    {
        if (isSubject)
        {
            return;
        }
        if (listType != null)
        {
            return;
        }
        switch (TheGiveSomebodyItException)
        {
        case DirectObjectPlacement.not_there_yet:
            TheGiveSomebodyItException = DirectObjectPlacement.normal;
            break;

        case DirectObjectPlacement.normal:
            // then the previous parameter is the indirect, not direct, object, and needs "to" prepended
            for (int i = 0; method_being_constructed.signature.Count > i; i++)
            {
                if (method_being_constructed.signature[i].which == PartsOfSpeech.noun)
                {
                    term newterm = method_being_constructed.signature[i];
                    newterm.noun.preposition = prep;
                    method_being_constructed.signature[i] = newterm;
                    CreateFullNames(method_being_constructed.signature[i].noun, verb);    //not sure why this is still needed
                    break;
                }
            }
            TheGiveSomebodyItException = DirectObjectPlacement.after_the_indirect_object;
            break;

        case DirectObjectPlacement.after_the_indirect_object:
        case DirectObjectPlacement.error:
            TheGiveSomebodyItException = DirectObjectPlacement.error;
            Console.WriteLine("  ERROR: I require those parameters to be separated by prepositions or commas.");
            method_being_constructed.problems++;
            break;
        }
    }
        private void btnUpdateTerm_Click(object sender, RoutedEventArgs e)
        {
            DataGridRow dgr       = null;
            var         visParent = VisualTreeHelper.GetParent(e.OriginalSource as FrameworkElement);

            while (dgr == null && visParent != null)
            {
                dgr       = visParent as DataGridRow;
                visParent = VisualTreeHelper.GetParent(visParent);
            }
            if (dgr == null)
            {
                return;
            }

            var rowIdx = dgr.GetIndex();

            term termToUpdate = (term)termDatagrid.Items.GetItemAt(rowIdx);

            atbHallSearch.SelectedItem = termToUpdate.hall.name;
            calendar.SelectedDate      = termToUpdate.rental_date;
            txtCalendar.Text           = termToUpdate.rental_date.ToShortDateString();

            tpTimeFrom.Text  = termToUpdate.rent_time_start.ToString(@"hh\:mm");
            tpTimeUntil.Text = termToUpdate.rent_time_end.ToString(@"hh\:mm");
            itemDatagrid.Items.Clear();
            foreach (item_list i in termToUpdate.items)
            {
                itemDatagrid.Items.Add(i);
            }
            notes.Text = termToUpdate.note;
            ChangeTerm = true;
            termIndex  = rowIdx;

            expander.IsExpanded = true;
        }
Esempio n. 9
0
    static int prompt = 1, subprompt, subsubprompt; // the sentence#, invocation#, and relative clause #

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    static void Main(string[] args)
    {
        ReadForms();
        TheVerbIs = FindVerb("is");
        InitNumberUnitSystem();
        InitInheritanceTree();

        string input = null;

        string[] words = null;
        int      maxWords;

        TestHarness.loadTestScript("me");
        for (Console.Write("{0}: ", prompt); (input = TestHarness.LineFeeder()) != null; TestHarness.EndTurn(2), Console.Write("{0}: ", ++prompt))
        {
            TestHarness.BeginTurn();

            // Move string literals into the string table, leaving placeholders behind.
            while (input.Contains('"'))
            {
                int from  = input.IndexOf('"');
                int endAt = from + 1;
loopPastDquoteLiteral:
                endAt += input.Substring(endAt).IndexOf('"');
                if (input.Length > endAt + 1 && input.ElementAt(endAt + 1) == '"')
                {
                    endAt += 2;
                    goto loopPastDquoteLiteral;
                }
                int    len     = endAt - (from + 1);
                string literal = input.Substring(from + 1, len);
                input = input.Substring(0, from - 1) + String.Format(" __litstring{0}__ ", literalStrings.Count) + input.Substring(endAt + 1);
                literalStrings.Add(literal.Replace("\"\"", "\""));
            }

            // cleanse the input
            input    = input.ToLowerInvariant() + " ";
            input    = input.Replace(", ", " , ").Replace(". ", " . ").Replace(": ", " : ").Replace("? ", " ? ");
            input    = input + " " + stringnums.EOL[0];
            words    = input.Split(new[] { ' ', '\t', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            maxWords = (int)words.Count();
            if (maxWords < 2)
            {
                break;               // EOL is always appended
            }
            // debugging / testharness feature: input a line number
            if (maxWords == 2 && Int32.TryParse(words[0], out subjectAt))
            {
                Console.WriteLine(TestHarness.testlines[--subjectAt * 3]);
                Console.WriteLine(TestHarness.testlines[subjectAt * 3 + 1]);
                Console.WriteLine(TestHarness.testlines[subjectAt * 3 + 2]);
                continue;
            }

            // meta / macro command: tell the compiler to run another file.
            if (maxWords == 3 && words[0] == "regard" && words[1].StartsWith("__litstring"))
            {
                TestHarness.loadTestScript(Say(words[1]));
                continue;
            }

            // initialize vars
            index       = 0;
            definedVerb = "";
            preposition = "";
            method_being_constructed = new multimethod()
            {
                prompt = prompt, question = ""
            };
            //method_being_constructed.prompt = prompt;
            subjectAt              = -1;
            isQuestion             = false;
            incarnations           = null;
            listType               = null;
            IdentEndsAt            = maxWords;
            just_declared_new_type = false;

            // Absorb any prepositions at the beginning, as in "To give..." or "To boldly go..." or "To a person give...", etc.
            while (stringnums.prepositions.Contains(words[index]))
            {
                if (preposition != "")
                {
                    preposition += " ";
                }
                preposition += words[index++];
            }

            // if the first word(s) indicate a question, read it.
            //method_being_constructed.question = "";

            /*if (stringnums.QuestionWords.Contains(words[index]))
             * {
             *  string question = "";
             *  while (stringnums.QuestionWords.Contains(words[index]))
             *  {
             *      if (question != "") question += " ";
             *      question += words[index++];
             *  }
             *  incarnations = FindVerb(words[index]); // Catches "What is.." but not "Which car is..."
             *  method_being_constructed.question = question;
             *  isQuestion = true;
             * }*/

            // if first word(s) indicated a subject, read it
            if (stringnums.DefiniteArticles.Contains(words[index]) || stringnums.IndefiniteArticles.Contains(words[index]) || stringnums.ListDeterminers.Contains(words[index]) || words[index].EndsWith("ing") || (method_being_constructed.question != "" && incarnations == null))
            {
                ParseSubject(words);
            }

            if (prompt >= 37)
            {
                Console.WriteLine();
            }

            // Regardless, parse the predicate:  a verb and the nouns that go with.
            incarnations = PredicateDefinition(words);

            // If we haven't found a verb yet, but we do have a subject, look for the verb in the subject's name.
            if (incarnations == null && subjectAt >= 0)
            {
                string[] subnames = method_being_constructed.signature[subjectAt].noun.name.Split(' ');
                for (int i = subnames.Count() - 1; i >= 0; i--)
                {
                    index--;
                    incarnations = FindMainVerb(subnames[i]);
                    if (incarnations == null)
                    {
                        continue;
                    }

                    // Ah, there's the verb. Shorten the subject's name, and try parsing the predicate again from this index position.
                    definedVerb = subnames[i];
                    string newname = subnames[0];
                    for (int j = 1; j < i; j++)
                    {
                        newname += " " + subnames[j];
                    }
                    method_being_constructed.signature[subjectAt].noun.name = newname;
                    Console.WriteLine("  oops; verb is '{1}' and subject is '{0}'", newname, definedVerb);
                    incarnations = PredicateDefinition(words);
                    break;
                }
            }

            // If we still don't have a verb, we're going to have to search for it the long way.
            if (incarnations == null)
            {
                int savedIndex = index;
                while (incarnations == null && index < maxWords - 1 && !stringnums.EndsInfinitiveDefinition.Contains(words[index]))
                {
                    incarnations = FindMainVerb(words[++index]); // this is an expensive loop
                }
                if (incarnations != null)
                {
                    // ah, found it. There must be a subject in front of it...
                    definedVerb = words[index];
                    IdentEndsAt = index;
                    index       = 0; // back to first word of sentence
                    if (ParseSubject(words) == null)
                    {
                        method_being_constructed.signature.Add(new term(incarnations));
                        Console.Write("ERROR: verb is '{0}' but I don't know what to do with the subject: ", definedVerb);
                        for (int i = savedIndex; i < IdentEndsAt; i++)
                        {
                            Console.Write("{0} ", words[i]);
                        }
                        Console.WriteLine();
                        method_being_constructed.problems++;
                        multimethods.Add(method_being_constructed);
                        continue;
                    }
                    index++;                                            // advance past verb
                    IdentEndsAt = (int)words.Count();                   // un-set the hint
                    var mm = PredicateDefinition2(words, incarnations); // and finish the predicate as normal
                    multimethods.Add(mm);
                }
            }

            // If we STILL don't have a verb, abort this sentence.
            if (incarnations == null)
            {
                method_being_constructed.signature.Add(new term("..."));
                Console.Write("ERROR: I couldn't find a verb in: ");
                for (int i = 0; i < index; i++)
                {
                    Console.Write("{0} ", words[i]);
                }
                Console.WriteLine();
                method_being_constructed.problems++;
                multimethods.Add(method_being_constructed);
                continue;
            }

            //if (prompt == 32)
            //    Console.WriteLine("debug");

            // OK, we have a verb, and processed the rest of the definition with it.  We should be at a marker separating
            // the function head from the function body.  Or if it's a type/struct/object definition, we're at the end of
            // the sentence entirely.
            method_being_constructed.fully_parsed = stringnums.EOL.Contains(words[index]);
            if (stringnums.EndsInfinitiveDefinition.Contains(words[index]))
            {
                index++; // advance past the comma, colon, BY, VIA, MEANS, or whatever separates head from body
            }
            else if (words[index] != ".")
            {
                Console.WriteLine("I didn't expect this definition of '{1}' end with a '{0}'", words[index], definedVerb);
                method_being_constructed.problems++;
                continue;
            }

            // If we had a valid definition, save away its body. We can't parse the bodies until we read all the heads.
            // That's because what names, esp. parameter names and other function invocations, that appear in the bodies
            // aren't even known yet.
            if (!method_being_constructed.fully_parsed)
            {
                method_being_constructed.body = new List <string>();
                while (index < maxWords - 1 && !stringnums.EOL.Contains(words[index]))
                {
                    method_being_constructed.body.Add(words[index++]);  //ParseParameterInvocation(words);
                }
            }


            // for case of "X is Y..."
            // if the subject is already a type, and is now being used with "IS" again,
            // Ensure we don't use a known type with "is" unless
            // 1) there's a "when", or
            // 2) the subject is "the" instance of the type, or
            // 3) the subject is a gerund phrase (function type), so the predicate is a categorical name, a "class" or "name of enum" for signatures
            if (subjectAt != -1 && incarnations._en == "been" && method_being_constructed.fully_parsed)
            {
                parameter theSubject = method_being_constructed.signature[subjectAt].noun;
                if (just_declared_new_type && theSubject.art == Article.the)
                {
                    Console.WriteLine("  global variable or singleton instance '{0}' created", theSubject.name);
                    PermanentDataSegment.Add(theSubject);
                }
                else if (theSubject.isAggregate && method_being_constructed.signature.Count == 3)
                {   // "Xing... is Y." so define Y as a category for verbs
                    var ident   = method_being_constructed.signature[2].which == PartsOfSpeech.noun ? method_being_constructed.signature[2].noun.name : method_being_constructed.signature[2].preposition;
                    var newType = CreateNewType(ident, StandardType.homogene);
                    Console.WriteLine("  assuming '{0}' categorizes verbs", ident);
                }
                else if (!just_declared_new_type)
                {
                    if (theSubject.type == StandardType.anything)
                    {
                        Console.WriteLine("  ERROR: I have no idea what a '{0}' is. It could be anything.", theSubject.name);
                    }
                    else
                    {
                        Console.WriteLine("  ERROR: trying to re-define the type '{0}'", NameOfType(theSubject.type));
                    }
                    method_being_constructed.problems++;
                }
            }

            // Create the various names for each parameter in the new method.
            // This isn't perfect because we don't know where a noun phrase ends and where adverbs and verbs begin.
            // We'll keep it all as the possible noun phrase, but when we start parsing the body, we'll look at
            // what the parameters are actually called in there. Then we can shorten our parameter names to match
            // sensibly.
            TheGiveSomebodyItException = DirectObjectPlacement.not_there_yet;
            for (int i = 0; i < method_being_constructed.signature.Count; i++)
            {
                if (method_being_constructed.signature[i].which == PartsOfSpeech.noun)
                {
                    term      newterm  = method_being_constructed.signature[i];
                    parameter oldparam = newterm.noun;
                    newterm.noun = NamedParameter(oldparam, incarnations, (i == subjectAt));
                    method_being_constructed.signature[i] = newterm;
                }
                else if (method_being_constructed.signature[i].which == PartsOfSpeech.verb)
                {
                    TheGiveSomebodyItException = DirectObjectPlacement.not_there_yet;
                }
            }

            // Now we should be at the end of line: a period, question mark, or exclamation mark
            // If not, throw a helpful error.
            method_being_constructed.problems++;
            if (index >= words.Count())
            {
                Console.WriteLine("COMPILER ERROR: EOL eaten: index too high");
            }
            else if (words[index] != "ENDOFINPUT" && words[index] != ".")
            {
                if (index < words.Count())
                {
                    Console.WriteLine("  ERROR: I wasn't expecting '{0}' there, but rather, the end of the sentence.", words[index]);
                }
                else
                {
                    Console.WriteLine("COMPILER ERROR: EOL eaten");
                }
            }
            else
            {
                method_being_constructed.problems--;
            }


            // Sentence processed. Get next sentence
        }

        TestSignatures();
        Pass2ResolveImplicitTypesAndCreateMultimethodDictionary();
        Pass3MethodBodies();
        VerifyAbstractSyntaxTree();
        CodeGeneration();
    }
        private void Add_Term_Click(object sender, RoutedEventArgs e)
        {
            BindingExpression timeFromV  = tpTimeFrom.GetBindingExpression(TimePicker.TextProperty);
            BindingExpression timeUntilV = tpTimeUntil.GetBindingExpression(TimePicker.TextProperty);

            if (tpTimeFrom.SelectedTime == null)
            {
                AddError(timeFromV, "Morate unijeti vrijeme pocetka");
                return;
            }
            if (tpTimeUntil.SelectedTime == null)
            {
                AddError(timeUntilV, "Morate unijeti vrijeme kraja");
                return;
            }

            RemoveError(timeFromV);
            RemoveError(timeUntilV);

            var obj       = atbHallSearch.SelectedItem as string;
            var dates     = calendar.SelectedDates;
            var note      = notes.Text;
            var timeFrom  = (DateTime)tpTimeFrom.SelectedTime;
            var timeUntil = (DateTime)tpTimeUntil.SelectedTime;

            if (timeFrom > timeUntil)
            {
                AddError(timeUntilV, "Morate unijeti validno vrijeme kraja");
                return;
            }
            else
            {
                RemoveError(timeUntilV);
            }



            TimeSpan timeFromTS  = new TimeSpan(timeFrom.Hour, timeFrom.Minute, timeFrom.Second);
            TimeSpan timeUntilTS = new TimeSpan(timeUntil.Hour, timeUntil.Minute, timeUntil.Second);
            hall     newHall     = null;

            if (obj != null)
            {
                newHall = hall.SelectById(halls.FirstOrDefault(h => h.Value.Equals(obj)).Key);
            }
            if (newHall != null)
            {
                if (dates != null)
                {
                    if (ChangeTerm)
                    {
                        term selected = (term)termDatagrid.SelectedItem;
                        int  index    = termIndex;
                        var  newTerm  = new term(newHall.id, (DateTime)calendar.SelectedDate, timeFromTS, timeUntilTS, itemDatagrid.Items.Cast <item_list>().ToList(), note);
                        if (term.SelectAll().Where(t => t.hall_id == ((term)newTerm).hall_id && t.rental_date.CompareTo(((term)newTerm).rental_date) == 0 &&
                                                   t.rent_time_end.CompareTo(((term)newTerm).rent_time_start) == 1).ToList().Count > 0)
                        {
                            newTerm.status = true;
                        }
                        terms[terms.IndexOf(selected)] = newTerm;
                        termDatagrid.Items.Refresh();
                        ChangeTerm = false;
                    }
                    else
                    {
                        terms = new ObservableCollection <term>();
                        dates.ToList().ForEach(d => {
                            List <item_list> items = new List <item_list>();
                            itemDatagrid.Items.Cast <item_list>().ToList().ForEach(i => items.Add(new item_list(i.item_id, i.quantity)));
                            var newTerm = new term(newHall.id, d, timeFromTS, timeUntilTS, items, note);
                            if (term.SelectAll().Where(t => t.hall_id == ((term)newTerm).hall_id && t.rental_date.CompareTo(((term)newTerm).rental_date) == 0 &&
                                                       t.rent_time_end.CompareTo(((term)newTerm).rent_time_start) == 1).ToList().Count > 0)
                            {
                                newTerm.status = true;
                                terms.Insert(0, newTerm);
                            }
                            else
                            {
                                terms.Add(newTerm);
                            }
                        });
                        termDatagrid.ItemsSource = terms;
                        expander.IsExpanded      = false;
                    }
                    if (terms.Count > 0 && terms.Where(t => t.status == true).ToList().Count > 0)
                    {
                        lbTermError.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        lbTermError.Visibility = Visibility.Hidden;
                    }
                    itemDatagrid.Items.Clear();
                    tbHallSearch.Text        = "";
                    txtCalendar.Text         = "Odaberite datum";
                    tpTimeFrom.SelectedTime  = null;
                    tpTimeUntil.SelectedTime = null;
                    notes.Text = "";
                }
            }
        }
Esempio n. 11
0
            public multi(string line)
            {
                //先分割成多個 basic
                string[] parts = line.Split(';');
                basics = new IRunnable[parts.Length];

                //然後就每一個 basic 進行分類
                for (int i = 0; i < parts.Length; i++)
                {
                    if (IsComment(parts[i]))
                    {
                        basics[i] = new empty();
                    }
                    else if (IsTerm(parts[i]))
                    {
                        basics[i] = new term(parts[i].Trim());
                    }
                    else if (IsExec(parts[i]))
                    {
                        basics[i] = new exec(parts[i].Trim());
                    }
                    else
                    {
                        basics[i] = new decla(parts[i].Trim());
                    }
                }
            }
Esempio n. 12
0
 var(term, operatorTable) = termAndOperatorTableFactory(Rec(() => expr));
Esempio n. 13
0
        public void lexemAnalyse(string expression)
        {
            string token = "";
            Token  tok;
            term   currentTerm = term.none;

            this.terms = new List <Token>();

            for (int i = 0; i < expression.Length; i++)
            {
                if (Char.IsNumber(expression[i]))  //IsDigit
                {
                    if ((currentTerm == term.negotive) || (currentTerm == term.number))
                    {
                        token      += expression[i];
                        currentTerm = term.number;
                    }
                    else if ((currentTerm != term.none) && (currentTerm != term.whitespace))
                    {
                        tok       = new Token();
                        tok.value = token;
                        tok.type  = currentTerm;
                        this.terms.Add(tok);
                        token       = expression[i].ToString();
                        currentTerm = term.number;
                    }
                    else
                    {
                        token       = expression[i].ToString();
                        currentTerm = term.number;
                    }
                }
                else if (Char.IsLetter(expression[i]))
                {
                    if (currentTerm == term.number)
                    {
                        //this.terms.Add("*");
                        tok       = new Token();
                        tok.value = token;
                        tok.type  = currentTerm;
                        this.terms.Add(tok);
                        tok       = new Token();
                        tok.value = "*";
                        tok.type  = term.operation;
                        this.terms.Add(tok);
                        token       = expression[i].ToString();
                        currentTerm = term.letter;
                    }
                    else if ((currentTerm == term.letter) || (currentTerm == term.multiline))
                    {
                        token      += expression[i].ToString();
                        currentTerm = term.multiline;
                    }
                    else if ((currentTerm == term.leftbracket) || (currentTerm == term.operation))
                    {
                        tok       = new Token();
                        tok.value = token;
                        tok.type  = currentTerm;
                        this.terms.Add(tok);
                        token       = expression[i].ToString();
                        currentTerm = term.letter;
                    }
                    else if (currentTerm == term.rightbracket)
                    {
                        tok       = new Token();
                        tok.value = token;
                        tok.type  = currentTerm;
                        this.terms.Add(tok);
                        tok       = new Token();
                        tok.value = "*";
                        tok.type  = term.operation;
                        this.terms.Add(tok);
                        token       = expression[i].ToString();
                        currentTerm = term.letter;
                    }
                    else if ((currentTerm == term.none) || (currentTerm == term.whitespace))
                    {
                        token       = expression[i].ToString();
                        currentTerm = term.letter;
                    }
                    else
                    {
                        token += expression[i];
                    }
                }
                else if (Char.IsWhiteSpace(expression[i]))
                {
                    if ((currentTerm != (int)term.none) && (currentTerm != term.whitespace))
                    {
                        tok       = new Token();
                        tok.value = token;
                        tok.type  = currentTerm;
                        this.terms.Add(tok);
                        token       = "";
                        currentTerm = term.whitespace;
                    }
                }
                else if (Char.IsSymbol(expression[i]) || (expression[i] == '*') || (expression[i] == '/'))
                {
                    if ((currentTerm == term.number) || (currentTerm == term.letter) || (currentTerm == term.rightbracket) || (currentTerm == term.multiline))
                    {
                        tok       = new Token();
                        tok.value = token;
                        tok.type  = currentTerm;
                        this.terms.Add(tok);
                        token       = expression[i].ToString();
                        currentTerm = term.operation;
                    }
                    else
                    {
                        token       = expression[i].ToString();
                        currentTerm = term.operation;
                    }
                }
                else if (expression[i] == '-')
                {
                    if ((currentTerm == term.number) || (currentTerm == term.letter) || (currentTerm == term.rightbracket))

                    {
                        tok       = new Token();
                        tok.value = token;
                        tok.type  = currentTerm;
                        this.terms.Add(tok);
                        token       = expression[i].ToString();
                        currentTerm = term.operation;
                    }
                    else if (currentTerm == term.leftbracket)
                    {
                        tok       = new Token();
                        tok.value = token;
                        tok.type  = currentTerm;
                        this.terms.Add(tok);
                        token       = expression[i].ToString();
                        currentTerm = term.negotive;
                    }
                    else if (currentTerm != (int)term.none)
                    {
                        token       = expression[i].ToString();
                        currentTerm = term.operation;
                    }
                    else
                    {
                        token       = expression[i].ToString();
                        currentTerm = term.negotive;
                    }
                }
                else if (expression[i] == ',')
                {
                    if (currentTerm == term.number)

                    {
                        token += expression[i].ToString();
                    }
                }
                else if (expression[i] == '(')
                {
                    if ((currentTerm == term.number) || (currentTerm == term.letter))


                    {
                        tok       = new Token();
                        tok.value = token;
                        tok.type  = currentTerm;
                        this.terms.Add(tok);
                        tok       = new Token();
                        tok.value = "*";
                        tok.type  = term.operation;
                        this.terms.Add(tok);
                        token       = expression[i].ToString();
                        currentTerm = term.leftbracket;
                    }
                    else if ((currentTerm == term.operation) || (currentTerm == term.multiline))
                    {
                        tok       = new Token();
                        tok.value = token;
                        tok.type  = currentTerm;
                        this.terms.Add(tok);
                        token       = expression[i].ToString();
                        currentTerm = term.leftbracket;
                    }
                    else if ((currentTerm == term.none) || (currentTerm == term.whitespace))
                    {
                        token       = expression[i].ToString();
                        currentTerm = term.leftbracket;
                    }
                }
                else if (expression[i] == ')')
                {
                    if ((currentTerm == term.number) || (currentTerm == term.letter) || (currentTerm == term.rightbracket))

                    {
                        tok       = new Token();
                        tok.value = token;
                        tok.type  = currentTerm;
                        this.terms.Add(tok);
                        token       = expression[i].ToString();
                        currentTerm = term.rightbracket;
                    }
                }
                //else
                //    this.terms.Add(token);
            }
            tok       = new Token();
            tok.value = token;
            tok.type  = currentTerm;
            this.terms.Add(tok);
        }
Esempio n. 14
0
 Add(term, newName);
Esempio n. 15
0
 foreach (var(term, newName) in terms)