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