From ec3626d1133f4e473dcea990b628fe5c25d2a0c1 Mon Sep 17 00:00:00 2001
From: Anders Nilsson <anders.nilsson@cs.lth.se>
Date: Mon, 27 Nov 2006 17:00:23 +0100
Subject: [PATCH] Synching. Soon, maybe, string elements can be parsed OK

---
 CompilerGeneration.jrag            |  2 +-
 siaras/Siaras.jjt                  | 61 ++++++++++++++++++++++--------
 testontologies/phony_instances.owl |  2 +-
 3 files changed, 47 insertions(+), 18 deletions(-)

diff --git a/CompilerGeneration.jrag b/CompilerGeneration.jrag
index 1bb803d..0b429de 100644
--- a/CompilerGeneration.jrag
+++ b/CompilerGeneration.jrag
@@ -18,7 +18,7 @@ aspect AbsGrammarGeneration {
  		pStream.println("ComplexElement : Element ::=  OwlIdentifier Attribute* Element*;");
 // 		pStream.println("ComplexElement ::=  id1:OwlIdentifier id2:OwlIdentifier;");
 		pStream.println("abstract SimpleElement : Element;");
-		pStream.println("StringElement : SimpleElement ::= <IDENTIFIER>;");
+		pStream.println("StringElement : SimpleElement ::= OwlIdentifier;");
 		pStream.println("IntElement : SimpleElement ::= <INTEGER_LITERAL>;");
 		pStream.println("FloatElement : SimpleElement ::= <FLOAT_LITERAL>;");
 		pStream.println("Attribute ::= Value;");
diff --git a/siaras/Siaras.jjt b/siaras/Siaras.jjt
index dc33755..44bcfe5 100644
--- a/siaras/Siaras.jjt
+++ b/siaras/Siaras.jjt
@@ -234,9 +234,10 @@ SPECIAL_TOKEN : /* COMMENTS */
 <DEFAULT,BOUNDS> TOKEN : /* OPERATORS */
 {
       < ASSIGN               : "="    >
-     | < GT                   : ">"    >
-     | < LT                   : "<"    >
-     | < END_TAG              : "/>"   >
+     | < END_TAG             : ">"    >
+     | < START_ENDTAG        : "</"    >
+     | < START_TAG           : "<"    >
+     | < END_TAGS            : "/>"   >
 //     | < BANG                 : "!"    >
 //     | < TILDE                : "~"    >
 //     | < HOOK                 : "?"    >
@@ -249,10 +250,10 @@ SPECIAL_TOKEN : /* COMMENTS */
 //     | < SC_AND               : "&&"   >
 //     | < INCR                 : "++"   >
 //     | < DECR                 : "--"   >
-//     | < PLUS                 : "+"    >
-//     | < MINUS                : "-"    >
+     | < PLUS                 : "+"    >
+     | < MINUS                : "-"    >
 //     | < STAR                 : "*"    >
-//     | < SLASH                : "/"    >
+     | < SLASH                : "/"    >
 //     | < BIT_AND              : "&"    >
 //     | < BIT_OR               : "|"    >
 //     | < XOR                  : "^"    >
@@ -274,12 +275,12 @@ SPECIAL_TOKEN : /* COMMENTS */
 }// OPERATORS
 
 
-<DEFAULT,BOUNDS> TOKEN : /* TEXT */
-{
-    < VALUE_LITERAL:
-        (<LETTER> | <DIGIT>) ( ~["<"] )*
-    >
-}// TEXT
+// <VALUESTATE,BOUNDS> TOKEN : /* TEXT */
+// {
+//     < VALUE_LITERAL:
+//         (<LETTER> | <DIGIT>) ( ~["<"] )*
+//     >
+// }// TEXT
 
 
 
@@ -347,7 +348,8 @@ void SimpleElement() : {}
 {
     IntElement()
 	| FloatElement()
-	| StringElement()
+//    	| LOOKAHEAD({getToken(1).kind != START_ENDTAG}) StringElement()
+  	| StringElement()
 }
 
 void IntElement() #IntElement : { Token t; }
@@ -362,10 +364,37 @@ void FloatElement() #FloatElement : { Token t; }
 	{jjtThis.setFLOAT_LITERAL(t.image);}
 }
 
-void StringElement() #StringElement : { Token t; }
+// JAVACODE
+// public  void StringElement()  {
+// 	StringElement se = new StringElement();
+// 	Token tok;
+// 	StringBuffer buf = new StringBuffer();
+// 	jjtree.openNodeScope(se);
+// 	try {
+// 		while (true) {
+// 			tok = getToken(1);
+// 			if (tok.kind == START_ENDTAG) break;
+// 			if (tok.kind == EOF) throw new ParseException();
+// 			buf.append(tok.image);
+// 			tok = getNextToken();
+// 		}
+// 	} finally {
+// 		jjtree.closeNodeScope(se,true);
+// 		se.setIDENTIFIER(buf.toString());
+// 	}
+// }
+
+void StringElement() #StringElement : {} //{ Token t; }
+{
+	Identifier()
+// 	WordList()
+//     t = <VALUE_LITERAL>
+// 	{jjtThis.setIDENTIFIER(t.image);}
+}
+
+void WordList() #List : {}
 {
-    t = <VALUE_LITERAL>
-	{jjtThis.setIDENTIFIER(t.image);}
+	Identifier() ( Identifier() )*
 }
 
 // void OwlElement() : {}
diff --git a/testontologies/phony_instances.owl b/testontologies/phony_instances.owl
index 102716d..ffa1a86 100644
--- a/testontologies/phony_instances.owl
+++ b/testontologies/phony_instances.owl
@@ -1,4 +1,4 @@
 <VacuumGripper>
-1
+Hej Världen
 </VacuumGripper>
 
-- 
GitLab