Author: abelevich
Date: 2008-10-08 05:06:41 -0400 (Wed, 08 Oct 2008)
New Revision: 10688
Added:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/
trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamSample.java
trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/html-seam.g
Log:
initial commit: antlr grammar sample
Added: trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamSample.java
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamSample.java
(rev 0)
+++
trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/HtmlSeamSample.java 2008-10-08
09:06:41 UTC (rev 10688)
@@ -0,0 +1,50 @@
+package org.richfaces.antlr;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+
+import org.jboss.seam.text.SeamTextLexer;
+import org.jboss.seam.text.SeamTextParser;
+
+import antlr.ANTLRException;
+
+/*
+ * html --> seam text sample
+ *
+ *
+ */
+
+public class HtmlSeamSample {
+
+ public static void main(String[] args) throws ANTLRException, IOException {
+ System.out.println("Enter one or several lines of text. Type \"go\"
at new line when done");
+ System.out.println();
+
+ BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+
+ String line = "";
+ String bufLine;
+
+ while ((bufLine = in.readLine()) != null) {
+ if (!"go".equals(bufLine)) {
+ if (line.length() > 0) {
+ line += "\n";
+ }
+ line += bufLine;
+
+ } else {
+// SeamTextParser parser = new SeamTextParser(new SeamTextLexer(new
StringReader(line)));
+ line = "";
+ try {
+// parser.startRule();
+// System.out.println(parser.toString());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+}
Added: trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/html-seam.g
===================================================================
--- trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/html-seam.g
(rev 0)
+++ trunk/sandbox/ui/editor/src/main/java/org/richfaces/antlr/html-seam.g 2008-10-08
09:06:41 UTC (rev 10688)
@@ -0,0 +1,12 @@
+header
+{
+ package org.richfaces.antlr;
+}
+
+class HtmlSeamParser extends Parser;
+fooRule : "fooRule";
+
+
+class HtmlSeamLexer extends Lexer;
+HMTL : "html";
+
Show replies by date