src/Pure/General/symbol.scala
changeset 27901 28083e9f8d1d
child 27905 070b4a6a9d58
equal deleted inserted replaced
27900:fdd6e68e29d9 27901:28083e9f8d1d
       
     1 /*  Title:      Pure/General/symbol.scala
       
     2     ID:         $Id$
       
     3     Author:     Makarius
       
     4 
       
     5 Basic support for Isabelle symbols.
       
     6 */
       
     7 
       
     8 package isabelle
       
     9 
       
    10 import java.util.regex.Pattern
       
    11 
       
    12 
       
    13 object Symbol {
       
    14 
       
    15   /* Regular expressions */
       
    16 
       
    17   private def compile(s: String) =
       
    18     Pattern.compile(s, Pattern.COMMENTS | Pattern.DOTALL)
       
    19 
       
    20   private val symbol_src = """ \\ \\? < (?:
       
    21       \^? [A-Za-z][A-Za-z0-9_']* |
       
    22       \^raw: [\x20-\x7e\u0100-\uffff && [^.>]]* ) >"""
       
    23 
       
    24   private val bad_symbol_src = "(?!" + symbol_src + ")" +
       
    25     """ \\ \\? < (?: (?! \p{Space} | ["`\\] | \(\* | \*\) | \{\* | \*\} ) . )*"""
       
    26 
       
    27   val symbol_pattern = compile(symbol_src)
       
    28   val bad_symbol_pattern = compile(bad_symbol_src)
       
    29   val pattern = compile(symbol_src + "|" + bad_symbol_src + "| .")
       
    30 }