/// <inheritdoc/> public Option <Token <TTokenType> > TryConsume(ICodeReader reader, DiagnosticList diagnostics) { if (reader is null) { throw new ArgumentNullException(nameof(reader)); } if (diagnostics is null) { throw new ArgumentNullException(nameof(diagnostics)); } var start = reader.Position; if (_spanTokenFactory is not null) { var match = GrammarTreeInterpreter.MatchSpan(reader, _grammarNode); if (match.IsMatch) { return(_spanTokenFactory(start, match, diagnostics)); } } else { var match = GrammarTreeInterpreter.MatchString(reader, _grammarNode); if (match.IsMatch) { return(_stringTokenFactory !(start, match, diagnostics)); } } return(Option.None <Token <TTokenType> >()); }
public static void WhenGivenNoMessageReturnAnEmptyString() { ICodeReader reader = IoC.Container.GetService <ICodeReader>(); var expected = ""; var actual = reader.DecryptMessage(""); Assert.Equal(expected, actual); }
public static string ParseTokenText(ICodeReader reader) { var offsetStart = reader.Offset; reader.ReadToken(); var offsetEnd = reader.Offset; return(reader.PeekTextReverse(offsetEnd - offsetStart)); }
public StandardAttributesSuggestion(DataTypes dataTypes, IElementContext targetElement, IElementContext parentElement, string attributeName, ICodeReader codeReader, IDictionary <string, string> namespaces) { _dataTypes = dataTypes; _targetElement = targetElement; _parentElement = parentElement; _attributeName = attributeName; _codeReader = codeReader; _namespaces = namespaces; }
/// <summary> /// Initializes a new delegate lexer. /// </summary> /// <param name="delegateTree"></param> /// <param name="endOfFileTokenType"></param> /// <param name="reader"></param> /// <param name="diagnostics"></param> public DelegateLexer( LexerDelegateTree <TTokenType> delegateTree, TTokenType endOfFileTokenType, ICodeReader reader, DiagnosticList diagnostics) : base(reader, diagnostics) { DelegateTree = delegateTree ?? throw new ArgumentNullException(nameof(delegateTree)); EndOfFileTokenType = endOfFileTokenType; }
/// <summary> /// Initializes a new lexer. /// You can call this directly but you shouldn't. /// Call <see cref="ModularLexerBuilder{TTokenType}.GetLexer(ICodeReader, DiagnosticList)"/> instead. /// </summary> /// <param name="tree"></param> /// <param name="endOfFileTokenType"></param> /// <param name="reader"></param> /// <param name="diagnostics"></param> public ModularLexer( LexerModuleTree <TTokenType> tree, TTokenType endOfFileTokenType, ICodeReader reader, DiagnosticList diagnostics) : base(reader, diagnostics) { ModuleTree = tree ?? throw new ArgumentNullException(nameof(tree)); EndOfFileTokenType = endOfFileTokenType; }
public static void WhenGivenSomeValidMorseCodeReturnTheMessage() { ICodeReader reader = IoC.Container.GetService <ICodeReader>(); string input = ".... . -.-- .--- ..- -.. ."; string expected = "HEY JUDE"; var actual = reader.DecryptMessage(input); Assert.Equal(expected, actual); }
public void Init() { this.codeReader = DataCenter.Default.DataReader.CodeReader; IList <string> catelogs = codeReader.GetAllCatelogs(); for (int i = 0; i < catelogs.Count; i++) { string catelog = catelogs[i]; AddCatelog(null, catelog); } }
public DataReader(string dataCenterUri) { this.dataStore = DataStoreFactory.CreateDataStore(dataCenterUri); this.codeReader = new CodeReader(dataStore.CreateInstrumentStore()); this.tradingDayReader = new CacheUtils_TradingDay(dataStore.CreateTradingDayStore().Load()); this.tradingSessionStore = dataStore.CreateTradingSessionStore(); this.tradingTimeStore = dataStore.CreateTradingTimeStore(); this.tickDataReader = new TickDataReader(dataStore, this); this.klineDataReader = new KLineDataReader(dataStore, this); this.timeLineDataReader = new TimeLineDataReader(this); this.mainContractReader = new MainContractReader(dataStore); }
public StartTagAttributeValueSuggestion( DataTypes dataTypes, IElementContext targetElement, IElementContext parentElement, IAttributeContext lastAttribute, ICodeReader codeReader, IDictionary <string, string> namespaceDeclarations) { _dataTypes = dataTypes; _targetElement = targetElement; _parentElement = parentElement; _lastAttribute = lastAttribute; _codeReader = codeReader; _namespaceDeclarations = namespaceDeclarations; }
public static IEnumerable <SuggestItem> GetSuggestions( ICompiler compiler, IContext context, int offset, ICodeReader codeReader) { var parentElement = context.TargetElement == null ? null : context.TargetElement.Parent; foreach (var defaultNamespace in Configuration.DefaultNamespaces.Concat(new [] { "Uno" })) { if (context.NamespaceDeclarations.ContainsKey(defaultNamespace)) { continue; } context.NamespaceDeclarations.Add(defaultNamespace, ""); } var dataTypes = new DataTypes(compiler, compiledTypes => ResolveUxClasses.GetUxClassTypes(context, compiledTypes, compiler.Data.IL)); switch (context.Type) { case ContextType.StartTagName: return(new StartTagNameSuggestion( dataTypes, parentElement, context.TargetElement, context.NamespaceDeclarations).Suggest()); case ContextType.StartTagAttributeName: return(new StartTagAttributeNameSuggestion( dataTypes, context.TargetElement, context.NamespaceDeclarations).Suggest()); case ContextType.StartTagAttributeValue: return(new StartTagAttributeValueSuggestion( dataTypes, context.TargetElement, parentElement, GetCurrentAttributeContext(context.TargetElement, offset), codeReader, context.NamespaceDeclarations).Suggest()); } return(Enumerable.Empty <SuggestItem>()); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); disconnectHandler = new Handler(new MyHandlerICallback(this)); var app = new App(); appHandler = (IApplicationHandler)app; codeReaderHandler = (ICodeReader)app; LoadApplication(app); }
/// <inheritdoc/> public Option <Token <TTokenType> > TryConsume(ICodeReader reader, DiagnosticList diagnostics) { if (reader is null) { throw new ArgumentNullException(nameof(reader)); } var start = reader.Position; reader.Advance(Prefix.Length); return(new Token <TTokenType>( _id, _type, new Range <int>(start, reader.Position), _isTrivia, _value, Prefix)); }
static void Main(string[] args) { Console.WriteLine("Enter your morse code and press enter."); var input = Console.ReadLine(); ICodeReader reader = IoC.Container.GetService <ICodeReader>(); var output = ""; try { output = reader.DecryptMessage(input); Console.WriteLine($"That translates to: {output}"); } catch (Exception ex) { Console.WriteLine($"Something went wrong... {ex.ToString()}"); } Console.ReadKey(); }
/// <inheritdoc/> public Option <Token <TTokenType> > TryConsume(ICodeReader reader, DiagnosticList diagnostics) { if (reader is null) { throw new ArgumentNullException(nameof(reader)); } var start = reader.Position; var result = _expression != null?reader.PeekRegex(_expression) : reader.PeekRegex(_regex !); if (result.Success) { reader.Advance(result.Length); return(new Token <TTokenType>( _id, _type, new Range <int>(start, reader.Position), _isTrivia, _converter != null ? _converter(result, diagnostics) : result.Value, result.Value)); } return(default);
/// <summary> /// Parses a regex expression from a reader. /// </summary> /// <param name="reader"></param> /// <param name="delimitator">The regex expression delimitator (if any).</param> /// <returns></returns> public static GrammarNode <Char> Parse(ICodeReader reader, Char?delimitator = null) => new RegexParser(reader, delimitator).MainParse();
void Window1_Loaded(object sender, RoutedEventArgs e) { Console.WriteLine("Window Loaded"); #if DEBUG //MessageBox.Show("Welkom bij de JOTARI!"); //MessageBox.Show("Welkom bij de JOTARI 2!"); #endif timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 1, 0); timer.Tick += new EventHandler(timer_Tick); timer.Start(); timer_Tick(null, null); Console.WriteLine("Creating ExcelDataReader"); excel = new ExcelDataReader(@"planning kinderen en leiding.xlsx"); Console.WriteLine("Creating ZBarInterface"); scanner = new ZBarInterface(); scanner.CodeRead += new CodeReadHandler(scanner_CodeRead); Console.WriteLine("Starting Scanner"); scanner.Start(); Console.WriteLine("Getting schedule from file"); schedule = excel.GenerateActivityTimeLines(36, 48);//GetSchedule(); #region fill comboboxes for (int k = 1; k <= 36; k++) { groupSelector.Items.Add("Klein" + k.ToString()); } for (int g = 1; g <= 48; g++) { groupSelector.Items.Add("Groot" + g.ToString()); } #endregion Keyboard.Focus(groupSelector); }
static bool restore(ICodeReader reader, int position) { reader.Restore(position); return(false); }
/// <summary> /// Initializes a new lexer. /// </summary> /// <param name="reader"></param> /// <param name="diagnostics"></param> protected BaseLexer(ICodeReader reader, DiagnosticList diagnostics) { this.Reader = reader; this.Diagnostics = diagnostics; }
/// <summary> /// Attempts to execute a transducer with content from a <see cref="StringCodeReader" />. If the /// state reached is not a terminal state, the reader is rewinded to it's initial position. /// </summary> /// <typeparam name="OutputT"></typeparam> /// <param name="transducer"></param> /// <param name="reader"></param> /// <param name="output"></param> /// <returns>Whether the state reached was a terminal state.</returns> public static Boolean TryExecute <OutputT>(this Transducer <Char, OutputT> transducer, ICodeReader reader, [MaybeNull] out OutputT output) { if (transducer is null) { throw new ArgumentNullException(nameof(transducer)); } if (reader is null) { throw new ArgumentNullException(nameof(reader)); } var start = reader.Position; TransducerState <Char, OutputT> state = transducer.InitialState; while (reader.Position != reader.Length) { if (!state.TransitionTable.TryGetValue(reader.Peek() !.Value, out TransducerState <Char, OutputT>?tmp)) { break; } state = tmp; reader.Advance(1); } if (state.IsTerminal) { output = state.Output; return(true); } reader.Restore(start); // Since the analyzer doesn't seems to obey [MaybeNull], we ignore the warning output = default; return(false); }
static bool restore(ICodeReader reader, int start) { reader.Restore(start); return(false); }
private RegexParser(ICodeReader reader, Char?delimitator) { this._reader = reader ?? throw new ArgumentNullException(nameof(reader)); this._delimitator = delimitator; }
public void Deserialize(ICodeReader input) { throw new NotImplementedException(); }
public static IEnumerable <KeyValuePair <string, string> > FindUXNameAttributes(ICodeReader codeReader) { var offset = codeReader.Offset; codeReader.Offset = 0; var nameAttributes = new Dictionary <string, string>(); var lastTagName = ""; var lastAttributeName = ""; while (codeReader.Offset < codeReader.Length) { switch (codeReader.PeekToken()) { case TokenType.StartTagName: lastTagName = ParseTokenText(codeReader); break; case TokenType.StartTagAttributeName: lastAttributeName = ParseTokenText(codeReader); break; case TokenType.StartTagAttributeValueText: string attributeValue = ParseTokenText(codeReader); if (lastAttributeName == "ux:Name") { nameAttributes.Add(lastTagName, attributeValue); } break; default: codeReader.ReadToken(); break; } } codeReader.Offset = offset; return(nameAttributes); }