1 package org.simantics.scl.compiler.markdown.internal;
\r
3 public class CharacterSet {
\r
8 public CharacterSet(String chars) {
\r
10 throw new IllegalArgumentException();
\r
11 minChar = Integer.MAX_VALUE;
\r
12 maxChar = Integer.MIN_VALUE;
\r
13 for(int i=0;i<chars.length();++i) {
\r
14 int c = (int)chars.charAt(i);
\r
15 if(c == '-' && i > 0 && i < chars.length()-1)
\r
17 minChar = Math.min(minChar, c);
\r
18 maxChar = Math.max(maxChar, c);
\r
21 table = new boolean[maxChar-minChar+1];
\r
22 for(int i=0;i<chars.length();++i) {
\r
23 int c = (int)chars.charAt(i);
\r
24 if(i < chars.length()-2 && chars.charAt(i+1)=='-') {
\r
25 int c2 = (int)chars.charAt(i+2);
\r
31 for(int j=c;j<=c2;++j)
\r
32 table[j - minChar] = true;
\r
36 table[c - minChar] = true;
\r
40 public boolean contains(char c_) {
\r
42 return c >= minChar && c <= maxChar && table[c - minChar];
\r