Commit 54c2b20f authored by Anders Nilsson's avatar Anders Nilsson

Modified StringElement so that it can handle also strings with double quotes (") within

parent 0c656895
......@@ -48,9 +48,9 @@ OwlRestriction : ComplexElement;
OwlUnionOf : ComplexElement;
abstract SimpleElement : Element;
StringElement : SimpleElement ::= <IDENTIFIER>;
IntElement : SimpleElement ::= <INTEGER_LITERAL>;
FloatElement : SimpleElement ::= <FLOAT_LITERAL>;
StringElement : SimpleElement ::= <LITERAL>;
IntElement : SimpleElement ::= <LITERAL>;
FloatElement : SimpleElement ::= <LITERAL>;
abstract Attribute ::= Value;
Version : Attribute;
......
......@@ -196,7 +196,11 @@ SPECIAL_TOKEN : /* COMMENTS */
"\u3300"-"\u337f",
"\u3400"-"\u3d2d",
"\u4e00"-"\u9fff",
"\uf900"-"\ufaff"
"\uf900"-"\ufaff",
"+",
"-",
",",
"."
]
>
|
......@@ -230,14 +234,17 @@ SPECIAL_TOKEN : /* COMMENTS */
| < LBRACKET : "[" >
| < RBRACKET : "]" >
| < SEMICOLON : ";" >
| < COMMA : "," >
| < DOT : "." >
| < QUOTE : "\"" >
// | < COMMA : "," >
// | < DOT : "." >
}// SEPARATORS
<DEFAULT,BOUNDS> TOKEN : /* OPERATORS */
{
< ASSIGN : "=" >
< ASSIGN : "=" >
| < START_ENDTAG : "</" >
| < START_TAG : "<" >
// | < GT : ">" >
// | < LT : "<" >
// | < BANG : "!" >
......@@ -252,8 +259,8 @@ SPECIAL_TOKEN : /* COMMENTS */
// | < SC_AND : "&&" >
// | < INCR : "++" >
// | < DECR : "--" >
| < PLUS : "+" >
| < MINUS : "-" >
// | < PLUS : "+" >
// | < MINUS : "-" >
// | < STAR : "*" >
| < SLASH : "/" >
// | < BIT_AND : "&" >
......@@ -347,21 +354,54 @@ void SimpleElement() : {}
void IntElement() #IntElement : { Token t; }
{
t = <INTEGER_LITERAL>
{jjtThis.setINTEGER_LITERAL(t.image);}
{jjtThis.setLITERAL(t.image);}
}
void FloatElement() #FloatElement : { Token t; }
{
t = <FLOAT_LITERAL>
{jjtThis.setFLOAT_LITERAL(t.image);}
{jjtThis.setLITERAL(t.image);}
}
void StringElement() #StringElement : { Token t; }
void StringElement() #StringElement : { Token t;String s; }
{
t = <IDENTIFIER> | t = <COMMA> | t = <MINUS> | t = <DOT> | t = <PLUS> | t = <SLASH>
| t = <COLON>
{jjtThis.setIDENTIFIER(t.image);}
}
t = <IDENTIFIER>
{
s = t.image;
if (getToken(1).kind != START_TAG ) {
s += getData();
}
}
{jjtThis.setLITERAL(s);}
}
JAVACODE
String getData() {
StringBuffer s = new StringBuffer();
// jjtThis.someData = true;
while ((getToken(1)).kind != START_TAG && (getToken(1)).kind != START_ENDTAG) {
Token t = getNextToken();
if (t.specialToken != null) {
Token tmp_t = t.specialToken;
while (tmp_t.specialToken != null) {
tmp_t = tmp_t.specialToken;
}
while (tmp_t != null) {
s.append(tmp_t.image);
tmp_t = tmp_t.next;
}
}
s.append(t.image);
}
return s.toString();
}
// void StringElement() #StringElement : { Token t; }
// {
// t = <IDENTIFIER> | t = <COMMA> | t = <MINUS> | t = <DOT> | t = <PLUS> | t = <SLASH>
// | t = <COLON>
// {jjtThis.setIDENTIFIER(t.image);}
// }
void OwlElement() : {}
{
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment