diff options
| author | Ken <kenny2minecraft@gmail.com> | 2020-06-21 15:09:36 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-21 09:09:36 +0200 |
| commit | 18d1f8f3afd60df65da736a1393b534d245cb58a (patch) | |
| tree | 9bfe3a75ce2fc4f55dde204a2282459f74683af0 /tests | |
| parent | f7513588738f027521e6e66964a50cb93a2791b1 (diff) | |
| download | pygments-git-18d1f8f3afd60df65da736a1393b534d245cb58a.tar.gz | |
Add Arrow lexer (#1481)
* Add Arrow lexer
* Pass tests: raw string for regex
* Make requested changes
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/examplefiles/primesieve.arw | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/examplefiles/primesieve.arw b/tests/examplefiles/primesieve.arw new file mode 100644 index 00000000..74ecce9b --- /dev/null +++ b/tests/examplefiles/primesieve.arw @@ -0,0 +1,60 @@ +function +/--> bool[] primeSieve(int max) +| bool[] primes[max] +| primes[0] = false +| primes[1] = false +| +| int i +| i = 2 +| /--> +| | primes[i] = true +| | i = i + 1 +| \--< i < max +| +| int firstPrime +| firstPrime = 1 +| /--> +| | bool firstIsComposite +| | /--> +| | | firstPrime = firstPrime + 1 +| | | firstIsComposite = false +| | | /--< firstPrime > max or firstPrime == max +| | | | firstIsComposite = not primes[firstPrime] +| | | \--> +| | \--< firstIsComposite +| | /--< firstPrime > max or firstPrime == max +| | | primes[firstPrime] = true +| | | int composite +| | | composite = firstPrime * 2 +| | | /--< composite > max +| | | | /--> +| | | | | primes[composite] = false +| | | | | composite = composite + firstPrime +| | | | \--< composite < max +| | | \--> +| | \--> +| \--< firstPrime < max - 1 +^ primes + +main +int max +max = 1000 +bool[] primes +primes = primeSieve(max) + +print "Enter a number and I'll tell you whether or not it's prime!" +int testNum +testNum = input int + +/--< testNum < 0 or testNum > max - 1 +| /--< not primes[testNum] +| | print "Prime" +| \--> +| /--< primes[testNum] +| | print "Not prime" +| \--> +\--> + +/--< not (testNum < 0 or testNum > max - 1) +| print "Out of bounds" +\--> |
