Permalink
Browse files

created regular expression objects which may be used later for syntax…

… highlighting in the GUI.
  • Loading branch information...
1 parent 242a654 commit a991b55753bdc485ef214163960af15ad5efe2e9 @Cazra Cazra committed May 18, 2012
@@ -0,0 +1,107 @@
+/*======================================================================
+ * _ _ _
+ * ___| (_)___(_) ___ _ __
+ * / _ \ | / __| |/ _ \| '_ \
+ * | __/ | \__ \ | (_) | | | |
+ * \___|_|_|___/_|\___/|_| |_|
+ * The Elision Term Rewriter
+ *
+ * Copyright (c) 2012 by UT-Battelle, LLC.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Collection of administrative costs for redistribution of the source code or
+ * binary form is allowed. However, collection of a royalty or other fee in excess
+ * of good faith amount for cost recovery for such redistribution is prohibited.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE DOE, OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+======================================================================*/
+package ElisionGUI
+
+import util.matching._
+
+object EliRegexes {
+ val multilineComment = Regex("""(/\*(\n|.)+?\*/)""",
+ "all")
+ val singlelineComment = Regex("""(//.*\n)""",
+ "all")
+ val verbatim = Regex("""((\"\"\"(\n|.)*?\"\"\"))""",
+ "all")
+ val stringLit = Regex("""(\"(\n|.)*?\")""",
+ "all")
+
+ val lambdaBackTick = Regex("""((\\\$\$?)(`(\n|\\`|.)*?`))""",
+ "all")
+ val lambdaNormal = Regex("""((\\\$\$?)([_a-zA-Z][_a-zA-Z0-9]*))""",
+ "all")
+
+ val varBackTick = Regex("""((\$\$?)(`(\n|\\`|.)*?`))""",
+ "all")
+ val varNormal = Regex("""((\$\$?)([_a-zA-Z][_a-zA-Z0-9]*))""",
+ "all")
+
+ val termSFBackTick = Regex("""((##?)(`(\n|\\`|.)*?`))""",
+ "all")
+ val termSFNormal = Regex("""((##?)([_a-zA-Z][_a-zA-Z0-9]*))""",
+ "all")
+
+ val typeRoot = Regex("""(ANY|BINDING|BOOLEAN|FLOAT|INTEGER|OPTYPE|STRATEGY|STRING|SYMBOL|NONE|\\^TYPE)""",
+ "all")
+
+ val boolConstants = Regex("""(true|false|Nothing)""",
+ "all")
+ val keywords = Regex("""(operator|is|case|->|@|=)""",
+ "all")
+ val algProps = Regex("""(associative|commutative|idempotent|identity|absorber|not)""",
+ "all")
+
+ val specialForm = Regex("""((\{)(:)((\n|.)*?)(:)(\}))""",
+ "all","startCurly","startColon","body","endColon","endCurly")
+ val opDefShortcut = Regex("""((\{)(!)((\n|.)*?)(\}))""",
+ "all","startCurly","startBang","body","endCurly")
+ val sequence = Regex("""((%)(([!]?[ACIBD](\[.+?\\])?)*))""",
+ "all","startMod","algProps")
+
+ val brackets = Regex("""((\{|\(|\[|\}|\)|\]))""",
+ "all")
+
+ val typeBackTick = Regex("""(: *`(\n|\\`|.)*?`)""",
+ "all")
+ val typeNormal = Regex("""(: *[_a-zA-Z][_a-zA-Z0-9]*)""",
+ "all")
+
+ val symbolBackTicks = Regex("""(`(\n|\\`|.)*?`)""",
+ "all")
+ val symbolNormal = Regex("""([_a-zA-Z][_a-zA-Z0-9]*)""",
+ "all")
+
+ val numHex = Regex("""(-?0(x|X)[0-9a-fA-F]*([0-9a-fA-F]+[.])?[0-9a-fA-F]+p?)""",
+ "all")
+ val numBin = Regex("""(-?0(b|B)[0-1]*([0-1]+[.])?[0-1]+(e|p)?)""",
+ "all")
+ val numDec = Regex("""(-?[0-9]*([0-9]+[.])?[0-9]+(e|p)?)""",
+ "all")
+}
+
+
+
+
+
@@ -1,3 +1,40 @@
+/*======================================================================
+ * _ _ _
+ * ___| (_)___(_) ___ _ __
+ * / _ \ | / __| |/ _ \| '_ \
+ * | __/ | \__ \ | (_) | | | |
+ * \___|_|_|___/_|\___/|_| |_|
+ * The Elision Term Rewriter
+ *
+ * Copyright (c) 2012 by UT-Battelle, LLC.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Collection of administrative costs for redistribution of the source code or
+ * binary form is allowed. However, collection of a royalty or other fee in excess
+ * of good faith amount for cost recovery for such redistribution is prohibited.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE DOE, OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+======================================================================*/
+
package ElisionGUI
import java.awt._
@@ -1,3 +1,40 @@
+/*======================================================================
+ * _ _ _
+ * ___| (_)___(_) ___ _ __
+ * / _ \ | / __| |/ _ \| '_ \
+ * | __/ | \__ \ | (_) | | | |
+ * \___|_|_|___/_|\___/|_| |_|
+ * The Elision Term Rewriter
+ *
+ * Copyright (c) 2012 by UT-Battelle, LLC.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Collection of administrative costs for redistribution of the source code or
+ * binary form is allowed. However, collection of a royalty or other fee in excess
+ * of good faith amount for cost recovery for such redistribution is prohibited.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE DOE, OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+======================================================================*/
+
package ElisionGUI
import swing._

0 comments on commit a991b55

Please sign in to comment.