public List <Track> getNewReleases() { TokenClass _Token = new TokenClass(); string token = _Token.getToken(); string url = "https://api.spotify.com/v1/recommendations?limit=40&market=US&seed_genres=rock%2C%20pop%2C%20indie"; var Authorization = _Token.currentToken; HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); webRequest.Method = "GET"; webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.Accept = "application/json"; webRequest.Headers.Add("Authorization:" + _Token.currentToken); webRequest.ContentLength = 0; HttpWebResponse resp = (HttpWebResponse)webRequest.GetResponse(); String json = ""; DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(RecommendationsClass)); using (Stream respStr = resp.GetResponseStream()) { using (StreamReader rdr = new StreamReader(respStr, Encoding.UTF8)) { json = rdr.ReadToEnd(); rdr.Close(); } } var recommendations = JsonConvert.DeserializeObject <Recommendation>(json).tracks; return(recommendations); }
public Token Expect(TokenClass clazz) { Token ret = null; if (Accept(clazz, ref ret)) { return(ret); } Token offender = ReadToken(); if (offender != null) { errorLog.AddError(ErrorType.ParserError, offender.Location, "Unexpected '{0}' (Expected '{1}')", offender.ToString(), Token.ClassToString(clazz)); } else { errorLog.AddError(ErrorType.ParserError, offender.Location, "Unexpected end of file (Expected {0})", Token.ClassToString(clazz)); throw new Exception(""); } return(new Token(clazz, "", Location)); }
private Token IncludeSpaces() { StringBuilder sString = new StringBuilder(); sString.Append(_CurrentChar); char c = (char)LA(1); while (c != 39) { sString.Append(c); Consume(); c = (char)LA(1); } Consume(); string sTemp = sString.ToString(); if (_TokenName.ContainsKey(sTemp.ToLower())) { TokenID id = (TokenID)_TokenName[sTemp.ToLower()]; TokenClass cls = (TokenClass)_TokenClass[id]; return(new Token(cls, id, sTemp)); } c = RemoveWhiteSpace(); if (c == '(') { return(new Token(TokenClass.CONTROL, TokenID.FUNCTION, sTemp)); } return(new Token(TokenClass.REFERENCE, TokenID.IDENTIFIER, sTemp)); }
// GET: Auth public async Task <ActionResult> fb(string code, string useremail) { var base64EncodedBytes = System.Convert.FromBase64String(useremail); var realuseremail = System.Text.Encoding.UTF8.GetString(base64EncodedBytes); using (var client = new HttpClient()) { var redirecturl = "http://webapplication16742.azurewebsites.net/auth/fb/" + useremail; var s1 = await client.GetStringAsync("https://graph.facebook.com/v2.3/oauth/access_token?client_id=619387381484849&redirect_uri=" + redirecturl + "&client_secret=1f22ecd5cfa27759fbf126531994531c&code=" + code); TokenClass token = JsonConvert.DeserializeObject <TokenClass>(s1); var s2 = await client.GetStringAsync("https://graph.facebook.com/v2.3/me?access_token=" + token.access_token); var fbme = JsonConvert.DeserializeObject <FbMe>(s2); var ac = new WebApplication1.Models.AccountInfo.SubAccount(); ac.provider = "fb"; ac.token = token.access_token; ac.useremail = realuseremail; ac.userid = fbme.id; ac.username = fbme.name; if (!TokenController.addTokenInternal(ac)) { return(HttpNotFound()); } } return(Redirect("/home/index?user=" + realuseremail)); }
private Token Identifier() { StringBuilder sString = new StringBuilder(); sString.Append(_CurrentChar); char c = (char)LA(1); while (char.IsLetterOrDigit(c) || c == '_') { sString.Append(c); Consume(); c = (char)LA(1); } string sTemp = sString.ToString(); //DebugTrace("Token =",sTemp); if (_TokenName.ContainsKey(sTemp.ToLower())) { TokenID id = (TokenID)_TokenName[sTemp.ToLower()]; TokenClass cls = (TokenClass)_TokenClass[id]; return(new Token(cls, id, sTemp)); } c = RemoveWhiteSpace(); if (c == '(') { return(new Token(TokenClass.CONTROL, TokenID.FUNCTION, sTemp)); } return(new Token(TokenClass.REFERENCE, TokenID.IDENTIFIER, sTemp)); }
public RTF(Stream stream) { source = new StreamReader(stream); text_buffer = new StringBuilder(1024); //pushed_text_buffer = new StringBuilder(1024); rtf_class = TokenClass.None; pushed_class = TokenClass.None; pushed_char = unchecked ((char)-1); line_num = 0; line_pos = 0; prev_char = unchecked ((char)-1); bump_line = false; font_list = null; charset_stack = null; cur_charset = new Charset(); destination_callbacks = new DestinationCallback(); class_callbacks = new ClassCallback(); destination_callbacks [Minor.OptDest] = new DestinationDelegate(HandleOptDest); destination_callbacks[Minor.FontTbl] = new DestinationDelegate(ReadFontTbl); destination_callbacks[Minor.ColorTbl] = new DestinationDelegate(ReadColorTbl); destination_callbacks[Minor.StyleSheet] = new DestinationDelegate(ReadStyleSheet); destination_callbacks[Minor.Info] = new DestinationDelegate(ReadInfoGroup); destination_callbacks[Minor.Pict] = new DestinationDelegate(ReadPictGroup); destination_callbacks[Minor.Object] = new DestinationDelegate(ReadObjGroup); }
//Get token from google OAUTH to get the user details private TokenClass GetAccesToken(string code) { string clientid = _config.GetSection("GoogleAuthentication").GetSection("ClinetID").Value; string clientsecret = _config.GetSection("GoogleAuthentication").GetSection("ClientSecret").Value; string redirection_url = _config.GetSection("GoogleAuthentication").GetSection("Redirect_URL").Value; string url = "https://accounts.google.com/o/oauth2/token"; string poststring = "grant_type=authorization_code&code=" + code + "&client_id=" + clientid + "&client_secret=" + clientsecret + "&redirect_uri=" + redirection_url + ""; var request = (System.Net.HttpWebRequest)WebRequest.Create(url); request.ContentType = "application/x-www-form-urlencoded"; request.Method = "POST"; UTF8Encoding utfenc = new UTF8Encoding(); byte[] bytes = utfenc.GetBytes(poststring); Stream outputstream = null; try { request.ContentLength = bytes.Length; outputstream = request.GetRequestStream(); outputstream.Write(bytes, 0, bytes.Length); } catch { } var response = (HttpWebResponse)request.GetResponse(); var streamReader = new StreamReader(response.GetResponseStream()); string responseFromServer = streamReader.ReadToEnd(); TokenClass obj = JsonConvert.DeserializeObject <TokenClass>(responseFromServer); return(obj); }
public Albums getNewReleases() { TokenClass _Token = new TokenClass(); string token = _Token.getToken(); string url = "https://api.spotify.com/v1/browse/new-releases?limit=48"; var Authorization = _Token.currentToken; HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); webRequest.Method = "GET"; webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.Accept = "application/json"; webRequest.Headers.Add("Authorization:" + _Token.currentToken); webRequest.ContentLength = 0; HttpWebResponse resp = (HttpWebResponse)webRequest.GetResponse(); String json = ""; DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(SpotifyNewReleasesClass)); using (Stream respStr = resp.GetResponseStream()) { using (StreamReader rdr = new StreamReader(respStr, Encoding.UTF8)) { json = rdr.ReadToEnd(); rdr.Close(); } } var album = JsonConvert.DeserializeObject <RootObject>(json).albums; return(album); }
protected void OverrideToken(Location loc, TokenClass newclass) { loc.callback = delegate(IToken tok) { //if (tok.Class != TokenClass.Keyword) { tok.Class = newclass; if (newclass == TokenClass.Type) { parsedtypes[tok.Text] = tok.Location; } else { if (parsedtypes.ContainsKey(tok.Text)) { parsedtypes.Remove(tok.Text); } } } }; locstack.Push(loc); //if (cb != null) //{ // cb.Invoke(loc); //} }
public bool Parse(SourceIterator iterator, out IToken token) { token = null; string content = string.Empty; TokenSubTypeEnum subtype; if (Char.IsLetter(iterator.Current) || iterator.Current == '_') { CodeInformation information = iterator.CodeInformation.Clone(); content = iterator.GetLettersAndDigits(); if (!_table.TryGetValue(content, out subtype)) { subtype = TokenSubTypeEnum.NA; } token = new TokenClass() { Content = content, CodeInformation = information, Type = TokenTypeEnum.IDENTIFIER, SubType = subtype }; return(true); } return(false); }
/// <summary> /// Initializes a new instance of the <see cref="Token"/> class. /// If the text parameter starts with a letter, marked as a variable otherwise it's a number. /// </summary> /// <param name="text">Value typed in by the user.</param> public Token(string text) { _text = text; _tokenClass = char.IsLetter(text[0]) ? TokenClass.Variable : TokenClass.Number; }
/// <summary> /// Initializes a new instance of the <see cref="Iodine.Compiler.Token"/> class. /// </summary> /// <param name="clazz">Token class.</param> /// <param name="value">Value.</param> /// <param name="doc">Documentation string.</param> /// <param name="location">Location.</param> public Token(TokenClass clazz, string value, string doc, SourceLocation location) { Class = clazz; Value = value; Documentation = doc; Location = location; }
/// <summary> /// Converts a TokenClass enum to its string representation /// </summary> /// <returns>The string representation of the TokenClass enum.</returns> /// <param name="clazz">Token class.</param> public static string ClassToString(TokenClass clazz) { switch (clazz) { case TokenClass.CloseBrace: return("}"); case TokenClass.OpenBrace: return("{"); case TokenClass.CloseParan: return(")"); case TokenClass.OpenParan: return("("); case TokenClass.Comma: return(","); case TokenClass.OpenBracket: return("["); case TokenClass.CloseBracket: return("]"); case TokenClass.SemiColon: return(";"); case TokenClass.Colon: return(":"); default: return(clazz.ToString()); } }
/// <summary> /// Gets ColorInfo for a token type /// </summary> /// <param name="tokentype">the token type</param> /// <returns>the color info</returns> public static ColorInfo GetColorInfo(int tokentype) { TokenClass t = (TokenClass)tokentype; if ((t & TokenClass.Custom) != 0) { if (!typemapping.ContainsKey(t)) { int v = tokentype & ~(int)TokenClass.Custom; ColorInfo ci = new ColorInfo( Color.FromKnownColor((KnownColor)(v >> 16 & 0xff)), Color.FromKnownColor((KnownColor)(v >> 8 & 0xff)), Color.FromKnownColor((KnownColor)(v & 0xff)), (FontStyle)(v >> 25 & 0xff)); typemapping.Add(t, ci); } } if (typemapping.ContainsKey(t)) { return((ColorInfo)typemapping[t]); } else { return((ColorInfo)typemapping[TokenClass.Any]); } }
public string getSpotifyToken() { TokenClass _Token = new TokenClass(); string token = _Token.getToken(); return(token); }
/// <summary> /// Initializes a new instance of the <see cref="T:XenonCore.Lexeme"/> class. /// </summary> /// <param name="type">Type.</param> /// <param name="unit">Unit.</param> /// <param name="value">Value.</param> /// <param name="literal">Literal.</param> public Lexeme(TokenClass type, SourceUnit unit, string value, object literal = null) { Type = type; Value = value; LiteralValue = literal ?? value; Location = unit.Location; }
private IEnumerator getBonificacion() { //Token Dictionary <string, string> headers = new Dictionary <string, string> (); headers.Add("Content-Type", "application/json"); headers.Add("Cookie", "Interceramic"); headers.Add("Authorization", "Basic U09LT0xBQlM6U09LT0xBQlNQUjBEMTIzIw=="); headers.Add("pClaveApp", "MIARQ"); WWW www = new WWW("https://swsp.interceramic.com/ords/miarqws_sa/genera/token", null, headers); yield return(www); tokenProp = JsonUtility.FromJson <TokenClass> (www.text); //Bonificacion Dictionary <string, string> headersPrecio = new Dictionary <string, string> (); headersPrecio.Add("Content-Type", "application/json"); headersPrecio.Add("pClaveApp", "MIARQ"); headersPrecio.Add("Authorization", "Bearer " + tokenProp.Token); WWW wwwPrecio = new WWW("https://swsp.interceramic.com/ords/miarqws_sa/consulta/bonificacion", null, headersPrecio); yield return(wwwPrecio); print("bonificacionResp: " + wwwPrecio.text); bonificacion = JsonUtility.FromJson <PrecioResp> (wwwPrecio.text); cantidad = bonificacion.MONTO.ToString(); }
/// <summary> /// Парсер даты и строк. /// </summary> /// <param name="iterator"></param> /// <param name="token"></param> /// <returns></returns> public bool Parse(SourceIterator iterator, out IToken token) { token = null; string content = string.Empty; CodeInformation information = iterator.CodeInformation.Clone(); if (ParseDate(iterator, out content)) { token = new TokenClass() { Content = content, CodeInformation = information, Type = TokenTypeEnum.LITERAL, SubType = TokenSubTypeEnum.L_DATE }; return(true); } if (ParseString(iterator, out content)) { token = new TokenClass() { Content = content, CodeInformation = information, Type = TokenTypeEnum.LITERAL, SubType = TokenSubTypeEnum.L_STRING }; return(true); } return(false); }
/// <summary> /// Accept the specified token and value. /// </summary> /// <param name="token">Token.</param> /// <param name="strval">Strval.</param> public bool Accept(TokenClass token, string strval) { var match = Match(token) && Match(strval); Skip(match ? 1 : 0); return(match); }
async Task <int> UserSelectedDamage(int damage, Spirit damagePicker, Present present, params TokenClass[] allowedTypes) { if (damage == 0) { return(0); } if (allowedTypes == null || allowedTypes.Length == 0) { allowedTypes = new TokenClass[] { Invader.Explorer, Invader.Town, Invader.City } } ; Token[] invaderTokens; int damageInflicted = 0; while (damage > 0 && (invaderTokens = Tokens.OfAnyType(allowedTypes).ToArray()).Length > 0) { var invaderToDamage = (HealthToken)await damagePicker.Action.Decision(Select.Invader.ForAggregateDamage(Space, invaderTokens, damage, present)); if (invaderToDamage == null) { break; } await ApplyDamageTo1(1, invaderToDamage); --damage; ++damageInflicted; } return(damageInflicted); }
public void GetToken(string code) { string poststring = "grant_type=authorization_code&code=" + code + "&client_id=" + clientid + "&client_secret=" + clientsecret + "&redirect_uri=" + redirection_url + ""; var request = (HttpWebRequest)WebRequest.Create(url); request.ContentType = "application/x-www-form-urlencoded"; request.Method = "POST"; UTF8Encoding utfenc = new UTF8Encoding(); byte[] bytes = utfenc.GetBytes(poststring); Stream outputstream = null; try { request.ContentLength = bytes.Length; outputstream = request.GetRequestStream(); outputstream.Write(bytes, 0, bytes.Length); } catch { } var response = (HttpWebResponse)request.GetResponse(); var streamReader = new StreamReader(response.GetResponseStream()); string responseFromServer = streamReader.ReadToEnd(); JavaScriptSerializer js = new JavaScriptSerializer(); TokenClass obj = js.Deserialize <TokenClass>(responseFromServer); GetuserProfile(obj.access_token); }
public async Task <object> CreateZoomMeeting(TokenClass payload) { var request = new HttpRequestMessage(HttpMethod.Post, "https://api.zoom.us/v2/users/me/meetings"); request.Content = new StringContent(JsonSerializer.Serialize(new RequestMeeting { agenda = payload.agenda, start_time = payload.start_time, timezone = payload.timezone, topic = payload.topic, type = payload.type, duration = payload.duration, password = payload.password })); request.Content.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json"); var client = _httpClient.CreateClient(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", payload.accesstoken); var response = await client.SendAsync(request); if (response.IsSuccessStatusCode) { var responseStream = await response.Content.ReadAsStreamAsync(); var Branches = JsonSerializer.DeserializeAsync <CreateMeetingResponse>(responseStream); return(Branches); } else { return(null); } }
/// <summary> /// Accept the specified token. /// </summary> /// <param name="token">Token.</param> public bool Accept(TokenClass token) { var match = Match(token); Skip(match ? 1 : 0); return(match); }
static async Task GatherLike(TargetSpaceCtx ctx, TokenClass tokenTypeOfInterest) { if (ctx.Tokens.HasAny(tokenTypeOfInterest)) { await ctx.GatherUpTo(1, tokenTypeOfInterest); } }
public Playlists getPlayLists() { TokenClass _Token = new TokenClass(); string token = _Token.getToken(); string url = "https://api.spotify.com/v1/browse/featured-playlists?country=US&locale=sv_US×tamp=2020-05-01T09%3A00%3A00&limit=10"; var Authorization = _Token.currentToken; HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); webRequest.Method = "GET"; webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.Accept = "application/json"; webRequest.Headers.Add("Authorization:" + _Token.currentToken); webRequest.ContentLength = 0; HttpWebResponse resp = (HttpWebResponse)webRequest.GetResponse(); String json = ""; DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(PlayListsClass)); using (Stream respStr = resp.GetResponseStream()) { using (StreamReader rdr = new StreamReader(respStr, Encoding.UTF8)) { json = rdr.ReadToEnd(); rdr.Close(); } } var playlists = JsonConvert.DeserializeObject <PlayList>(json).playlists; return(playlists); }
public StyleElement(Style s, TokenClass token_class, Major major, Minor minor, int param, string text) { this.token_class = token_class; this.major = major; this.minor = minor; this.param = param; this.text = text; lock (s) { if (s.Elements == null) { s.Elements = this; } else { StyleElement se = s.Elements; while (se.next != null) { se = se.next; } se.next = this; } } }
Token ReadHexNumber() { var accum = new StringBuilder(); source.Skip(2); while (source.See() && IsHexNumber(source.Peek())) { accum.Append(source.Read()); } var val = accum.ToString(); bool isBigInt = source.Peek() == 'L'; bool fitsInInteger = false; if (isBigInt) { source.Skip(); BigInteger valBig; fitsInInteger = BigInteger.TryParse( "0" + val, System.Globalization.NumberStyles.HexNumber, null, out valBig ); val = valBig.ToString(); } else { long val64; fitsInInteger = long.TryParse( val, System.Globalization.NumberStyles.HexNumber, null, out val64 ); val = val64.ToString(); } if (!fitsInInteger) { errorLog.Add(Errors.IntegerOverBounds, source.Location); } TokenClass tokenClass = isBigInt ? TokenClass.BigIntLiteral : TokenClass.IntLiteral; if (string.IsNullOrEmpty(val)) { errorLog.Add(Errors.IllegalSyntax, source.Location); } return(new Token(tokenClass, val, lastDocStr, source.Location)); }
protected void BtnDeleteRuta_Click(object sender, EventArgs e) { TokenClass token = new TokenClass(); logClass = new LogClass(); //logClass.AnularRutaAsign( HdnIdAsignruta.Value,token.TokenId); Response.Redirect("~/View/Logistica/AdministracionRutas?ID=" + HdnIdInventario.Value + "&TOKEN=" + token.TokenId); }
public ClassDelegate this[TokenClass c] { get { return callbacks[(int)c]; } set { callbacks[(int)c] = value; } }
protected void BtnDownLoadExcel_Click(object sender, EventArgs e) { token = new TokenClass(); logclass = new LogClass(); Inventario inventario = logclass.GetVariables(HdnIdInventario.Value); ExportarExcel(logclass.GetDetailInventory(HdnIdInventario.Value, token.TokenId), inventario.Name); Response.Redirect("~/View/Logistica/DetalleInventario?ID=" + HdnIdInventario.Value + "&TOKEN=" + token.TokenId); }
public bool CheckCMM(TokenClass rtf_class, Major major, Minor minor) { if ((this.rtf_class == rtf_class) && (this.major == major) && (this.minor == minor)) { return(true); } return(false); }
public RTFException(RTF rtf, string error_message) { this.pos = rtf.LinePos; this.line = rtf.LineNumber; this.token_class = rtf.TokenClass; this.major = rtf.Major; this.minor = rtf.Minor; this.param = rtf.Param; this.text = rtf.Text; this.error_message = error_message; }
/// <summary> /// Gets the <see cref="HighlightColor"/> for the specified class of /// token. /// </summary> /// <param name="p_ttpTokenClass">The token class for which the /// <see cref="HighlightColor"/> is to be returned.</param> /// <returns>The <see cref="HighlightColor"/> for the specified class of /// token.</returns> public HighlightColor GetColorFor(TokenClass p_ttpTokenClass) { switch (p_ttpTokenClass) { case TokenClass.Operator: return new HighlightColor(Color.ForestGreen, false, false); case TokenClass.String: return new HighlightColor(Color.Maroon, false, false); case TokenClass.Keyword: return new HighlightColor(Color.Red, false, false); case TokenClass.Variable: return new HighlightColor(Color.Blue, false, false); default: return defaultHighlightingStrategy.GetColorFor("DefaultColor"); } }
public StyleElement(Style s, TokenClass token_class, Major major, Minor minor, int param, string text) { this.token_class = token_class; this.major = major; this.minor = minor; this.param = param; this.text = text; lock (s) { if (s.Elements == null) { s.Elements = this; } else { StyleElement se = s.Elements; while (se.next != null) se = se.next; se.next = this; } } }
public void SetToken(TokenClass cl, Major maj, Minor min, int par, string text) { this.rtf_class = cl; this.major = maj; this.minor = min; this.param = par; if (par == NoParam) { this.text_buffer = new StringBuilder(text); } else { this.text_buffer = new StringBuilder(text + par.ToString()); } }
public void UngetToken() { if (this.pushed_class != TokenClass.None) { throw new RTFException(this, "Cannot unget more than one token"); } if (this.rtf_class == TokenClass.None) { throw new RTFException(this, "No token to unget"); } this.pushed_class = this.rtf_class; this.pushed_major = this.major; this.pushed_minor = this.minor; this.pushed_param = this.param; //this.pushed_text_buffer = new StringBuilder(this.text_buffer.ToString()); }
public void Lookup(string token) { Object obj; KeyStruct key; obj = key_table[token.Substring(1)]; if (obj == null) { rtf_class = TokenClass.Unknown; major = (Major) -1; minor = (Minor) -1; return; } key = (KeyStruct)obj; this.rtf_class = TokenClass.Control; this.major = key.Major; this.minor = key.Minor; }
public Token() : base() { Identation = string.Empty; tokenClass = TokenClass.Whitespace; stringClass = Html.StringClass.DoubleQuote; serverTagClass = Html.ServerTagClass.Expression; Value = string.Empty; Line = 1; Column = 1; Start = 0; End = 0; }
/// <summary>Return the next token in the stream</summary> public TokenClass GetToken() { if (pushed_class != TokenClass.None) { this.rtf_class = this.pushed_class; this.major = this.pushed_major; this.minor = this.pushed_minor; this.param = this.pushed_param; this.pushed_class = TokenClass.None; return this.rtf_class; } GetToken2(); if (this.rtf_class == TokenClass.Text) { this.minor = (Minor)this.cur_charset[(int)this.major]; if (encoding == null) { encoding = Encoding.GetEncoding (encoding_code_page); } encoded_text = new String (encoding.GetChars (new byte [] { (byte) this.major })); } if (this.cur_charset.Flags == CharsetFlags.None) { return this.rtf_class; } if (CheckCMM (TokenClass.Control, Major.Unicode, Minor.UnicodeAnsiCodepage)) { encoding_code_page = param; // fallback to the default one in case we have an invalid value if (encoding_code_page < 0 || encoding_code_page > 65535) encoding_code_page = DefaultEncodingCodePage; } if (((this.cur_charset.Flags & CharsetFlags.Read) != 0) && CheckCM(TokenClass.Control, Major.CharSet)) { this.cur_charset.ReadMap(); } else if (((this.cur_charset.Flags & CharsetFlags.Switch) != 0) && CheckCMM(TokenClass.Control, Major.CharAttr, Minor.FontNum)) { Font fp; fp = Font.GetFont(this.font_list, this.param); if (fp != null) { if (fp.Name.StartsWith("Symbol")) { this.cur_charset.ID = CharsetType.Symbol; } else { this.cur_charset.ID = CharsetType.General; } } else if (((this.cur_charset.Flags & CharsetFlags.Switch) != 0) && (this.rtf_class == TokenClass.Group)) { switch(this.major) { case Major.BeginGroup: { this.charset_stack.Push(this.cur_charset); break; } case Major.EndGroup: { this.cur_charset = (Charset)this.charset_stack.Pop(); break; } } } } return this.rtf_class; }
public Token Expect(TokenClass clazz, string val) { Token ret = PeekToken (); if (Accept (clazz, val)) { return ret; } Token offender = ReadToken (); if (offender != null) { errorLog.AddError (ErrorType.ParserError, offender.Location, "Unexpected '{0}' (Expected '{1}')", offender.ToString (), Token.ClassToString ( clazz)); } else { errorLog.AddError (ErrorType.ParserError, offender.Location, "Unexpected end of file (Expected {0})", Token.ClassToString (clazz)); throw new Exception (""); } return new Token (clazz, "", Location); }
public TokenExpression() { this.token = new TokenClass(this); }
public Token(TokenClass clazz, object val, int line) { this.tokenClass = clazz; this.tokenValue = val; this.line = line; }
public void CopyFrom(Token t) { Start = t.Start; End = t.End; Line = t.Line; Column = t.Column; Identation = t.Identation; tokenClass = t.tokenClass; stringClass = t.stringClass; serverTagClass = t.serverTagClass; Value = t.Value; }
public bool Match(TokenClass clazz, string val) { return PeekToken () != null && PeekToken ().Class == clazz && PeekToken ().Value == val; }
public bool Match(TokenClass clazz1, TokenClass clazz2) { return PeekToken () != null && PeekToken ().Class == clazz1 && PeekToken (1) != null && PeekToken (1).Class == clazz2; }
public bool Match(TokenClass clazz) { return PeekToken () != null && PeekToken ().Class == clazz; }
private void GetToken2() { char c; int sign; this.rtf_class = TokenClass.Unknown; this.param = NoParam; this.text_buffer.Length = 0; if (this.pushed_char != EOF) { c = this.pushed_char; this.text_buffer.Append(c); this.pushed_char = EOF; } else if ((c = GetChar()) == EOF) { this.rtf_class = TokenClass.EOF; return; } if (c == '{') { this.rtf_class = TokenClass.Group; this.major = Major.BeginGroup; return; } if (c == '}') { this.rtf_class = TokenClass.Group; this.major = Major.EndGroup; return; } if (c != '\\') { if (c != '\t') { this.rtf_class = TokenClass.Text; this.major = (Major)c; // FIXME - typing? return; } else { this.rtf_class = TokenClass.Control; this.major = Major.SpecialChar; this.minor = Minor.Tab; return; } } if ((c = GetChar()) == EOF) { // Not so good return; } if (!Char.IsLetter(c)) { if (c == '\'') { char c2; if ((c = GetChar()) == EOF) { return; } if ((c2 = GetChar()) == EOF) { return; } this.rtf_class = TokenClass.Text; this.major = (Major)((Char)((Convert.ToByte(c.ToString(), 16) * 16 + Convert.ToByte(c2.ToString(), 16)))); return; } // Escaped char if (c == ':' || c == '{' || c == '}' || c == '\\') { this.rtf_class = TokenClass.Text; this.major = (Major)c; return; } Lookup(this.text_buffer.ToString()); return; } while (Char.IsLetter(c)) { if ((c = GetChar()) == EOF) { break; } } if (c != EOF) { this.text_buffer.Length--; } Lookup(this.text_buffer.ToString()); if (c != EOF) { this.text_buffer.Append(c); } sign = 1; if (c == '-') { sign = -1; c = GetChar(); } if (c != EOF && Char.IsDigit(c)) { this.param = 0; while (Char.IsDigit(c)) { this.param = this.param * 10 + Convert.ToByte(c) - 48; if ((c = GetChar()) == EOF) { break; } } this.param *= sign; } if (c != EOF) { if (c != ' ') { this.pushed_char = c; } this.text_buffer.Length--; } }
/// <summary>Return the next token in the stream</summary> public TokenClass GetToken() { if (pushed_class != TokenClass.None) { this.rtf_class = this.pushed_class; this.major = this.pushed_major; this.minor = this.pushed_minor; this.param = this.pushed_param; this.pushed_class = TokenClass.None; return this.rtf_class; } GetToken2(); if (this.rtf_class == TokenClass.Text) { this.minor = (Minor)this.cur_charset[(int)this.major]; } if (this.cur_charset.Flags == CharsetFlags.None) { return this.rtf_class; } if (((this.cur_charset.Flags & CharsetFlags.Read) != 0) && CheckCM(TokenClass.Control, Major.CharSet)) { this.cur_charset.ReadMap(); } else if (((this.cur_charset.Flags & CharsetFlags.Switch) != 0) && CheckCMM(TokenClass.Control, Major.CharAttr, Minor.FontNum)) { Font fp; fp = Font.GetFont(this.font_list, this.param); if (fp != null) { if (fp.Name.StartsWith("Symbol")) { this.cur_charset.ID = CharsetType.Symbol; } else { this.cur_charset.ID = CharsetType.General; } } else if (((this.cur_charset.Flags & CharsetFlags.Switch) != 0) && (this.rtf_class == TokenClass.Group)) { switch(this.major) { case Major.BeginGroup: { this.charset_stack.Push(this.cur_charset); break; } case Major.EndGroup: { this.cur_charset = (Charset)this.charset_stack.Pop(); break; } } } } return this.rtf_class; }
public bool Accept(TokenClass clazz, ref Token token) { if (PeekToken () != null && PeekToken ().Class == clazz) { token = ReadToken (); return true; } return false; }
/// <summary> /// Converts a TokenClass enum to its string representation /// </summary> /// <returns>The string representation of the TokenClass enum.</returns> /// <param name="clazz">Token class.</param> public static string ClassToString(TokenClass clazz) { switch (clazz) { case TokenClass.CloseBrace: return "}"; case TokenClass.OpenBrace: return "{"; case TokenClass.CloseParan: return ")"; case TokenClass.OpenParan: return "("; case TokenClass.Comma: return ","; case TokenClass.OpenBracket: return "["; case TokenClass.CloseBracket: return "]"; case TokenClass.SemiColon: return ";"; case TokenClass.Colon: return ":"; default: return clazz.ToString (); } }
public bool Accept(TokenClass clazz, string val) { if (PeekToken () != null && PeekToken ().Class == clazz && PeekToken ().Value == val) { ReadToken (); return true; } return false; }
public void Set(TokenClass tokenClass, string value = "") { Class = tokenClass; Value = value; }
/// <summary> /// Initializes a new instance of the <see cref="Iodine.Compiler.Token"/> class. /// </summary> /// <param name="clazz">Token class.</param> /// <param name="value">Value.</param> /// <param name="location">Location.</param> public Token(TokenClass clazz, string value, Location location) { this.Class = clazz; this.Value = value; this.Location = location; }
public RTF(Stream stream) { source = new StreamReader(stream); text_buffer = new StringBuilder(1024); //pushed_text_buffer = new StringBuilder(1024); rtf_class = TokenClass.None; pushed_class = TokenClass.None; pushed_char = unchecked((char)-1); line_num = 0; line_pos = 0; prev_char = unchecked((char)-1); bump_line = false; cur_charset = new Charset(); destination_callbacks = new DestinationCallback(); class_callbacks = new ClassCallback(); destination_callbacks [Minor.OptDest] = new DestinationDelegate (HandleOptDest); destination_callbacks[Minor.FontTbl] = new DestinationDelegate(ReadFontTbl); destination_callbacks[Minor.ColorTbl] = new DestinationDelegate(ReadColorTbl); destination_callbacks[Minor.StyleSheet] = new DestinationDelegate(ReadStyleSheet); destination_callbacks[Minor.Info] = new DestinationDelegate(ReadInfoGroup); destination_callbacks[Minor.Pict] = new DestinationDelegate(ReadPictGroup); destination_callbacks[Minor.Object] = new DestinationDelegate(ReadObjGroup); }
public bool CheckCMM(TokenClass rtf_class, Major major, Minor minor) { if ((this.rtf_class == rtf_class) && (this.major == major) && (this.minor == minor)) { return true; } return false; }
/// <summary> /// Initializes a new instance of the <see cref="Iodine.Compiler.Token"/> class. /// </summary> /// <param name="clazz">Token class.</param> /// <param name="value">Value.</param> /// <param name="location">Location.</param> public Token (TokenClass clazz, string value, SourceLocation location) { Class = clazz; Value = value; Location = location; }
public Token(TokenClass tokenClass) : this() { Class = tokenClass; }