use of antlr.Token in project jasn1 by openmuc.
the class ASNLexer method mWS.
public final void mWS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype;
Token _token = null;
int _begin = text.length();
_ttype = WS;
int _saveIndex;
{
int _cnt29 = 0;
_loop29: do {
switch(LA(1)) {
case ' ':
{
match(' ');
break;
}
case '\t':
{
match('\t');
break;
}
case '\u000c':
{
match('\f');
break;
}
case '\n':
case '\r':
{
{
if ((LA(1) == '\r') && (LA(2) == '\n') && (true) && (true) && (true) && (true) && (true) && (true) && (true) && (true) && (true)) {
match("\r\n");
if (inputState.guessing == 0) {
newline();
}
} else if ((LA(1) == '\r') && (true) && (true) && (true) && (true) && (true) && (true) && (true) && (true) && (true) && (true)) {
match('\r');
if (inputState.guessing == 0) {
newline();
}
} else if ((LA(1) == '\n')) {
match('\n');
if (inputState.guessing == 0) {
newline();
}
} else {
throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn());
}
}
break;
}
default:
{
if (_cnt29 >= 1) {
break _loop29;
} else {
throw new NoViableAltForCharException((char) LA(1), getFilename(), getLine(), getColumn());
}
}
}
_cnt29++;
} while (true);
}
if (inputState.guessing == 0) {
_ttype = Token.SKIP;
}
if (_createToken && _token == null && _ttype != Token.SKIP) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length() - _begin));
}
_returnToken = _token;
}
use of antlr.Token in project jasn1 by openmuc.
the class ASNParser method syntaxTokens.
public final List<String> syntaxTokens() throws RecognitionException, TokenStreamException {
List<String> syntaxTokens;
Token up = null;
Token lo = null;
Token num = null;
syntaxTokens = new ArrayList<String>();
try {
// for error handling
{
_loop159: do {
switch(LA(1)) {
case UPPER:
{
up = LT(1);
match(UPPER);
if (inputState.guessing == 0) {
syntaxTokens.add(up.getText());
}
break;
}
case LOWER:
{
lo = LT(1);
match(LOWER);
if (inputState.guessing == 0) {
syntaxTokens.add(lo.getText());
}
break;
}
case COMMA:
{
match(COMMA);
if (inputState.guessing == 0) {
syntaxTokens.add(",");
}
break;
}
case AMPERSAND:
{
match(AMPERSAND);
if (inputState.guessing == 0) {
syntaxTokens.add("&");
}
break;
}
case C_STRING:
{
match(C_STRING);
break;
}
case DOT:
{
match(DOT);
break;
}
case NULL_KW:
{
match(NULL_KW);
break;
}
case BY_KW:
{
match(BY_KW);
if (inputState.guessing == 0) {
syntaxTokens.add("BY");
}
break;
}
case NUMBER:
{
num = LT(1);
match(NUMBER);
if (inputState.guessing == 0) {
syntaxTokens.add(num.getText());
}
break;
}
case L_PAREN:
{
match(L_PAREN);
if (inputState.guessing == 0) {
syntaxTokens.add("(");
}
break;
}
case R_PAREN:
{
match(R_PAREN);
if (inputState.guessing == 0) {
syntaxTokens.add(")");
}
break;
}
default:
{
break _loop159;
}
}
} while (true);
}
} catch (RecognitionException ex) {
if (inputState.guessing == 0) {
reportError(ex);
recover(ex, _tokenSet_32);
} else {
throw ex;
}
}
return syntaxTokens;
}
use of antlr.Token in project jasn1 by openmuc.
the class ASNParser method objectClassElement.
public final AsnElementType objectClassElement() throws RecognitionException, TokenStreamException {
AsnElementType eletyp;
Token lid = null;
Token up = null;
eletyp = new AsnElementType();
AsnValue val;
AsnType obj;
AsnTag tg;
String s;
try {
// for error handling
{
if ((LA(1) == AMPERSAND) && (LA(2) == LOWER)) {
{
{
{
match(AMPERSAND);
{
lid = LT(1);
match(LOWER);
if (inputState.guessing == 0) {
eletyp.name = lid.getText();
}
}
{
obj = type();
}
{
switch(LA(1)) {
case UNIQUE_KW:
{
match(UNIQUE_KW);
break;
}
case DEFAULT_KW:
case OPTIONAL_KW:
case COMMA:
case R_BRACE:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
{
switch(LA(1)) {
case OPTIONAL_KW:
{
{
match(OPTIONAL_KW);
if (inputState.guessing == 0) {
eletyp.isOptional = true;
}
}
break;
}
case DEFAULT_KW:
{
{
match(DEFAULT_KW);
if (inputState.guessing == 0) {
eletyp.isDefault = true;
}
val = value();
if (inputState.guessing == 0) {
eletyp.value = val;
}
}
break;
}
case COMMA:
case R_BRACE:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
}
}
if (inputState.guessing == 0) {
if ((AsnDefinedType.class).isInstance(obj)) {
eletyp.isDefinedType = true;
eletyp.definedType = (AsnDefinedType) obj;
} else {
eletyp.typeReference = obj;
}
}
}
} else if ((LA(1) == AMPERSAND) && (LA(2) == UPPER)) {
{
match(AMPERSAND);
{
up = LT(1);
match(UPPER);
if (inputState.guessing == 0) {
eletyp.name = up.getText();
eletyp.typeReference = new AsnAny();
}
}
}
} else {
throw new NoViableAltException(LT(1), getFilename());
}
}
} catch (RecognitionException ex) {
if (inputState.guessing == 0) {
reportError(ex);
recover(ex, _tokenSet_33);
} else {
throw ex;
}
}
return eletyp;
}
use of antlr.Token in project jasn1 by openmuc.
the class ASNParser method value.
public final AsnValue value() throws RecognitionException, TokenStreamException {
AsnValue value;
Token c = null;
value = new AsnValue();
AsnSequenceValue seqval;
AsnDefinedValue defval;
String aStr;
AsnSignedNumber num;
AsnOidComponentList cmplst;
List<String> valueInBracesTokens;
try {
// for error handling
switch(LA(1)) {
case TRUE_KW:
{
{
match(TRUE_KW);
if (inputState.guessing == 0) {
value.isTrueKW = true;
}
}
break;
}
case FALSE_KW:
{
{
match(FALSE_KW);
if (inputState.guessing == 0) {
value.isFalseKW = true;
}
}
break;
}
case NULL_KW:
{
{
match(NULL_KW);
if (inputState.guessing == 0) {
value.isNullKW = true;
}
}
break;
}
case C_STRING:
{
{
c = LT(1);
match(C_STRING);
if (inputState.guessing == 0) {
value.isCString = true;
value.cStr = c.getText();
}
}
break;
}
case MINUS:
case NUMBER:
{
{
num = signed_number();
if (inputState.guessing == 0) {
value.isSignedNumber = true;
value.signedNumber = num;
}
}
break;
}
case PLUS_INFINITY_KW:
{
{
match(PLUS_INFINITY_KW);
if (inputState.guessing == 0) {
value.isPlusInfinity = true;
}
}
break;
}
case MINUS_INFINITY_KW:
{
{
match(MINUS_INFINITY_KW);
if (inputState.guessing == 0) {
value.isMinusInfinity = true;
}
}
break;
}
default:
boolean synPredMatched431 = false;
if (((LA(1) == UPPER || LA(1) == LOWER) && (_tokenSet_34.member(LA(2))) && (_tokenSet_35.member(LA(3))))) {
int _m431 = mark();
synPredMatched431 = true;
inputState.guessing++;
try {
{
defined_value();
}
} catch (RecognitionException pe) {
synPredMatched431 = false;
}
rewind(_m431);
inputState.guessing--;
}
if (synPredMatched431) {
{
defval = defined_value();
if (inputState.guessing == 0) {
value.isDefinedValue = true;
value.definedValue = defval;
}
}
} else {
boolean synPredMatched437 = false;
if (((LA(1) == LOWER) && (_tokenSet_30.member(LA(2))) && (_tokenSet_36.member(LA(3))))) {
int _m437 = mark();
synPredMatched437 = true;
inputState.guessing++;
try {
{
choice_value(value);
}
} catch (RecognitionException pe) {
synPredMatched437 = false;
}
rewind(_m437);
inputState.guessing--;
}
if (synPredMatched437) {
{
choice_value(value);
if (inputState.guessing == 0) {
value.isChoiceValue = true;
}
}
} else {
boolean synPredMatched440 = false;
if (((LA(1) == L_BRACE) && (LA(2) == COMMA || LA(2) == R_BRACE || LA(2) == LOWER) && (_tokenSet_37.member(LA(3))))) {
int _m440 = mark();
synPredMatched440 = true;
inputState.guessing++;
try {
{
sequence_value();
}
} catch (RecognitionException pe) {
synPredMatched440 = false;
}
rewind(_m440);
inputState.guessing--;
}
if (synPredMatched440) {
{
seqval = sequence_value();
if (inputState.guessing == 0) {
value.isSequenceValue = true;
value.seqval = seqval;
}
}
} else {
boolean synPredMatched443 = false;
if (((LA(1) == L_BRACE) && (_tokenSet_38.member(LA(2))) && (_tokenSet_36.member(LA(3))))) {
int _m443 = mark();
synPredMatched443 = true;
inputState.guessing++;
try {
{
sequenceof_value(value);
}
} catch (RecognitionException pe) {
synPredMatched443 = false;
}
rewind(_m443);
inputState.guessing--;
}
if (synPredMatched443) {
{
sequenceof_value(value);
if (inputState.guessing == 0) {
value.isSequenceOfValue = true;
}
}
} else {
boolean synPredMatched446 = false;
if (((LA(1) == L_BRACE || LA(1) == B_STRING || LA(1) == H_STRING) && (_tokenSet_37.member(LA(2))) && (_tokenSet_35.member(LA(3))))) {
int _m446 = mark();
synPredMatched446 = true;
inputState.guessing++;
try {
{
cstr_value(value);
}
} catch (RecognitionException pe) {
synPredMatched446 = false;
}
rewind(_m446);
inputState.guessing--;
}
if (synPredMatched446) {
{
cstr_value(value);
if (inputState.guessing == 0) {
value.isCStrValue = true;
}
}
} else {
boolean synPredMatched449 = false;
if (((LA(1) == L_BRACE) && ((LA(2) >= NUMBER && LA(2) <= LOWER)) && (_tokenSet_5.member(LA(3))))) {
int _m449 = mark();
synPredMatched449 = true;
inputState.guessing++;
try {
{
obj_id_comp_lst();
}
} catch (RecognitionException pe) {
synPredMatched449 = false;
}
rewind(_m449);
inputState.guessing--;
}
if (synPredMatched449) {
{
cmplst = obj_id_comp_lst();
if (inputState.guessing == 0) {
value.isAsnOIDValue = true;
value.oidval = cmplst;
}
}
} else {
throw new NoViableAltException(LT(1), getFilename());
}
}
}
}
}
}
}
} catch (RecognitionException ex) {
if (inputState.guessing == 0) {
reportError(ex);
recover(ex, _tokenSet_37);
} else {
throw ex;
}
}
return value;
}
use of antlr.Token in project jasn1 by openmuc.
the class ASNParser method obj_id_component.
public final AsnOidComponent obj_id_component() throws RecognitionException, TokenStreamException {
AsnOidComponent oidcmp;
Token num = null;
Token lid = null;
Token num1 = null;
oidcmp = new AsnOidComponent();
AsnDefinedValue defval;
String s, n = "";
try {
// for error handling
{
if ((LA(1) == NUMBER)) {
{
num = LT(1);
match(NUMBER);
if (inputState.guessing == 0) {
s = num.getText();
oidcmp.num = new Integer(s);
oidcmp.numberForm = true;
}
}
} else {
boolean synPredMatched99 = false;
if (((LA(1) == LOWER) && (_tokenSet_9.member(LA(2))) && (_tokenSet_6.member(LA(3))))) {
int _m99 = mark();
synPredMatched99 = true;
inputState.guessing++;
try {
{
match(LOWER);
{
if ((LA(1) == L_PAREN)) {
match(L_PAREN);
match(NUMBER);
match(R_PAREN);
} else {
}
}
}
} catch (RecognitionException pe) {
synPredMatched99 = false;
}
rewind(_m99);
inputState.guessing--;
}
if (synPredMatched99) {
{
{
lid = LT(1);
match(LOWER);
if (inputState.guessing == 0) {
oidcmp.name = lid.getText();
oidcmp.nameForm = true;
}
}
{
switch(LA(1)) {
case L_PAREN:
{
match(L_PAREN);
{
num1 = LT(1);
match(NUMBER);
if (inputState.guessing == 0) {
n = num1.getText();
oidcmp.num = new Integer(n);
oidcmp.nameAndNumberForm = true;
}
}
match(R_PAREN);
break;
}
case R_BRACE:
case NUMBER:
case UPPER:
case LOWER:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
}
} else {
boolean synPredMatched105 = false;
if (((LA(1) == UPPER || LA(1) == LOWER) && (_tokenSet_10.member(LA(2))) && (_tokenSet_6.member(LA(3))))) {
int _m105 = mark();
synPredMatched105 = true;
inputState.guessing++;
try {
{
defined_value();
}
} catch (RecognitionException pe) {
synPredMatched105 = false;
}
rewind(_m105);
inputState.guessing--;
}
if (synPredMatched105) {
{
defval = defined_value();
if (inputState.guessing == 0) {
oidcmp.isDefinedValue = true;
oidcmp.defval = defval;
}
}
} else {
throw new NoViableAltException(LT(1), getFilename());
}
}
}
}
} catch (RecognitionException ex) {
if (inputState.guessing == 0) {
reportError(ex);
recover(ex, _tokenSet_11);
} else {
throw ex;
}
}
return oidcmp;
}
Aggregations