コード例 #1
0
 public override int VisitCell([NotNull] GrammarParser.CellContext context)
 {
     try
     {
         string cellRef = context.GetText();
         int    column  = 0;
         while (65 <= (int)cellRef[column] && (int)cellRef[column] <= 90)
         {
             column++;
         }
         int colNum = ColumnSys26.Sys26ToNum(cellRef.Substring(0, column)) - 1;
         int rowNum = int.Parse(cellRef.Substring(column)) - 1;
         ElectronicTableCell cell = CalculatingCell.Table.Cell(rowNum, colNum);
         if (cell.CurrentlyCalculating)
         {
             var ex = new Exception();
             ex.Data.Add("Type", "cell loop");
             throw ex;
         }
         cell.Depended.Add(CalculatingCell);
         CalculatingCell.Dependecies.Add(cell);
         cell.CurrentlyCalculating = true;
         int ans = cell.Count();
         cell.CurrentlyCalculating = false;
         Console.WriteLine($"Value of {cellRef} is {ans}");
         return(ans);
     }
     catch
     {
         throw;
     }
 }
コード例 #2
0
 /// <summary>
 /// Visit a parse tree produced by the <c>Cell</c>
 /// labeled alternative in <see cref="GrammarParser.expression"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitCell([NotNull] GrammarParser.CellContext context)
 {
     return(VisitChildren(context));
 }
コード例 #3
0
 /// <summary>
 /// Exit a parse tree produced by the <c>Cell</c>
 /// labeled alternative in <see cref="GrammarParser.expression"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitCell([NotNull] GrammarParser.CellContext context)
 {
 }