private bool TryParseWeekAndVenue(ITokenStream ts, ref Slot resultSlot) { if (!ts.PreviousToken().IsPositiveNumberThatContainDecimalPoint() || !ts.NextToken().IsPossiblyVenuValue()) { return(false); } resultSlot.WeekNumber = WeekNumber.Parse(ts.CurrentToken().Value()); resultSlot.Venue = ts.NextToken().Value(); return(true); }
protected override void ExtractToken(ITokenStream tokenStream) { tokenStream.GoToNextToken(); _startDate = ParseDate(tokenStream.CurrentToken().Value()); tokenStream.GoToNextToken(); _endDate = ParseDate(tokenStream.NextToken().Value()); }
private bool TryParseSubjectCode(ITokenStream ts, ref Slot resultSlot) { if (ts.CurrentToken().IsPossiblySubjectCode() && ts.NextToken().Value() == "-") { resultSlot.Code = ts.CurrentToken().Value(); return(true); } return(false); }
//private static Token newLine = new Token("\n"); /** * <returns> IPattern </returns> */ public Object Parse(ITokenStream tokenStream) { Token token; CAConfig pattern = new CAConfig(0, null); //LivingCell.DeadState);//Determine the size of the configuration! //CellState[,] patternState = new CellState[,]; IList <IList <CellState> > rows = new List <IList <CellState> >(); IList <CellState> row = null; Boolean rowOpened = false; int rowIndex = 0; int columnIndex = 0; while ((token = tokenStream.NextToken()) != null) { if (token.Equals(stateSeparator)) { //token=tokenStream.NextToken(); //do nothing } else if (token.Equals(rowStart)) //init a new row { if (rowOpened) { throw new InvalidOperationException(string.Format("Missing enclosing bracket! Please, enclose the row, before creating a new one")); } row = new List <CellState>(); rowOpened = true; rowIndex++; columnIndex = 0; } else if (token.Equals(rowEnd)) //add the existing row to the list of rows { rows.Add(row); rowOpened = false; } else if (!char.IsWhiteSpace(token.ToString(), 0)) //State Token { if (row == null || !rowOpened) { throw new InvalidOperationException("You should define a cell state within a Row. Use the following format: {D,A,D,D} "); } CellState cellState = null;//CellState.ValueOf(token.ToString()); row.Add(cellState); pattern.AddCellState(null, cellState); columnIndex++; } } return(pattern); }
public Word ParseWord(String wordSource) { Word word = new Word(); //using the lexer to parse the character sequence into symbols ITokenStream tokenStream = lexer.Analyze(wordSource); Token nextToken = null; while ((nextToken = tokenStream.NextToken()) != null) { word.Append(Symbol.valueOf(nextToken.ToString()));//in this case a token = a symbol } return(word); }
private bool TryParseStartTime(ITokenStream ts, ref Slot resultSlot) { if (!ts.CurrentToken().IsTime()) { return(false); } if (!ts.PreviousToken().IsDay()) { return(false); } resultSlot.StartTime = Time.CreateTime_12HourFormat(ts.CurrentToken().Value(), ts.NextToken().Value()); return(true); }
private bool TryParseEndTime(ITokenStream ts, ref Slot resultSlot) { if (ts.CurrentToken().IsTime() && ts.PreviousToken().Value() == "-") { resultSlot.EndTime = Time.CreateTime_12HourFormat(ts.CurrentToken().Value(), ts.NextToken().Value()); return(true); } return(false); }
/// <summary> /// Gets the next token /// </summary> protected void GetNextToken() { currentToken = stream.NextToken(); }
protected override bool HaltingCondition(ITokenStream ts) { return (ts.CurrentToken().Value().ToLower() == "user" && ts.NextToken().Value().ToLower() == "guide"); }