public ConsumerRequest(IOAuthContext context, IOAuthConsumerContext consumerContext, IToken token, ICertificateFactory clientSslCertificateFactory) { _context = context; _consumerContext = consumerContext; _token = token; _clientSslCertificateFactory = clientSslCertificateFactory; }
public IToken InterpretExpression(IToken n) { if(n is RangeToken) { n = ResolveRange((RangeToken) n); } return n; }
public override IToken Evaluate(IToken first, IToken last, TokenTreeList parameters, bool isFinal) { if (first == null) throw new Exception($"Operation {Text} can not be unary."); IToken evaluated = last.Evaluate(parameters, isFinal); if (evaluated == null) throw new Exception($"Second element of Operation {Text} is not unique."); ListToken evaluatedList = evaluated as ListToken; if (evaluatedList != null) { ListToken list = new ListToken(); foreach (IToken item in evaluatedList.Tokens) list.Tokens.Add(Evaluate(first, item, parameters, isFinal)); return list; } IntToken intToken = evaluated as IntToken; if (intToken == null) { if (isFinal) throw new Exception($"Operation {Text} must have integer second element."); return new ExpressionToken(first, new IndexOperator(), last); } IToken tokenList = first.Evaluate(parameters, isFinal); ListToken listToken = tokenList as ListToken; int index = intToken.Value; return listToken == null ? (index == 0 && tokenList is ITypeToken ? tokenList : new ExpressionToken(first, new IndexOperator(), intToken)) : (listToken.Tokens.Count > index ? listToken.Tokens[index] : new NullToken()); }
IToken GetFunctionDefinitionEndToken() { if (functionDefinitionEndToken == null) { functionDefinitionEndToken = ast.GetToken(methodDefinition.TokenStopIndex); } return functionDefinitionEndToken; }
public void EmitAssign(IToken token, object value) { EmitPop(token); //function.Add(AsmTemplate.Assign(token.Text, value)); // MapFunction(token); }
public void SignContextWithToken(IOAuthContext context, IToken token) { context.Token = token.Token; context.TokenSecret = token.TokenSecret; SignContext(context); }
public ASTNode(IToken token) { _startIndex = -1; _stopIndex = -1; _childIndex = -1; _token = token; }
/// <summary> /// Override of base to track previous on channel token. This token is needed as input to decide whether regular expression or division expression recognition is enabled. /// </summary> public override IToken NextToken() { var result = base.NextToken(); if (result.Channel == DefaultTokenChannel) { Last = result; } return result; }
public IConsumerRequest CreateConsumerRequest(IOAuthContext context, IOAuthConsumerContext consumerContext, IToken token) { if (context == null) throw new ArgumentNullException("context"); if (consumerContext == null) throw new ArgumentNullException("consumerContext"); return new ConsumerRequest(context, consumerContext, token); }
override public void initialize(IToken tok) { IHiddenStreamToken t = (IHiddenStreamToken) tok; base.initialize(t); hiddenBefore = t.getHiddenBefore(); hiddenAfter = t.getHiddenAfter(); }
public override CompiledTemplate DefineTemplateAlias(IToken aliasT, IToken targetT) { CompiledTemplate result = base.DefineTemplateAlias(aliasT, targetT); _templateInformation.Add(new TemplateInformation(aliasT, targetT, result)); return result; }
/// <summary> /// Evaluate the function. /// </summary> /// <param name="parameters">The tokens that make up the function parameter list.</param> /// <param name="substitutions">The tokens that can be used for substitutions.</param> /// <param name="isFinal">Whether a result needs to be returned.</param> /// <returns></returns> public override IToken Perform(IToken parameters, TokenTreeList substitutions, bool isFinal) { ListToken listToken = parameters as ListToken; if (listToken == null) throw new Exception($"Token must be list for '{ID}'"); List<IToken> lastList = listToken.Tokens; int count = lastList.Count; IToken toFind = lastList[count - 1]; if (toFind is ExpressionToken) { if (isFinal) throw new Exception($"Could not find value for {toFind}"); return UnParsed(listToken); } for (int i = 0; i < count - 1; i++) { IToken token = lastList[i]; if (token is ExpressionToken) return UnParsed(listToken); ListToken list = token as ListToken; if (list != null && list.Tokens.Contains(toFind)) return new BoolTooken(true); if (token.Text == toFind.Text) return new BoolTooken(true); } return new BoolTooken(false); }
protected override ParsedSyntax Syntax(ParsedSyntax left, IToken token, ParsedSyntax right) { if(left == null || right == null) return base.Syntax(left, token, right); return left.Equal(token, right); }
internal static Syntax CreateSourceSyntax ( Syntax left, ITokenClass tokenClass, IToken token, Syntax right) => new Syntax(left, tokenClass, token, right);
public void Delete(IToken token) { if (_tokens.ContainsKey(token.UserId)) { _tokens.Remove(token.UserId); } }
public string CreateSignature(X509Certificate2 certificate, IToken token, Uri uri, string verb, string verifier = null, bool renewToken = false, string callback = null) { var oAuthParameters = new OAuthParameters( new ConsumerKey(token.ConsumerKey), //Modified to fix oauth error for private app //new TokenKey(token.TokenKey), new TokenKey(token.ConsumerKey), "RSA-SHA1", new DefaultTimestampSequence(), new DefaultNonceSequence(), string.Empty, "1.0", verifier, token.Session, renewToken, callback); var signatureBaseString = new SignatureBaseString( new Request { Url = uri, Verb = verb }, oAuthParameters); var signature = new RsaSha1(certificate).Sign(signatureBaseString); oAuthParameters.SetSignature(signature); return new AuthorizationHeader(oAuthParameters, string.Empty, renewToken).Value; }
public TokenWrapper(IToken token, string tokenName) { TokenName = tokenName; Token = token; Type = new TokenType {Type = token.Type}; tokenHashCode = Type.GetHashCode(); }
public CommonTree(IToken t) { this.startIndex = -1; this.stopIndex = -1; this.childIndex = -1; this.token = t; }
public bool Parse(string text, int currentPosition, IToken currentToken, out int newPosition, out IToken newToken, out IForwardMovingTokenizer newParser) { //if we can't find a , or ) then we kack var idx = text.IndexOf(",", currentPosition); if (idx == -1) { idx = text.IndexOf(")", currentPosition); if (idx == -1) { newPosition = -1; newToken = null; newParser = null; return false; } var substring = text.Substring(currentPosition, idx - currentPosition); newPosition = idx + 1; newToken = NaturalToken.New(substring).HasDPCTokenType(DPCTokenType.Item); newParser = new ToDotParser(); return true; } else { var substring = text.Substring(currentPosition, idx - currentPosition); newPosition = idx + 1; newToken = NaturalToken.New(substring).HasDPCTokenType(DPCTokenType.Item); newParser = new ToCommaOrEndParenthesisParser(); return true; } }
public string CreateSignature(X509Certificate2 certificate, IToken token, Uri uri, string verb, string verifier = null) { var oAuthParameters = new OAuthParameters( new ConsumerKey(token.ConsumerKey), new TokenKey(token.ConsumerKey), "RSA-SHA1", new DefaultTimestampSequence(), new DefaultNonceSequence(), string.Empty, "1.0", verifier, token.Session); var signatureBaseString = new SignatureBaseString( new Request { Url = uri, Verb = verb }, oAuthParameters); var signature = new RsaSha1(certificate).Sign(signatureBaseString); oAuthParameters.SetSignature(signature); return new AuthorizationHeader(oAuthParameters, string.Empty).Value; ; }
public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e) { NotificationManager.AddNotification( new ParseError ( string.Format("line {0} : {1} at {2} : {3}", line, charPositionInLine, offendingSymbol, msg) )); }
public override IToken Perform(IToken token, TokenTreeList parameters, bool isFinal) { ListToken listToken = token as ListToken; if (listToken == null) throw new Exception($"Last token must be list for '{ID}'"); List<IToken> lastList = listToken.Tokens; int count = lastList.Count; IToken first = lastList[0]; if (first is ExpressionToken) return UnParsed(listToken); for (int i = 1; i < count - 1; i += 2) { IToken second = lastList[i]; if (second is ExpressionToken) return UnParsed(listToken); if (first.Text == second.Text) return lastList[i + 1]; } return count % 2 == 0 ? lastList[count - 1] : new NullToken(); }
public static string[] GetComments(IToken[] FileTokens, List<IToken> alreadyTakenComments, int lastTokenLineNo, int prevTokenIndex, int nextTokenIndex, bool acn = false) { List<string> comments = new List<string>(); int WS = acn ? acnLexer.WS : asn1Lexer.WS; int COMMENT = acn ? acnLexer.COMMENT : asn1Lexer.COMMENT; int COMMENT2 = acn ? acnLexer.COMMENT2 : asn1Lexer.COMMENT2; //first see if there comments on the same line while (nextTokenIndex >= 0 && nextTokenIndex < FileTokens.Length) { IToken t = FileTokens[nextTokenIndex++]; if (alreadyTakenComments.Contains(t)) { break; } if (t.Line != lastTokenLineNo) { break; } if (t.Type == WS) { continue; } else if (t.Type == COMMENT || t.Type == COMMENT2) { comments.Insert(0, t.Text); alreadyTakenComments.Add(t); } else { break; } } //if no comments were found at the same line, then look back (above) if (comments.Count == 0) { while (prevTokenIndex >= 0 && prevTokenIndex < FileTokens.Length) { IToken t = FileTokens[prevTokenIndex--]; if (alreadyTakenComments.Contains(t)) break; if (t.Type == WS) continue; else if (t.Type == COMMENT || t.Type == COMMENT2) { comments.Insert(0, t.Text); alreadyTakenComments.Add(t); } else break; } } return comments.ToArray(); }
public static string AsNotQuoted(IToken token) { if (token == null) return null; return AsNotQuoted(token.Text); }
public CaretToken(IToken oldToken) : base(oldToken) { this.channel = TokenConstants.DefaultChannel; this._originalToken = oldToken; this.type = CaretTokenType; }
/// <summary> /// In our implementation, Token.TokenIndex always returns -1. /// We can not insert all the intermediate tokens like Antlr does in the default implementation. /// This method just returns the text of the starting and ending tokens. /// </summary> public override string GetText(IToken start, IToken stop) { if (start != null || stop != null) { if (start == stop) { return start.Text; } else { return start.Text + " ... " + stop.Text; } } else if (start != null) { return start.Text + " ..."; } else if (stop != null) { return "... " + stop.Text; } else { return String.Empty; } }
public string CreateSignature(IToken token, Uri uri, string verb, string verifier = null, string callback = null) { var oAuthParameters = new OAuthParameters( new ConsumerKey(token.ConsumerKey), new TokenKey(token.TokenKey), "HMAC-SHA1", new DefaultTimestampSequence(), new DefaultNonceSequence(), string.Empty, "1.0", verifier, token.Session, false, callback); var signatureBaseString = new SignatureBaseString( new Request { Url = uri, Verb = verb }, oAuthParameters); var signature = new HmacSha1().Sign(signatureBaseString, token.ConsumerSecret, token.TokenSecret); oAuthParameters.SetSignature(signature); return new AuthorizationHeader(oAuthParameters, string.Empty).Value; }
// helper extension method to sign each JSON request with OAuth public static void SetAccessToken(this JsonServiceClient client, IToken access_token) { // we use a request filter to add the required OAuth header client.LocalHttpWebRequestFilter += webservice_request => { OAuthConsumerContext consumer_context = new OAuthConsumerContext (); consumer_context.SignatureMethod = "HMAC-SHA1"; consumer_context.ConsumerKey = access_token.ConsumerKey; consumer_context.ConsumerSecret = "anyone"; consumer_context.UseHeaderForOAuthParameters = true; // the OAuth process creates a signature, which uses several data from // the web request like method, hostname, headers etc. OAuthContext request_context = new OAuthContext (); request_context.Headers = webservice_request.Headers; request_context.RequestMethod = webservice_request.Method; request_context.RawUri = webservice_request.RequestUri; // now create the signature for that context consumer_context.SignContextWithToken (request_context, access_token); // BUG TODO the oauth_token is not included when generating the header, // this is a bug ing DevDefined.OAuth. We add it manually as a workaround request_context.AuthorizationHeaderParameters.Add ("oauth_token", access_token.Token); string oauth_header = request_context.GenerateOAuthParametersForHeader (); webservice_request.Headers.Add ("Authorization", oauth_header); }; }
public static Token2 CreateToken(IToken token) { int length = token.StopIndex - token.StartIndex + 1; int startPosition = token.StartIndex; int endPosition = token.StopIndex; switch (token.Type) { case Java6ColorizerLexer.DOUBLELITERAL: case Java6ColorizerLexer.FLOATLITERAL: return new NumericLiteralToken(token.Type, startPosition, endPosition); case Java6ColorizerLexer.STRINGLITERAL: return new StringLiteralToken(token.Type, startPosition, endPosition); case Java6ColorizerLexer.BLOCK_COMMENT: case Java6ColorizerLexer.LINE_COMMENT: return new CommentLiteralToken(token.Type, startPosition, endPosition); case Java6ColorizerLexer.IDENTIFIER: if (Keywords.Contains(token.Text)) { return new KeywordToken(token.Type, startPosition, endPosition); } return new IdentifierToken(token.Type, startPosition, endPosition); } //System.Diagnostics.Debug.WriteLine(string.Format("case JavaLexer.{0}:"), ); return new InvalidToken(token.Type, startPosition, endPosition); }
protected override ParsedSyntax Syntax(ParsedSyntax left, IToken token, ParsedSyntax right) { Tracer.Assert(left != null); Tracer.Assert(right != null); return left.Associative(this, token, right); }
public void delete(IToken from, IToken to) { delete(DEFAULT_PROGRAM_NAME, from, to); }
public CompoundAndNode(IToken o) : base(o) { }
/// <summary>Normalise and parse the given condition values.</summary> /// <param name="raw">The raw condition values to normalise.</param> /// <param name="tokenContext">The tokens available for this content pack.</param> /// <param name="formatVersion">The format version specified by the content pack.</param> /// <param name="latestFormatVersion">The latest format version.</param> /// <param name="minumumTokenVersions">The minimum format versions for newer condition types.</param> /// <param name="conditions">The normalised conditions.</param> /// <param name="error">An error message indicating why normalisation failed.</param> private bool TryParseConditions(InvariantDictionary <string> raw, IContext tokenContext, ISemanticVersion formatVersion, ISemanticVersion latestFormatVersion, InvariantDictionary <ISemanticVersion> minumumTokenVersions, out ConditionDictionary conditions, out string error) { conditions = new ConditionDictionary(); // no conditions if (raw == null || !raw.Any()) { error = null; return(true); } // parse conditions foreach (KeyValuePair <string, string> pair in raw) { // parse condition key if (!TokenName.TryParse(pair.Key, out TokenName name)) { error = $"'{pair.Key}' isn't a valid token name"; conditions = null; return(false); } // get token IToken token = tokenContext.GetToken(name, enforceContext: false); if (token == null) { error = $"'{pair.Key}' isn't a valid condition; must be one of {string.Join(", ", tokenContext.GetTokens(enforceContext: false).Select(p => p.Name).OrderBy(p => p))}"; conditions = null; return(false); } // validate subkeys if (!token.CanHaveSubkeys) { if (name.HasSubkey()) { error = $"{name.Key} conditions don't allow subkeys (:)"; conditions = null; return(false); } } else if (token.RequiresSubkeys) { if (!name.HasSubkey()) { error = $"{name.Key} conditions must specify a token subkey (see readme for usage)"; conditions = null; return(false); } } // check compatibility if (minumumTokenVersions.TryGetValue(name.Key, out ISemanticVersion minVersion) && minVersion.IsNewerThan(formatVersion)) { error = $"{name} isn't available with format version {formatVersion} (change the {nameof(ContentConfig.Format)} field to {latestFormatVersion} to use newer features)"; conditions = null; return(false); } // parse values InvariantHashSet values = this.ParseCommaDelimitedField(pair.Value); if (!values.Any()) { error = $"{name} can't be empty"; conditions = null; return(false); } // restrict to allowed values InvariantHashSet rawValidValues = token.GetAllowedValues(name); if (rawValidValues?.Any() == true) { InvariantHashSet validValues = new InvariantHashSet(rawValidValues); { string[] invalidValues = values.ExceptIgnoreCase(validValues).ToArray(); if (invalidValues.Any()) { error = $"invalid {name} values ({string.Join(", ", invalidValues)}); expected one of {string.Join(", ", validValues)}"; conditions = null; return(false); } } } // perform custom validation if (!token.TryCustomValidation(values, out string customError)) { error = $"invalid {name} values: {customError}"; conditions = null; return(false); } // create condition conditions[name] = new Condition(name, values); } // return parsed conditions error = null; return(true); }
/// <summary> /// The purpose of this method is to resolve indirect reference. That mean copy the reference's content to the new document's stream /// and replace the indirect reference with the correct/new one /// </summary> /// <param name="writer">PDF stream writer</param> /// <param name="tokenToCopy">Token to inspect for reference</param> /// <param name="tokenScanner">scanner get the content from the original document</param> /// <param name="referencesFromDocument">Map of previously copied tokens for original document.</param> /// <param name="callstack">Call stack of indirect references</param> /// <returns>A reference of the token that was copied. With all the reference updated</returns> public static IToken CopyToken(IPdfStreamWriter writer, IToken tokenToCopy, IPdfTokenScanner tokenScanner, IDictionary <IndirectReference, IndirectReferenceToken> referencesFromDocument, Dictionary <IndirectReference, IndirectReferenceToken> callstack = null) { if (callstack == null) { callstack = new Dictionary <IndirectReference, IndirectReferenceToken>(); } // This token need to be deep copied, because they could contain reference. So we have to update them. switch (tokenToCopy) { case DictionaryToken dictionaryToken: { var newContent = new Dictionary <NameToken, IToken>(); foreach (var setPair in dictionaryToken.Data) { var name = setPair.Key; var token = setPair.Value; newContent.Add(NameToken.Create(name), CopyToken(writer, token, tokenScanner, referencesFromDocument, callstack)); } return(new DictionaryToken(newContent)); } case ArrayToken arrayToken: { var newArray = new List <IToken>(arrayToken.Length); foreach (var token in arrayToken.Data) { newArray.Add(CopyToken(writer, token, tokenScanner, referencesFromDocument, callstack)); } return(new ArrayToken(newArray)); } case IndirectReferenceToken referenceToken: { if (referencesFromDocument.TryGetValue(referenceToken.Data, out var newReferenceToken)) { return(newReferenceToken); } if (callstack.ContainsKey(referenceToken.Data) && callstack[referenceToken.Data] == null) { newReferenceToken = writer.ReserveObjectNumber(); callstack[referenceToken.Data] = newReferenceToken; referencesFromDocument.Add(referenceToken.Data, newReferenceToken); return(newReferenceToken); } callstack.Add(referenceToken.Data, null); // we add the token to referencesFromDocument to prevent stackoverflow on references cycles // newReferenceToken = context.ReserveNumberToken(); // callstack.Add(newReferenceToken.Data.ObjectNumber); // referencesFromDocument.Add(referenceToken.Data, newReferenceToken); // var tokenObject = DirectObjectFinder.Get <IToken>(referenceToken.Data, tokenScanner); Debug.Assert(!(tokenObject is IndirectReferenceToken)); var result = CopyToken(writer, tokenObject, tokenScanner, referencesFromDocument, callstack); if (callstack[referenceToken.Data] != null) { return(writer.WriteToken(result, callstack[referenceToken.Data])); } newReferenceToken = writer.WriteToken(result); referencesFromDocument.Add(referenceToken.Data, newReferenceToken); return(newReferenceToken); } case StreamToken streamToken: { var properties = CopyToken(writer, streamToken.StreamDictionary, tokenScanner, referencesFromDocument, callstack) as DictionaryToken; Debug.Assert(properties != null); var bytes = streamToken.Data; return(new StreamToken(properties, bytes)); } case ObjectToken _: { // Since we don't write token directly to the stream. // We can't know the offset. Therefore the token would be invalid throw new NotSupportedException("Copying a Object token is not supported"); } } return(tokenToCopy); }
public override void SyntaxError(System.IO.TextWriter output, IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e) { StringBuilder builder = new StringBuilder(); // the human readable message object[] format = new object[] { line, charPositionInLine + 1 }; builder.AppendFormat(CultureInfo.CurrentCulture, "Error on line {0} at position {1}:\n", format); // the actual error message builder.AppendLine(msg); #if DEBUG builder.AppendLine($"Debug: Offending symbol type: {recognizer.Vocabulary.GetSymbolicName(offendingSymbol.Type)}"); #endif if (offendingSymbol.TokenSource != null) { // the line with the error on it string input = offendingSymbol.TokenSource.InputStream.ToString(); string[] lines = input.Split('\n'); string errorLine = lines[line - 1]; builder.AppendLine(errorLine); // adding indicator symbols pointing out where the error is // on the line int start = offendingSymbol.StartIndex; int stop = offendingSymbol.StopIndex; if (start >= 0 && stop >= 0) { // the end point of the error in "line space" int end = (stop - start) + charPositionInLine + 1; for (int i = 0; i < end; i++) { // move over until we are at the point we need to // be if (i >= charPositionInLine && i < end) { builder.Append("^"); } else { builder.Append(" "); } } } } throw new ParseException(null, builder.ToString(), null); }
public AdminController(IUser userStore, IUserRole userRoleStore, ITest testStore, IQuestion questionStore, IStudentAnswer studentAnswerStore, IToken tokenStore) { _userStore = userStore; _userRoleStore = userRoleStore; _testStore = testStore; _questionStore = questionStore; _studentAnswerStore = studentAnswerStore; _tokenStore = tokenStore; }
public void delete(string programName, IToken from, IToken to) { replace(programName, from, to, null); }
public void replace(IToken from, IToken to, string text) { replace(DEFAULT_PROGRAM_NAME, from, to, text); }
public void insertBefore(string programName, IToken t, string text) { insertBefore(programName, ((TokenWithIndex)t).getIndex(), text); }
public void delete(IToken indexT) { delete(DEFAULT_PROGRAM_NAME, indexT, indexT); }
public void insertAfter(IToken t, string text) { insertAfter(DEFAULT_PROGRAM_NAME, t, text); }
public void replace(IToken indexT, string text) { replace(DEFAULT_PROGRAM_NAME, indexT, indexT, text); }
public ICalendarComponent component( ISerializationContext ctx, ISerializerFactory sf, ICalendarComponentFactory cf, ICalendarObject o ) //throws RecognitionException, TokenStreamException { ICalendarComponent c = null;; IToken n = null; IToken m = null; match(BEGIN); match(COLON); { switch (LA(1)) { case IANA_TOKEN: { n = LT(1); match(IANA_TOKEN); c = cf.Build(n.getText().ToLower(), true); break; } case X_NAME: { m = LT(1); match(X_NAME); c = cf.Build(m.getText().ToLower(), true); break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } var processor = ctx.GetService(typeof(ISerializationProcessor <ICalendarComponent>)) as ISerializationProcessor <ICalendarComponent>; // Do some pre-processing on the component if (processor != null) { processor.PreDeserialization(c); } SerializationUtil.OnDeserializing(c); // Push the component onto the serialization context stack ctx.Push(c); if (o != null) { // Add the component as a child immediately, in case // embedded components need to access this component, // or the iCalendar itself. o.AddChild(c); } c.Line = n.getLine(); c.Column = n.getColumn(); { // ( ... )* for (;;) { if ((LA(1) == CRLF)) { match(CRLF); } else { goto _loop16_breakloop; } } _loop16_breakloop :; } // ( ... )* { // ( ... )* for (;;) { switch (LA(1)) { case IANA_TOKEN: case X_NAME: { property(ctx, c); break; } case BEGIN: { component(ctx, sf, cf, c); break; } default: { goto _loop18_breakloop; } } } _loop18_breakloop :; } // ( ... )* match(END); match(COLON); match(IANA_TOKEN); { // ( ... )* for (;;) { if ((LA(1) == CRLF)) { match(CRLF); } else { goto _loop20_breakloop; } } _loop20_breakloop :; } // ( ... )* // Do some final processing on the component if (processor != null) { processor.PostDeserialization(c); } // Notify that the component has been loaded c.OnLoaded(); SerializationUtil.OnDeserialized(c); // Pop the component off the serialization context stack ctx.Pop(); return(c); }
public void insertBefore(IToken t, string text) { insertBefore(DEFAULT_PROGRAM_NAME, t, text); }
public ConstructorNode(IToken token) : base(token) { }
public ICalendarParameter parameter( ISerializationContext ctx, ICalendarParameterCollectionContainer container ) //throws RecognitionException, TokenStreamException { ICalendarParameter p = null;; IToken n = null; IToken m = null; string v; var values = new List <string>(); { switch (LA(1)) { case IANA_TOKEN: { n = LT(1); match(IANA_TOKEN); p = new CalendarParameter(n.getText()); break; } case X_NAME: { m = LT(1); match(X_NAME); p = new CalendarParameter(m.getText()); break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } // Push the parameter onto the serialization context stack ctx.Push(p); match(EQUAL); v = param_value(); values.Add(v); { // ( ... )* for (;;) { if ((LA(1) == COMMA)) { match(COMMA); v = param_value(); values.Add(v); } else { goto _loop30_breakloop; } } _loop30_breakloop :; } // ( ... )* p.SetValue(values); if (container != null) { container.Parameters.Add(p); } // Notify that the parameter has been loaded p.OnLoaded(); // Pop the parameter off the serialization context stack ctx.Pop(); return(p); }
public SpotifyTokenChangedEventArgs(IToken oldToken, IToken newToken) { this.OldToken = oldToken; this.NewToken = newToken; }
public ICalendarProperty property( ISerializationContext ctx, ICalendarPropertyListContainer c ) //throws RecognitionException, TokenStreamException { ICalendarProperty p = null;; IToken n = null; IToken m = null; string v; { switch (LA(1)) { case IANA_TOKEN: { n = LT(1); match(IANA_TOKEN); p = new CalendarProperty(n.getLine(), n.getColumn()); p.Name = n.getText().ToUpper(); break; } case X_NAME: { m = LT(1); match(X_NAME); p = new CalendarProperty(m.getLine(), m.getColumn()); p.Name = m.getText().ToUpper(); break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } var processor = ctx.GetService(typeof(ISerializationProcessor <ICalendarProperty>)) as ISerializationProcessor <ICalendarProperty>; // Do some pre-processing on the property if (processor != null) { processor.PreDeserialization(p); } if (c != null) { // Add the property to the container, as the parent object(s) // may be needed during deserialization. c.Properties.Add(p); } // Push the property onto the serialization context stack ctx.Push(p); IStringSerializer dataMapSerializer = new DataMapSerializer(ctx); { // ( ... )* for (;;) { if ((LA(1) == SEMICOLON)) { match(SEMICOLON); parameter(ctx, p); } else { goto _loop24_breakloop; } } _loop24_breakloop :; } // ( ... )* match(COLON); v = value(); // Deserialize the value of the property // into a concrete iCalendar data type, // a list of concrete iCalendar data types, // or string value. var deserialized = dataMapSerializer.Deserialize(new StringReader(v)); if (deserialized != null) { // Try to determine if this is was deserialized as a *list* // of concrete types. var targetType = dataMapSerializer.TargetType; var listOfTargetType = typeof(IList <>).MakeGenericType(targetType); if (listOfTargetType.IsAssignableFrom(deserialized.GetType())) { // We deserialized a list - add each value to the // resulting object. foreach (var item in (IEnumerable)deserialized) { p.AddValue(item); } } else { // We deserialized a single value - add it to the object. p.AddValue(deserialized); } } { // ( ... )* for (;;) { if ((LA(1) == CRLF)) { match(CRLF); } else { goto _loop26_breakloop; } } _loop26_breakloop :; } // ( ... )* // Do some final processing on the property: if (processor != null) { processor.PostDeserialization(p); } // Notify that the property has been loaded p.OnLoaded(); // Pop the property off the serialization context stack ctx.Pop(); return(p); }
/// <summary> /// Creates a new Service clause with the given Endpoint Specifier and Graph Pattern /// </summary> /// <param name="endpointSpecifier">Endpoint Specifier</param> /// <param name="pattern">Graph Pattern</param> /// <param name="silent">Whether Evaluation Errors are suppressed</param> public Service(IToken endpointSpecifier, GraphPattern pattern, bool silent) { this._endpointSpecifier = endpointSpecifier; this._pattern = pattern; this._silent = silent; }
public SelectClause(IToken token) : base(token) { }
private void UpdateNavigationTargets(AntlrParseResultEventArgs antlrParseResultArgs) { Contract.Requires(antlrParseResultArgs != null); List <IEditorNavigationTarget> navigationTargets = new List <IEditorNavigationTarget>(); if (antlrParseResultArgs != null) { #if false IAstRuleReturnScope resultArgs = antlrParseResultArgs.Result as IAstRuleReturnScope; var result = resultArgs != null ? resultArgs.Tree as CommonTree : null; if (result != null) { foreach (CommonTree child in result.Children) { if (child == null || string.IsNullOrEmpty(child.Text)) { continue; } if (child.Text == "rule" && child.ChildCount > 0) { var ruleName = child.GetChild(0).Text; if (string.IsNullOrEmpty(ruleName)) { continue; } if (ruleName == "Tokens") { continue; } var navigationType = char.IsUpper(ruleName[0]) ? _lexerRuleNavigationType : _parserRuleNavigationType; IToken startToken = antlrParseResultArgs.Tokens[child.TokenStartIndex]; IToken stopToken = antlrParseResultArgs.Tokens[child.TokenStopIndex]; Span span = new Span(startToken.StartIndex, stopToken.StopIndex - startToken.StartIndex + 1); SnapshotSpan ruleSpan = new SnapshotSpan(antlrParseResultArgs.Snapshot, span); SnapshotSpan ruleSeek = new SnapshotSpan(antlrParseResultArgs.Snapshot, new Span(((CommonTree)child.GetChild(0)).Token.StartIndex, 0)); var glyph = char.IsUpper(ruleName[0]) ? _lexerRuleGlyph : _parserRuleGlyph; navigationTargets.Add(new EditorNavigationTarget(ruleName, navigationType, ruleSpan, ruleSeek, glyph)); } else if (child.Text.StartsWith("tokens")) { foreach (CommonTree tokenChild in child.Children) { if (tokenChild.Text == "=" && tokenChild.ChildCount == 2) { var ruleName = tokenChild.GetChild(0).Text; if (string.IsNullOrEmpty(ruleName)) { continue; } var navigationType = char.IsUpper(ruleName[0]) ? _lexerRuleNavigationType : _parserRuleNavigationType; IToken startToken = antlrParseResultArgs.Tokens[tokenChild.TokenStartIndex]; IToken stopToken = antlrParseResultArgs.Tokens[tokenChild.TokenStopIndex]; Span span = new Span(startToken.StartIndex, stopToken.StopIndex - startToken.StartIndex + 1); SnapshotSpan ruleSpan = new SnapshotSpan(antlrParseResultArgs.Snapshot, span); SnapshotSpan ruleSeek = new SnapshotSpan(antlrParseResultArgs.Snapshot, new Span(((CommonTree)tokenChild.GetChild(0)).Token.StartIndex, 0)); var glyph = char.IsUpper(ruleName[0]) ? _lexerRuleGlyph : _parserRuleGlyph; navigationTargets.Add(new EditorNavigationTarget(ruleName, navigationType, ruleSpan, ruleSeek, glyph)); } else if (tokenChild.ChildCount == 0) { var ruleName = tokenChild.Text; if (string.IsNullOrEmpty(ruleName)) { continue; } var navigationType = char.IsUpper(ruleName[0]) ? _lexerRuleNavigationType : _parserRuleNavigationType; IToken startToken = antlrParseResultArgs.Tokens[tokenChild.TokenStartIndex]; IToken stopToken = antlrParseResultArgs.Tokens[tokenChild.TokenStopIndex]; Span span = new Span(startToken.StartIndex, stopToken.StopIndex - startToken.StartIndex + 1); SnapshotSpan ruleSpan = new SnapshotSpan(antlrParseResultArgs.Snapshot, span); SnapshotSpan ruleSeek = new SnapshotSpan(antlrParseResultArgs.Snapshot, new Span(tokenChild.Token.StartIndex, 0)); var glyph = char.IsUpper(ruleName[0]) ? _lexerRuleGlyph : _parserRuleGlyph; navigationTargets.Add(new EditorNavigationTarget(ruleName, navigationType, ruleSpan, ruleSeek, glyph)); } } } } } #endif } this._navigationTargets = navigationTargets; OnNavigationTargetsChanged(EventArgs.Empty); }
/// <summary> /// Creates a new Service clause with the given Endpoint Specifier and Graph Pattern /// </summary> /// <param name="endpointSpecifier">Endpoint Specifier</param> /// <param name="pattern">Graph Pattern</param> public Service(IToken endpointSpecifier, GraphPattern pattern) : this(endpointSpecifier, pattern, false) { }
public static HasTokenizerIdTokenDecoration <T> HasTokenizerId <T>(this IToken <T> thing, string tokenizerId) { Condition.Requires(thing).IsNotNull(); return(new HasTokenizerIdTokenDecoration <T>(thing, tokenizerId)); }
public VariableDecNode(IToken t) : base(t) { }
public static HasTokenizerIdTokenDecoration <T> New(IToken <T> decorated, string tokenizerId) { return(new HasTokenizerIdTokenDecoration <T>(decorated, tokenizerId)); }
public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e) { throw new NFSdbSyntaxException(msg, line, charPositionInLine, e); }
public PosNode(IToken o) : base(o) { }
public override IDecorationOf <IToken <T> > ApplyThisDecorationTo(IToken <T> thing) { return(new HasTokenizerIdTokenDecoration <T>(thing, this.TokenizerId)); }
public AverageNode(Type inputType, IToken payload, TreeNodeFactory treeNodeFactory) : base(inputType, payload, treeNodeFactory) { }
public HasTokenizerIdTokenDecoration(IToken <T> decorated, string tokenizerId) : base(decorated) { Condition.Requires(tokenizerId).IsNotNullOrEmpty(); this.TokenizerId = tokenizerId; }