source: libcfa/src/algorithms/range_iterator.cfa @ 8157bde

ADTast-experimentalenumforall-pointer-decaypthread-emulationqualifiedEnum
Last change on this file since 8157bde was 8157bde, checked in by Thierry Delisle <tdelisle@…>, 2 years ago

Pushing to get off jax

  • Property mode set to 100644
File size: 1.3 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// range_iterator.cfa --
8//
9// Author           : Thierry Delisle
10// Created On       : Tue Nov 30 13:06:22 2021
11// Last Modified By :
12// Last Modified On :
13// Update Count     :
14//
15
16
17
18void main(RangeParser & this) {
19        for() {
20                this._start = -1;
21                this._stop = -1;
22                int start_len = -1, stop_len = -1;
23                int ret = sscanf(this.text, "%u%n-%u%n", &this._start, &start_len, &stop, &stop_len);
24                switch(ret) {
25                case 0:
26                        // Not a range, maybe a comma?
27                        if(this.text[0] == ',') {
28                                this.text ++;
29                                continue;
30                        }
31
32                        serr | "Error: unexpected character in next range: '" | this.text |"'";
33                        exit(2);
34                case 1:
35                        this.text += start_len;
36                        // Only one value, push it!
37                        this.com = this._start;
38                        suspend;
39                        break;
40                case 2:
41                        if(this._start > this._stop) {
42                                serr | "Error: next range out of order '" | this.text |"'";
43                                exit(2);
44                        }
45                        this.text += stop_len;
46                        for(this.com i = this._start; this.com <= this._stop; this.com++) {
47                                suspend;
48                        }
49                        break;
50                default:
51                        serr | "Error reading next block: '" | this.text |"', returned" | ret;
52                        exit(2);
53                }
54
55                if(this.text[0] == '\0') break;
56        }
57}
Note: See TracBrowser for help on using the repository browser.