public void LogError(EErrorCode inErrorCode, CToken inToken) { _error_count++; string text = string.Format("{0} [{3}]. Token {1}. Position {2}", inErrorCode, inToken, inToken.Position, _parsing_file); _printer.LogError(text); }
public static void LoadBuiltins(CProgram program) { ImportType(program, SearchAssembliesForType(program, "System.Object"), BuiltIns.Variant); ImportType(program, SearchAssembliesForType(program, "System.String"), BuiltIns.String); CClass vtype = program.FindClass("System.ValueType"); ImportType(program, SearchAssembliesForType(program, "System.Byte"), BuiltIns.Byte); BuiltIns.Byte.ForceSetBaseClass(vtype); ImportType(program, SearchAssembliesForType(program, "System.Int32"), BuiltIns.Int32); BuiltIns.Int32.ForceSetBaseClass(vtype); ImportType(program, SearchAssembliesForType(program, "System.Int64"), BuiltIns.Int64); BuiltIns.Int64.ForceSetBaseClass(vtype); ImportType(program, SearchAssembliesForType(program, "System.Char"), BuiltIns.Character); BuiltIns.Character.ForceSetBaseClass(vtype); ImportType(program, SearchAssembliesForType(program, "System.Boolean"), BuiltIns.Boolean); BuiltIns.Boolean.ForceSetBaseClass(vtype); ImportType(program, SearchAssembliesForType(program, "System.DateTime"), BuiltIns.Date); BuiltIns.Date.ForceSetBaseClass(vtype); ImportType(program, SearchAssembliesForType(program, "System.Double"), BuiltIns.Double); BuiltIns.Double.ForceSetBaseClass(vtype); BuiltIns.Variant.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(BuiltIns.Variant, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); BuiltIns.Object.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(BuiltIns.Object, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); BuiltIns.String.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(BuiltIns.String, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); BuiltIns.Byte.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(BuiltIns.Byte, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); BuiltIns.Int32.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(BuiltIns.Int32, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); BuiltIns.Int64.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(BuiltIns.Int64, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); BuiltIns.Character.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(BuiltIns.Character, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); BuiltIns.Boolean.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(BuiltIns.Boolean, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); BuiltIns.Date.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(BuiltIns.Date, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); BuiltIns.Double.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(BuiltIns.Double, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); }
private void SearchCommand_Executing(object sender, ExecutingEventArgs e) { if (String.IsNullOrWhiteSpace(ResultCollection.SearchContent) || IsLoading) { return; } StatusInfo = String.Format("Searching '{0}' ...", ResultCollection.SearchContent); StatusColor = 1; if (IsSearching) { CToken.Cancel(); CToken = new CancellationTokenSource(); } IsSearching = true; var data = VectorFinder.FindWord(ResultCollection.SearchContent, CToken.Token); ResultCollection.ResultList.Clear(); if (data == null) { return; } int i = 0; foreach (var record in data) { ResultCollection.ResultList.Add(record); record.Index = String.Format("{0}.", ++i); } IsBeginSearching = true; ReloadSignal = true; FindRelations(CToken.Token); }
static void Main(string[] args) { // Print all the tokens serials using CRSAtoken Service class .serials method // Check if it requires a PIN // Extract all the tokens CToken token; Console.WriteLine("[+] Initialized the CRsaTokenService "); String[] serials = tokenService.Serials.Split(','); if (serials.Length > 0) { Console.WriteLine("[+] Found {0} tokens", serials.Length); foreach (String serial in serials) { token = new CToken(); token.Init(serial); PrintToken(token); } } else { Console.WriteLine("[-] No tokens found "); } }
public string ObtenerToken(string url, string credenciales) { CToken tokens = new CToken(); HttpWebRequest solicitud = WebRequest.Create(url) as HttpWebRequest; solicitud.Method = "POST"; solicitud.ContentType = "application/x-www-form-urlencoded"; try { byte[] byteArray = Encoding.UTF8.GetBytes(credenciales); Stream dataStream = solicitud.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); HttpWebResponse Repuesta = solicitud.GetResponse() as HttpWebResponse; StreamReader Transmisor = new StreamReader(Repuesta.GetResponseStream()); string Resultado = Transmisor.ReadToEnd(); tokens = JsonConvert.DeserializeObject <CToken>(Resultado); } catch (Exception e) { return(e.Message); } return(tokens.access_token); }
private async Task Login_ClickedAsync(object sender, EventArgs e) { CUser user = new CUser(); user.SetUser(txtPassword.Text, txtUserName.Text); if (user.ValidateText()) { await DisplayAlert("Login", "Login was successful.", "OK"); //var result = await App.RestService.Login(user); var result = new CToken(); result.AccessToken = ""; if (result.AccessToken != null) { //App.UserDatabase.SaveUser(user); //App.TokenDatabase.SaveToken(result); if (Device.OS == TargetPlatform.Android) { Application.Current.MainPage = new NavigationPage(new Dashboard()); } else if (Device.OS == TargetPlatform.iOS) { await Navigation.PushModalAsync(new NavigationPage(new Dashboard())); } } } else { await DisplayAlert("Login", "Login was unsuccessful, empty username or password.", "OK"); } }
public override string ToString() { return(String.Format( "MacroConstant : {0}", CToken.Stringify(this.Replacement) )); }
public CParserException CParserException(CToken Token, string Format, params object[] Arguments) { var Message = String.Format(Format, Arguments); var PositionInfo = this.LastFileLineMap.Translate(Token); return(new CParserException(this, PositionInfo, Message)); }
static BuiltIns() { /* These aren't fully resolved; we need to use Cecil to load the appropriate .NET type defitinions in. * See ClrImporter.LoadBuiltins. */ Variant = new CClass("__Variant", null); Byte = new CClass("Byte", false); String = new CClass("String", true); Int32 = new CClass("Int32", true); Int64 = new CClass("Int64", true); Character = new CClass("Character", false); Boolean = new CClass("Boolean", true); Date = new CClass("Date", true); Double = new CClass("Double", true); Object = Variant; DbNull = new CClass("DbNull", false); Nothing = new CClass("Nothing", false); Nothing.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); Void = new CClass("__Void", false); FunctionPlaceHolder = new CClass("__FunctionPlaceHolder", false); FunctionPlaceHolder.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); SubPlaceHolder = new CClass("__SubPlaceHolder", false); SubPlaceHolder.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); SetupGlobalTypes(); CArgumentList arrArgs = new CArgumentList(); arrArgs.Add(new CArgument(CToken.Keyword(null, "byval"), CToken.Identifer(null, "arglist"), new CTypeRef(null, Variant))); Array = new CFunction(CToken.Identifer(null, "Array"), "Array", "array", TokenTypes.visPublic, FunctionType.Function, arrArgs, new CTypeRef(null, new CArrayType(new CTypeRef(null, Variant), 1))); Array.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); CArgumentList dicArgs = new CArgumentList(); dicArgs.Add(new CArgument(CToken.Keyword(null, "byval"), CToken.Identifer(null, "arglist"), new CTypeRef(null, Variant))); Dictionary = new CFunction(CToken.Identifer(null, "Dictionary"), "Dictionary", "dictionary", TokenTypes.visPublic, FunctionType.Function, dicArgs, new CTypeRef(null, new CDictionaryType(new CTypeRef(null, Variant)))); Dictionary.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); CArgumentList refArgs = new CArgumentList(); refArgs.Add(new CArgument(CToken.Keyword(null, "byval"), CToken.Identifer(null, "func"), new CTypeRef(null, BuiltIns.String))); GetRef = new CFunction(CToken.Identifer(null, "GetRef"), "GetRef", "getref", TokenTypes.visPublic, FunctionType.Function, refArgs, new CTypeRef(null, BuiltIns.FunctionPlaceHolder)); GetRef.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); // add string ienumerator interface CToken ifaceName = CToken.Identifer(null, "System.Collections.Generic.IEnumerable`1<char>"); CInterface iface = new CInterface(ifaceName, ifaceName); iface.GenericParameters.Add(Character); String.AddInterface(new CTypeRef(null, iface)); }
public void TestCreateKeyword() { var token = CToken.Create(new Token <TokenType> { Type = TokenType.SYMBOL, Value = "while" }); Assert.That(token.Type, Is.EqualTo(CTokenType.KEYWORD)); }
public void TestCreateEnumSpecifier() { var token = CToken.Create(new Token <TokenType> { Type = TokenType.SYMBOL, Value = "enum" }); Assert.That(token.Type, Is.EqualTo(CTokenType.ENUM_SPECIFIER)); }
public void TestCreateStructureSpecifier() { var token = CToken.Create(new Token <TokenType> { Type = TokenType.SYMBOL, Value = "struct" }); Assert.That(token.Type, Is.EqualTo(CTokenType.STRUCTURE_SPECIFIER)); }
public void TestCreateMainProgramTargetIdentifierToken() { var token = CToken.Create(new Token <TokenType> { Type = TokenType.SYMBOL, Value = "main_program" }); Assert.That(token.Type, Is.EqualTo(CTokenType.TARGET_IDENTIFIER)); }
public void TestCreateStringLiteralToken() { var token = CToken.Create(new Token <TokenType> { Type = TokenType.STRING_LITERAL }); Assert.That(token.Type, Is.EqualTo(CTokenType.STRING_LITERAL)); }
public void TestCreateNonPPDirectiveToken() { var token = CToken.Create(new Token <TokenType> { Type = TokenType.SYMBOL, Value = "ifdef" }); Assert.That(token.Type, Is.EqualTo(CTokenType.SYMBOL)); }
public void TestCreateSymbolToken() { var token = CToken.Create(new Token <TokenType> { Type = TokenType.SYMBOL }); Assert.That(token.Type, Is.EqualTo(CTokenType.SYMBOL)); }
public void TestCreatePunctuatorToken() { var token = CToken.Create(new Token <TokenType> { Type = TokenType.PUNCTUATOR }); Assert.That(token.Type, Is.EqualTo(CTokenType.PUNCTUATOR)); }
public void TestCreateCharLiteralToken() { var token = CToken.Create(new Token <TokenType> { Type = TokenType.CHAR_LITERAL }); Assert.That(token.Type, Is.EqualTo(CTokenType.CHAR_LITERAL)); }
public void TestCreateTypeSpecifier() { var token = CToken.Create(new Token <TokenType> { Type = TokenType.SYMBOL, Value = "int" }); Assert.That(token.Type, Is.EqualTo(CTokenType.TYPE_SPECIFIER)); }
public void TestCreateNumericLiteralToken() { var token = CToken.Create(new Token <TokenType> { Type = TokenType.NUMERIC_LITERAL }); Assert.That(token.Type, Is.EqualTo(CTokenType.NUMERIC_LITERAL)); }
public void TestCreateTerminatorToken() { var token = CToken.Create(new Token <TokenType> { Type = TokenType.PUNCTUATOR, Value = ";" }); Assert.That(token.Type, Is.EqualTo(CTokenType.TERMINATOR)); }
public void TestCreatePPSymbolToken() { var token = CToken.Create(new Token <TokenType> { Type = TokenType.PUNCTUATOR, Value = "#" }); Assert.That(token.Type, Is.EqualTo(CTokenType.PP_SYMBOL)); }
static void PrintToken(CToken token) { int timeleft = 0; String currentCode = tokenService.getCurrentCode(token.serialNumber, "", out timeleft); Console.WriteLine("\n===== Token With Serial Number: {0}", token.serialNumber); Console.WriteLine("Token Code: {0} \nTimeleft: {1} \nUserId: {2} \nURL: {3}", currentCode, timeleft, token.userId, string.IsNullOrEmpty(token.url) ? "No URL" : token.url); }
public void ShowLine(CToken TokenCurrent) { var Position = TokenCurrent.Position; var Lines = Text.Split('\n'); Console.Error.WriteLine("{0}", Lines[Position.Row]); //throw new NotImplementedException(); }
public override string ToString() { return(String.Format( "MacroFunction({0}) : {1}", String.Join(",", Parameters.Select(Parameter => CToken.Stringify(Parameter))), CToken.Stringify(this.Replacement) )); }
internal CToken CreateToken(String rawvalue, String sValue, TokenTypes type, object additionalInfo) { String filename = filenamesrc == null ? null : filenamesrc.Filename; CToken result = new CToken(filename, -1, 0, "", type, sValue, rawvalue, false); result.AdditionalInfo = additionalInfo; return(result); }
private string ReplaceSimpleVariable(string Identifier) { switch (Identifier) { case "__FILE__": return(CToken.Stringify(CurrentFileName)); case "__LINE__": return(String.Format("{0}", Tokens.Current.Position.Row + 1)); } return(Identifier); }
public void TestMethod2() { var Token = new CToken() { Raw = @"""Hello World\n""", Type = CTokenType.String, }; Assert.AreEqual("Hello World\n", Token.GetStringValue()); }
public void TestCreateIfPPDirectiveToken() { var token = CToken.Create(new Token <TokenType> { Type = TokenType.SYMBOL, Value = "if" }, new Token <TokenType> { Type = TokenType.PUNCTUATOR, Value = "#" }); Assert.That(token.Type, Is.EqualTo(CTokenType.PP_DIRECTIVE)); }
public void TestPushToken() { var token = CToken.Create(new Token <TokenType>()); var m = new Mock <ITokenizer <TokenType> >(); var l = new CLexer(m.Object); l.PushToken(token); var otherToken = l.GetNextToken(); Assert.That(otherToken, Is.EqualTo(token)); }