Eq: 'eq' value=STRING | NUMBER |NULL; NUMBER: '-'? INT ('.' INT)?; terminal NULL: 'null';
@Test public void parseNull() { final String value = null; String expression = "eq"+ value; //parsing... Eq eq; assertThat(eq.getValue()).isEqualTo(value); }
that sounds like a parse error?!?
the question is your semantic?
wouldnt it be better to have a StringLiteral, a NumberLiteral, and Null as separate types?
Eq: 'eq' '(' attribute=FIELD_VALUE ',' value=STRING | INT | NULL')';
Eq: EqString | EqInt ... EqString: 'eq' '(' attribute=FIELD_VALUE ',' value=STRING')'; EqInt: 'eq' '(' attribute=FIELD_VALUE ',' value=INT')';
that sounds like a parse error?!?
the question is your semantic?
wouldnt it be better to have a StringLiteral, a NumberLiteral, and Null as separate types?
Eq: 'eq' '(' attribute=FIELD_VALUE ',' value=STRING | INT | NULL')';
Eq: EqString | EqInt ... EqString: 'eq' '(' attribute=FIELD_VALUE ',' value=STRING')'; EqInt: 'eq' '(' attribute=FIELD_VALUE ',' value=INT')';
that sounds like a parse error?!?
the question is your semantic?
wouldnt it be better to have a StringLiteral, a NumberLiteral, and Null as separate types?
Eq: 'eq' '(' attribute=FIELD_VALUE ',' value=STRING | INT | NULL')';
Eq: EqString | EqInt ... EqString: 'eq' '(' attribute=FIELD_VALUE ',' value=STRING')'; EqInt: 'eq' '(' attribute=FIELD_VALUE ',' value=INT')';
that sounds like a parse error?!?
the question is your semantic?
wouldnt it be better to have a StringLiteral, a NumberLiteral, and Null as separate types?
Eq: 'eq' '(' attribute=FIELD_VALUE ',' value=STRING | INT | NULL')';
Eq: EqString | EqInt ... EqString: 'eq' '(' attribute=FIELD_VALUE ',' value=STRING')'; EqInt: 'eq' '(' attribute=FIELD_VALUE ',' value=INT')';
i mean something like
Eq: 'eq' '(' attribute=FIELD_VALUE ',' value=Literal ')'; Literal: (StringOrNumberLiteral | BOOLEAN | NULL); StringOrNumberLiteral: STRING | NUMBER; NUMBER: '-'? INT ('.' INT)?; terminal BOOLEAN returns ecore::EBoolean: 'true' | 'false'; terminal NULL: 'null'; terminal FIELD_VALUE: ('A'..'Z' | 'a'..'z') ('A'..'Z' | 'a'..'z' | '0'..'9' | '.' | '_' | '-')*;
And Whats your actual question
class Eq String getValue()
class Eq EObject getValue()
class In List<Strings> getValues()
As I said. Make the literals eobjects
By using assignments
Then you can instanceof
if (at all) the type would be EObject? or do you mean java.lang.Object? if yes what do you want to fill it with?
EObject getValue();
why do you want to?
assertThat(inFilter.getValues()).contains("a", "b");
Literal returns ecore::EJavaObject: StringOrNumberLiteral | BOOLEAN | NULL; StringOrNumberLiteral returns ecore::EJavaObject: (STRING | NUMBER);
and how does the grammar look like. maybe you did something wrong
Literal returns ecore::EObject: (StringOrNumberLiteral | BooleanValue | NullValue); StringOrNumberLiteral returns ecore::EObject: (StringLiteral | NumberValue); StringLiteral returns ecore::EObject: StringValue; StringValue: value = STRING; NumberValue: value = DOUBLE; BooleanValue: value = BOOLEAN; NullValue: value = NULL;
value=(STRING | INT) Object getValue()
no i meant
Literal:
(StringOrNumberLiteral | BooleanValue | NullValue);
StringOrNumberLiteral:
(StringLiteral | NumberValue);
StringLiteral:
value = STRING;
NumberValue:
value = DOUBLE;
BooleanValue:
value = BOOLEAN;
NullValue:
value = NULL;
StringLiteral literal = (StringLiteral) eq.getLiteral(); assertThat(literal.getValue()).isEqualTo("4711");