001// $ANTLR 2.7.7 (20060906): "schema-extension.g" -> "AntlrSchemaExtensionParser.java"$ 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 * 021 */ 022package org.apache.directory.api.ldap.model.schema.syntaxes; 023 024import java.io.StringReader; 025import java.util.List; 026 027 028import antlr.TokenBuffer; 029import antlr.TokenStreamException; 030import antlr.TokenStreamIOException; 031import antlr.ANTLRException; 032import antlr.LLkParser; 033import antlr.Token; 034import antlr.TokenStream; 035import antlr.RecognitionException; 036import antlr.NoViableAltException; 037import antlr.MismatchedTokenException; 038import antlr.SemanticException; 039import antlr.ParserSharedInputState; 040import antlr.collections.impl.BitSet; 041 042/** 043 * An antlr generated schema parser. This is a sub-parser used to parse 044 * extensions according to RFC4512. 045 * 046 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 047 */ 048public class AntlrSchemaExtensionParser extends antlr.LLkParser implements AntlrSchemaExtensionTokenTypes 049 { 050 051protected AntlrSchemaExtensionParser(TokenBuffer tokenBuf, int k) { 052 super(tokenBuf,k); 053 tokenNames = _tokenNames; 054} 055 056public AntlrSchemaExtensionParser(TokenBuffer tokenBuf) { 057 this(tokenBuf,3); 058} 059 060protected AntlrSchemaExtensionParser(TokenStream lexer, int k) { 061 super(lexer,k); 062 tokenNames = _tokenNames; 063} 064 065public AntlrSchemaExtensionParser(TokenStream lexer) { 066 this(lexer,3); 067} 068 069public AntlrSchemaExtensionParser(ParserSharedInputState state) { 070 super(state,3); 071 tokenNames = _tokenNames; 072} 073 074/** 075 * extensions = *( SP xstring SP qdstrings ) 076 * xstring = "X" HYPHEN 1*( ALPHA / HYPHEN / USCORE ) 077 */ 078 public final AntlrSchemaParser.Extension extension() throws RecognitionException, TokenStreamException { 079 AntlrSchemaParser.Extension extension = new AntlrSchemaParser.Extension(); 080 081 Token xkey = null; 082 Token xvalues = null; 083 084 { 085 xkey = LT(1); 086 match(XKEY); 087 extension.key = xkey.getText(); 088 } 089 { 090 xvalues = LT(1); 091 match(XVALUES); 092 extension.values = qdstrings(xvalues.getText()); 093 } 094 return extension; 095 } 096 097 public final List<String> qdstrings( 098 String s 099 ) throws RecognitionException, TokenStreamException { 100 List<String> qdstrings; 101 102 103 try 104 { 105 AntlrSchemaQdstringLexer lexer = new AntlrSchemaQdstringLexer(new StringReader(s)); 106 AntlrSchemaQdstringParser parser = new AntlrSchemaQdstringParser(lexer); 107 qdstrings = parser.qdstrings(); 108 } 109 catch (RecognitionException re) { 110 re.printStackTrace(); 111 throw re; 112 } 113 catch (TokenStreamException tse) { 114 tse.printStackTrace(); 115 throw tse; 116 } 117 118 119 return qdstrings; 120 } 121 122 123 public static final String[] _tokenNames = { 124 "<0>", 125 "EOF", 126 "<2>", 127 "NULL_TREE_LOOKAHEAD", 128 "WHSP", 129 "QUOTE", 130 "XKEY", 131 "XVALUES", 132 "XSTRING", 133 "VALUES", 134 "VALUE", 135 "QUOTED_STRING" 136 }; 137 138 139 }