diff options
| author | Georg Brandl <georg@python.org> | 2021-01-18 21:24:00 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2021-01-18 22:08:36 +0100 |
| commit | 2a3d3a7d5b9c60dedf6638d876161d9563faebcf (patch) | |
| tree | 809c0b4a686db98f5954afa1944404cd9652c6b2 /tests/lexers/pike | |
| parent | f0445be718da83541ea3401aad882f3937147263 (diff) | |
| download | pygments-git-examplefiles.tar.gz | |
Move test_examplefiles to new tests/lexers scheme.examplefiles
Diffstat (limited to 'tests/lexers/pike')
| -rw-r--r-- | tests/lexers/pike/example.txt | 3021 | ||||
| -rw-r--r-- | tests/lexers/pike/example2.txt | 333 |
2 files changed, 3354 insertions, 0 deletions
diff --git a/tests/lexers/pike/example.txt b/tests/lexers/pike/example.txt new file mode 100644 index 00000000..5b4defaf --- /dev/null +++ b/tests/lexers/pike/example.txt @@ -0,0 +1,3021 @@ +---input--- +#pike __REAL_VERSION__ + +//! A string wrapper that pretends to be a @[Stdio.File] object +//! in addition to some features of a @[Stdio.FILE] object. + + +//! This constant can be used to distinguish a FakeFile object +//! from a real @[Stdio.File] object. +constant is_fake_file = 1; + +protected string data; +protected int ptr; +protected int(0..1) r; +protected int(0..1) w; +protected int mtime; + +protected function read_cb; +protected function read_oob_cb; +protected function write_cb; +protected function write_oob_cb; +protected function close_cb; + +//! @seealso +//! @[Stdio.File()->close()] +int close(void|string direction) { + direction = lower_case(direction||"rw"); + int cr = has_value(direction, "r"); + int cw = has_value(direction, "w"); + + if(cr) { + r = 0; + } + + if(cw) { + w = 0; + } + + // FIXME: Close callback + return 1; +} + +//! @decl void create(string data, void|string type, void|int pointer) +//! @seealso +//! @[Stdio.File()->create()] +void create(string _data, void|string type, int|void _ptr) { + if(!_data) error("No data string given to FakeFile.\n"); + data = _data; + ptr = _ptr; + mtime = time(); + if(type) { + type = lower_case(type); + if(has_value(type, "r")) + r = 1; + if(has_value(type, "w")) + w = 1; + } + else + r = w = 1; +} + +protected string make_type_str() { + string type = ""; + if(r) type += "r"; + if(w) type += "w"; + return type; +} + +//! @seealso +//! @[Stdio.File()->dup()] +this_program dup() { + return this_program(data, make_type_str(), ptr); +} + +//! Always returns 0. +//! @seealso +//! @[Stdio.File()->errno()] +int errno() { return 0; } + +//! Returns size and the creation time of the string. +Stdio.Stat stat() { + Stdio.Stat st = Stdio.Stat(); + st->size = sizeof(data); + st->mtime=st->ctime=mtime; + st->atime=time(); + return st; +} + +//! @seealso +//! @[Stdio.File()->line_iterator()] +String.SplitIterator line_iterator(int|void trim) { + if(trim) + return String.SplitIterator( data-"\r", '\n' ); + return String.SplitIterator( data, '\n' ); +} + +protected mixed id; + +//! @seealso +//! @[Stdio.File()->query_id()] +mixed query_id() { return id; } + +//! @seealso +//! @[Stdio.File()->set_id()] +void set_id(mixed _id) { id = _id; } + +//! @seealso +//! @[Stdio.File()->read_function()] +function(:string) read_function(int nbytes) { + return lambda() { return read(nbytes); }; +} + +//! @seealso +//! @[Stdio.File()->peek()] +int(-1..1) peek(int|float|void timeout) { + if(!r) return -1; + if(ptr >= sizeof(data)) return 0; + return 1; +} + +//! Always returns 0. +//! @seealso +//! @[Stdio.File()->query_address()] +string query_address(void|int(0..1) is_local) { return 0; } + +//! @seealso +//! @[Stdio.File()->read()] +string read(void|int(0..) len, void|int(0..1) not_all) { + if(!r) return 0; + if (len < 0) error("Cannot read negative number of characters.\n"); + int start=ptr; + ptr += len; + if(zero_type(len) || ptr>sizeof(data)) + ptr = sizeof(data); + + // FIXME: read callback + return data[start..ptr-1]; +} + +//! @seealso +//! @[Stdio.FILE()->gets()] +string gets() { + if(!r) return 0; + string ret; + sscanf(data,"%*"+(string)ptr+"s%[^\n]",ret); + if(ret) + { + ptr+=sizeof(ret)+1; + if(ptr>sizeof(data)) + { + ptr=sizeof(data); + if(!sizeof(ret)) + ret = 0; + } + } + + // FIXME: read callback + return ret; +} + +//! @seealso +//! @[Stdio.FILE()->getchar()] +int getchar() { + if(!r) return 0; + int c; + if(catch(c=data[ptr])) + c=-1; + else + ptr++; + + // FIXME: read callback + return c; +} + +//! @seealso +//! @[Stdio.FILE()->unread()] +void unread(string s) { + if(!r) return; + if(data[ptr-sizeof(s)..ptr-1]==s) + ptr-=sizeof(s); + else + { + data=s+data[ptr..]; + ptr=0; + } +} + +//! @seealso +//! @[Stdio.File()->seek()] +int seek(int pos, void|int mult, void|int add) { + if(mult) + pos = pos*mult+add; + if(pos<0) + { + pos = sizeof(data)+pos; + if( pos < 0 ) + pos = 0; + } + ptr = pos; + if( ptr > strlen( data ) ) + ptr = strlen(data); + return ptr; +} + +//! Always returns 1. +//! @seealso +//! @[Stdio.File()->sync()] +int(1..1) sync() { return 1; } + +//! @seealso +//! @[Stdio.File()->tell()] +int tell() { return ptr; } + +//! @seealso +//! @[Stdio.File()->truncate()] +int(0..1) truncate(int length) { + data = data[..length-1]; + return sizeof(data)==length; +} + +//! @seealso +//! @[Stdio.File()->write()] +int(-1..) write(string|array(string) str, mixed ... extra) { + if(!w) return -1; + if(arrayp(str)) str=str*""; + if(sizeof(extra)) str=sprintf(str, @extra); + + if(ptr==sizeof(data)) { + data += str; + ptr = sizeof(data); + } + else if(sizeof(str)==1) + data[ptr++] = str[0]; + else { + data = data[..ptr-1] + str + data[ptr+sizeof(str)..]; + ptr += sizeof(str); + } + + // FIXME: write callback + return sizeof(str); +} + +//! @seealso +//! @[Stdio.File()->set_blocking] +void set_blocking() { + close_cb = 0; + read_cb = 0; + read_oob_cb = 0; + write_cb = 0; + write_oob_cb = 0; +} + +//! @seealso +//! @[Stdio.File()->set_blocking_keep_callbacks] +void set_blocking_keep_callbacks() { } + +//! @seealso +//! @[Stdio.File()->set_blocking] +void set_nonblocking(function rcb, function wcb, function ccb, + function rocb, function wocb) { + read_cb = rcb; + write_cb = wcb; + close_cb = ccb; + read_oob_cb = rocb; + write_oob_cb = wocb; +} + +//! @seealso +//! @[Stdio.File()->set_blocking_keep_callbacks] +void set_nonblocking_keep_callbacks() { } + + +//! @seealso +//! @[Stdio.File()->set_close_callback] +void set_close_callback(function cb) { close_cb = cb; } + +//! @seealso +//! @[Stdio.File()->set_read_callback] +void set_read_callback(function cb) { read_cb = cb; } + +//! @seealso +//! @[Stdio.File()->set_read_oob_callback] +void set_read_oob_callback(function cb) { read_oob_cb = cb; } + +//! @seealso +//! @[Stdio.File()->set_write_callback] +void set_write_callback(function cb) { write_cb = cb; } + +//! @seealso +//! @[Stdio.File()->set_write_oob_callback] +void set_write_oob_callback(function cb) { write_oob_cb = cb; } + + +//! @seealso +//! @[Stdio.File()->query_close_callback] +function query_close_callback() { return close_cb; } + +//! @seealso +//! @[Stdio.File()->query_read_callback] +function query_read_callback() { return read_cb; } + +//! @seealso +//! @[Stdio.File()->query_read_oob_callback] +function query_read_oob_callback() { return read_oob_cb; } + +//! @seealso +//! @[Stdio.File()->query_write_callback] +function query_write_callback() { return write_cb; } + +//! @seealso +//! @[Stdio.File()->query_write_oob_callback] +function query_write_oob_callback() { return write_oob_cb; } + +string _sprintf(int t) { + return t=='O' && sprintf("%O(%d,%O)", this_program, sizeof(data), + make_type_str()); +} + + +// FakeFile specials. + +//! A FakeFile can be casted to a string. +mixed cast(string to) { + switch(to) { + case "string": return data; + case "object": return this; + } + error("Can not cast object to %O.\n", to); +} + +//! Sizeof on a FakeFile returns the size of its contents. +int(0..) _sizeof() { + return sizeof(data); +} + +//! @ignore + +#define NOPE(X) mixed X (mixed ... args) { error("This is a FakeFile. %s is not available.\n", #X); } +NOPE(assign); +NOPE(async_connect); +NOPE(connect); +NOPE(connect_unix); +NOPE(open); +NOPE(open_socket); +NOPE(pipe); +NOPE(tcgetattr); +NOPE(tcsetattr); + +// Stdio.Fd +NOPE(dup2); +NOPE(lock); // We could implement this +NOPE(mode); // We could implement this +NOPE(proxy); // We could implement this +NOPE(query_fd); +NOPE(read_oob); +NOPE(set_close_on_exec); +NOPE(set_keepalive); +NOPE(trylock); // We could implement this +NOPE(write_oob); + +//! @endignore + +---tokens--- +'#' Comment.Preproc +'pike __REAL_VERSION__' Comment.Preproc +'\n' Comment.Preproc + +'\n' Text + +'//! A string wrapper that pretends to be a @[Stdio.File] object\n' Comment.Single + +'//! in addition to some features of a @[Stdio.FILE] object.\n' Comment.Single + +'\n' Text + +'\n' Text + +'//! This constant can be used to distinguish a FakeFile object\n' Comment.Single + +'//! from a real @[Stdio.File] object.\n' Comment.Single + +'constant' Keyword +' ' Text +'is_fake_file' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +';' Punctuation +'\n' Text + +'\n' Text + +'protected' Keyword +' ' Text +'string' Keyword.Type +' ' Text +'data' Name +';' Punctuation +'\n' Text + +'protected' Keyword +' ' Text +'int' Keyword.Type +' ' Text +'ptr' Name +';' Punctuation +'\n' Text + +'protected' Keyword +' ' Text +'int' Name.Function +'(' Punctuation +'0.' Literal.Number.Float +'.1' Literal.Number.Float +')' Punctuation +' ' Text +'r' Name +';' Punctuation +'\n' Text + +'protected' Keyword +' ' Text +'int' Name.Function +'(' Punctuation +'0.' Literal.Number.Float +'.1' Literal.Number.Float +')' Punctuation +' ' Text +'w' Name +';' Punctuation +'\n' Text + +'protected' Keyword +' ' Text +'int' Keyword.Type +' ' Text +'mtime' Name +';' Punctuation +'\n' Text + +'\n' Text + +'protected' Keyword +' ' Text +'function' Keyword.Type +' ' Text +'read_cb' Name +';' Punctuation +'\n' Text + +'protected' Keyword +' ' Text +'function' Keyword.Type +' ' Text +'read_oob_cb' Name +';' Punctuation +'\n' Text + +'protected' Keyword +' ' Text +'function' Keyword.Type +' ' Text +'write_cb' Name +';' Punctuation +'\n' Text + +'protected' Keyword +' ' Text +'function' Keyword.Type +' ' Text +'write_oob_cb' Name +';' Punctuation +'\n' Text + +'protected' Keyword +' ' Text +'function' Keyword.Type +' ' Text +'close_cb' Name +';' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->close()]\n' Comment.Single + +'int' Keyword.Type +' ' Text +'close' Name.Function +'(' Punctuation +'void' Keyword.Type +'|' Operator +'string' Keyword.Type +' ' Text +'direction' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'direction' Name +' ' Text +'=' Operator +' ' Text +'lower_case' Name +'(' Punctuation +'direction' Name +'|' Operator +'|' Operator +'"' Literal.String +'rw' Literal.String +'"' Literal.String +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'int' Keyword.Type +' ' Text +'cr' Name +' ' Text +'=' Operator +' ' Text +'has_value' Name +'(' Punctuation +'direction' Name +',' Punctuation +' ' Text +'"' Literal.String +'r' Literal.String +'"' Literal.String +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'int' Keyword.Type +' ' Text +'cw' Name +' ' Text +'=' Operator +' ' Text +'has_value' Name +'(' Punctuation +'direction' Name +',' Punctuation +' ' Text +'"' Literal.String +'w' Literal.String +'"' Literal.String +')' Punctuation +';' Punctuation +'\n' Text + +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'cr' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'r' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'cw' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'w' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +' ' Text +'// FIXME: Close callback\n' Comment.Single + +' ' Text +'return' Keyword +' ' Text +'1' Literal.Number.Integer +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @decl void create(string data, void|string type, void|int pointer)\n' Comment.Single + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->create()]\n' Comment.Single + +'void' Keyword.Type +' ' Text +'create' Name.Function +'(' Punctuation +'string' Keyword.Type +' ' Text +'_data' Name +',' Punctuation +' ' Text +'void' Keyword.Type +'|' Operator +'string' Keyword.Type +' ' Text +'type' Name +',' Punctuation +' ' Text +'int' Keyword.Type +'|' Operator +'void' Keyword.Type +' ' Text +'_ptr' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'!' Operator +'_data' Name +')' Punctuation +' ' Text +'error' Name +'(' Punctuation +'"' Literal.String +'No data string given to FakeFile.' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'data' Name +' ' Text +'=' Operator +' ' Text +'_data' Name +';' Punctuation +'\n' Text + +' ' Text +'ptr' Name +' ' Text +'=' Operator +' ' Text +'_ptr' Name +';' Punctuation +'\n' Text + +' ' Text +'mtime' Name +' ' Text +'=' Operator +' ' Text +'time' Name +'(' Punctuation +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'type' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'type' Name +' ' Text +'=' Operator +' ' Text +'lower_case' Name +'(' Punctuation +'type' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'has_value' Name +'(' Punctuation +'type' Name +',' Punctuation +' ' Text +'"' Literal.String +'r' Literal.String +'"' Literal.String +')' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'r' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'has_value' Name +'(' Punctuation +'type' Name +',' Punctuation +' ' Text +'"' Literal.String +'w' Literal.String +'"' Literal.String +')' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'w' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'else' Keyword +'\n' Text + +' ' Text +'r' Name +' ' Text +'=' Operator +' ' Text +'w' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'protected' Keyword +' ' Text +'string' Keyword.Type +' ' Text +'make_type_str' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'string' Keyword.Type +' ' Text +'type' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String +'"' Literal.String +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'r' Name +')' Punctuation +' ' Text +'type' Name +' ' Text +'+' Operator +'=' Operator +' ' Text +'"' Literal.String +'r' Literal.String +'"' Literal.String +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'w' Name +')' Punctuation +' ' Text +'type' Name +' ' Text +'+' Operator +'=' Operator +' ' Text +'"' Literal.String +'w' Literal.String +'"' Literal.String +';' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'type' Name +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->dup()]\n' Comment.Single + +'this_program' Name +' ' Text +'dup' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'this_program' Name.Function +'(' Punctuation +'data' Name +',' Punctuation +' ' Text +'make_type_str' Name +'(' Punctuation +')' Punctuation +',' Punctuation +' ' Text +'ptr' Name +')' Punctuation +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! Always returns 0.\n' Comment.Single + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->errno()]\n' Comment.Single + +'int' Keyword.Type +' ' Text +'errno' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +' ' Text +'0' Literal.Number.Integer +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'//! Returns size and the creation time of the string.\n' Comment.Single + +'Stdio' Name +'.' Punctuation +'Stat' Name +' ' Text +'stat' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'Stdio' Name +'.' Punctuation +'Stat' Name +' ' Text +'st' Name +' ' Text +'=' Operator +' ' Text +'Stdio' Name +'.' Punctuation +'Stat' Name +'(' Punctuation +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'st' Name +'-' Operator +'>' Operator +'size' Name +' ' Text +'=' Operator +' ' Text +'sizeof' Keyword +'(' Punctuation +'data' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'st' Name +'-' Operator +'>' Operator +'mtime' Name +'=' Operator +'st' Name +'-' Operator +'>' Operator +'ctime' Name +'=' Operator +'mtime' Name +';' Punctuation +'\n' Text + +' ' Text +'st' Name +'-' Operator +'>' Operator +'atime' Name +'=' Operator +'time' Name +'(' Punctuation +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'st' Name +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->line_iterator()]\n' Comment.Single + +'String' Name +'.' Punctuation +'SplitIterator' Name +' ' Text +'line_iterator' Name +'(' Punctuation +'int' Keyword.Type +'|' Operator +'void' Keyword.Type +' ' Text +'trim' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'trim' Name +')' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'String' Name +'.' Punctuation +'SplitIterator' Name +'(' Punctuation +' ' Text +'data' Name +'-' Operator +'"' Literal.String +'\\r' Literal.String.Escape +'"' Literal.String +',' Punctuation +' ' Text +"'" Literal.String.Char +'\\n' Literal.String.Char +"'" Literal.String.Char +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'String' Name +'.' Punctuation +'SplitIterator' Name +'(' Punctuation +' ' Text +'data' Name +',' Punctuation +' ' Text +"'" Literal.String.Char +'\\n' Literal.String.Char +"'" Literal.String.Char +' ' Text +')' Punctuation +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'protected' Keyword +' ' Text +'mixed' Keyword.Type +' ' Text +'id' Name +';' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->query_id()]\n' Comment.Single + +'mixed' Keyword.Type +' ' Text +'query_id' Name.Function +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +' ' Text +'id' Name +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->set_id()]\n' Comment.Single + +'void' Keyword.Type +' ' Text +'set_id' Name.Function +'(' Punctuation +'mixed' Keyword.Type +' ' Text +'_id' Name +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'id' Name +' ' Text +'=' Operator +' ' Text +'_id' Name +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->read_function()]\n' Comment.Single + +'function' Keyword.Type +'(' Punctuation +':' Operator +'string' Keyword.Type +')' Punctuation +' ' Text +'read_function' Name +'(' Punctuation +'int' Keyword.Type +' ' Text +'nbytes' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'lambda' Name.Function +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +' ' Text +'read' Name +'(' Punctuation +'nbytes' Name +')' Punctuation +';' Punctuation +' ' Text +'}' Punctuation +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->peek()]\n' Comment.Single + +'int' Keyword.Type +'(' Punctuation +'-' Operator +'1.' Literal.Number.Float +'.1' Literal.Number.Float +')' Punctuation +' ' Text +'peek' Name +'(' Punctuation +'int' Keyword.Type +'|' Operator +'float' Keyword.Type +'|' Operator +'void' Keyword.Type +' ' Text +'timeout' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'!' Operator +'r' Name +')' Punctuation +' ' Text +'return' Keyword +' ' Text +'-' Operator +'1' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'ptr' Name +' ' Text +'>' Operator +'=' Operator +' ' Text +'sizeof' Keyword +'(' Punctuation +'data' Name +')' Punctuation +')' Punctuation +' ' Text +'return' Keyword +' ' Text +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'1' Literal.Number.Integer +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! Always returns 0.\n' Comment.Single + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->query_address()]\n' Comment.Single + +'string' Keyword.Type +' ' Text +'query_address' Name +'(' Punctuation +'void' Keyword.Type +'|' Operator +'int' Keyword.Type +'(' Punctuation +'0.' Literal.Number.Float +'.1' Literal.Number.Float +')' Punctuation +' ' Text +'is_local' Name +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +' ' Text +'0' Literal.Number.Integer +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->read()]\n' Comment.Single + +'string' Keyword.Type +' ' Text +'read' Name +'(' Punctuation +'void' Keyword.Type +'|' Operator +'int' Keyword.Type +'(' Punctuation +'0.' Literal.Number.Float +'.' Punctuation +')' Punctuation +' ' Text +'len' Name +',' Punctuation +' ' Text +'void' Keyword.Type +'|' Operator +'int' Keyword.Type +'(' Punctuation +'0.' Literal.Number.Float +'.1' Literal.Number.Float +')' Punctuation +' ' Text +'not_all' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'!' Operator +'r' Name +')' Punctuation +' ' Text +'return' Keyword +' ' Text +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +' ' Text +'(' Punctuation +'len' Name +' ' Text +'<' Operator +' ' Text +'0' Literal.Number.Integer +')' Punctuation +' ' Text +'error' Name +'(' Punctuation +'"' Literal.String +'Cannot read negative number of characters.' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'int' Keyword.Type +' ' Text +'start' Name +'=' Operator +'ptr' Name +';' Punctuation +'\n' Text + +' ' Text +'ptr' Name +' ' Text +'+' Operator +'=' Operator +' ' Text +'len' Name +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'zero_type' Name +'(' Punctuation +'len' Name +')' Punctuation +' ' Text +'|' Operator +'|' Operator +' ' Text +'ptr' Name +'>' Operator +'sizeof' Keyword +'(' Punctuation +'data' Name +')' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'ptr' Name +' ' Text +'=' Operator +' ' Text +'sizeof' Keyword +'(' Punctuation +'data' Name +')' Punctuation +';' Punctuation +'\n' Text + +'\n' Text + +' ' Text +'// FIXME: read callback\n' Comment.Single + +' ' Text +'return' Keyword +' ' Text +'data' Name +'[' Punctuation +'start' Name +'.' Punctuation +'.' Punctuation +'ptr' Name +'-' Operator +'1' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.FILE()->gets()]\n' Comment.Single + +'string' Keyword.Type +' ' Text +'gets' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'!' Operator +'r' Name +')' Punctuation +' ' Text +'return' Keyword +' ' Text +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'string' Keyword.Type +' ' Text +'ret' Name +';' Punctuation +'\n' Text + +' ' Text +'sscanf' Keyword +'(' Punctuation +'data' Name +',' Punctuation +'"' Literal.String +'%*' Literal.String +'"' Literal.String +'+' Operator +'(' Punctuation +'string' Keyword.Type +')' Punctuation +'ptr' Name +'+' Operator +'"' Literal.String +'s%[^' Literal.String +'\\n' Literal.String.Escape +']' Literal.String +'"' Literal.String +',' Punctuation +'ret' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'ret' Name +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'ptr' Name +'+' Operator +'=' Operator +'sizeof' Keyword +'(' Punctuation +'ret' Name +')' Punctuation +'+' Operator +'1' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'ptr' Name +'>' Operator +'sizeof' Keyword +'(' Punctuation +'data' Name +')' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'ptr' Name +'=' Operator +'sizeof' Keyword +'(' Punctuation +'data' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'!' Operator +'sizeof' Keyword +'(' Punctuation +'ret' Name +')' Punctuation +')' Punctuation +'\n' Text + +'\t' Text +'ret' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +' ' Text +'// FIXME: read callback\n' Comment.Single + +' ' Text +'return' Keyword +' ' Text +'ret' Name +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.FILE()->getchar()]\n' Comment.Single + +'int' Keyword.Type +' ' Text +'getchar' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'!' Operator +'r' Name +')' Punctuation +' ' Text +'return' Keyword +' ' Text +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'int' Keyword.Type +' ' Text +'c' Name +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'catch' Keyword +'(' Punctuation +'c' Name +'=' Operator +'data' Name +'[' Punctuation +'ptr' Name +']' Punctuation +')' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'c' Name +'=' Operator +'-' Operator +'1' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'else' Keyword +'\n' Text + +' ' Text +'ptr' Name +'+' Operator +'+' Operator +';' Punctuation +'\n' Text + +'\n' Text + +' ' Text +'// FIXME: read callback\n' Comment.Single + +' ' Text +'return' Keyword +' ' Text +'c' Name +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.FILE()->unread()]\n' Comment.Single + +'void' Keyword.Type +' ' Text +'unread' Name +'(' Punctuation +'string' Keyword.Type +' ' Text +'s' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'!' Operator +'r' Name +')' Punctuation +' ' Text +'return' Keyword +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'data' Name +'[' Punctuation +'ptr' Name +'-' Operator +'sizeof' Keyword +'(' Punctuation +'s' Name +')' Punctuation +'.' Punctuation +'.' Punctuation +'ptr' Name +'-' Operator +'1' Literal.Number.Integer +']' Punctuation +'=' Operator +'=' Operator +'s' Name +')' Punctuation +'\n' Text + +' ' Text +'ptr' Name +'-' Operator +'=' Operator +'sizeof' Keyword +'(' Punctuation +'s' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'else' Keyword +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'data' Name +'=' Operator +'s' Name +'+' Operator +'data' Name +'[' Punctuation +'ptr' Name +'.' Punctuation +'.' Punctuation +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'ptr' Name +'=' Operator +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->seek()]\n' Comment.Single + +'int' Keyword.Type +' ' Text +'seek' Name +'(' Punctuation +'int' Keyword.Type +' ' Text +'pos' Name +',' Punctuation +' ' Text +'void' Keyword.Type +'|' Operator +'int' Keyword.Type +' ' Text +'mult' Name +',' Punctuation +' ' Text +'void' Keyword.Type +'|' Operator +'int' Keyword.Type +' ' Text +'add' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'mult' Name +')' Punctuation +'\n' Text + +' ' Text +'pos' Name +' ' Text +'=' Operator +' ' Text +'pos' Name +'*' Operator +'mult' Name +'+' Operator +'add' Name +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'pos' Name +'<' Operator +'0' Literal.Number.Integer +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'pos' Name +' ' Text +'=' Operator +' ' Text +'sizeof' Keyword +'(' Punctuation +'data' Name +')' Punctuation +'+' Operator +'pos' Name +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +' ' Text +'pos' Name +' ' Text +'<' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +')' Punctuation +'\n' Text + +'\t' Text +'pos' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'ptr' Name +' ' Text +'=' Operator +' ' Text +'pos' Name +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +' ' Text +'ptr' Name +' ' Text +'>' Operator +' ' Text +'strlen' Name +'(' Punctuation +' ' Text +'data' Name +' ' Text +')' Punctuation +' ' Text +')' Punctuation +'\n' Text + +' ' Text +'ptr' Name +' ' Text +'=' Operator +' ' Text +'strlen' Name +'(' Punctuation +'data' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'ptr' Name +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! Always returns 1.\n' Comment.Single + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->sync()]\n' Comment.Single + +'int' Keyword.Type +'(' Punctuation +'1.' Literal.Number.Float +'.1' Literal.Number.Float +')' Punctuation +' ' Text +'sync' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +' ' Text +'1' Literal.Number.Integer +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->tell()]\n' Comment.Single + +'int' Keyword.Type +' ' Text +'tell' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +' ' Text +'ptr' Name +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->truncate()]\n' Comment.Single + +'int' Keyword.Type +'(' Punctuation +'0.' Literal.Number.Float +'.1' Literal.Number.Float +')' Punctuation +' ' Text +'truncate' Name +'(' Punctuation +'int' Keyword.Type +' ' Text +'length' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'data' Name +' ' Text +'=' Operator +' ' Text +'data' Name +'[' Punctuation +'.' Punctuation +'.' Punctuation +'length' Name +'-' Operator +'1' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'sizeof' Name.Function +'(' Punctuation +'data' Name +')' Punctuation +'=' Operator +'=' Operator +'length' Name +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->write()]\n' Comment.Single + +'int' Keyword.Type +'(' Punctuation +'-' Operator +'1.' Literal.Number.Float +'.' Punctuation +')' Punctuation +' ' Text +'write' Name +'(' Punctuation +'string' Keyword.Type +'|' Operator +'array' Keyword.Type +'(' Punctuation +'string' Keyword.Type +')' Punctuation +' ' Text +'str' Name +',' Punctuation +' ' Text +'mixed' Keyword.Type +' ' Text +'.' Punctuation +'.' Punctuation +'.' Punctuation +' ' Text +'extra' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'!' Operator +'w' Name +')' Punctuation +' ' Text +'return' Keyword +' ' Text +'-' Operator +'1' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'arrayp' Name +'(' Punctuation +'str' Name +')' Punctuation +')' Punctuation +' ' Text +'str' Name +'=' Operator +'str' Name +'*' Operator +'"' Literal.String +'"' Literal.String +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'sizeof' Keyword +'(' Punctuation +'extra' Name +')' Punctuation +')' Punctuation +' ' Text +'str' Name +'=' Operator +'sprintf' Name +'(' Punctuation +'str' Name +',' Punctuation +' ' Text +'@' Operator +'extra' Name +')' Punctuation +';' Punctuation +'\n' Text + +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'ptr' Name +'=' Operator +'=' Operator +'sizeof' Keyword +'(' Punctuation +'data' Name +')' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'data' Name +' ' Text +'+' Operator +'=' Operator +' ' Text +'str' Name +';' Punctuation +'\n' Text + +' ' Text +'ptr' Name +' ' Text +'=' Operator +' ' Text +'sizeof' Keyword +'(' Punctuation +'data' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'else' Keyword +' ' Text +'if' Keyword +'(' Punctuation +'sizeof' Keyword +'(' Punctuation +'str' Name +')' Punctuation +'=' Operator +'=' Operator +'1' Literal.Number.Integer +')' Punctuation +'\n' Text + +' ' Text +'data' Name +'[' Punctuation +'ptr' Name +'+' Operator +'+' Operator +']' Punctuation +' ' Text +'=' Operator +' ' Text +'str' Name +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'else' Keyword +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'data' Name +' ' Text +'=' Operator +' ' Text +'data' Name +'[' Punctuation +'.' Punctuation +'.' Punctuation +'ptr' Name +'-' Operator +'1' Literal.Number.Integer +']' Punctuation +' ' Text +'+' Operator +' ' Text +'str' Name +' ' Text +'+' Operator +' ' Text +'data' Name +'[' Punctuation +'ptr' Name +'+' Operator +'sizeof' Keyword +'(' Punctuation +'str' Name +')' Punctuation +'.' Punctuation +'.' Punctuation +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'ptr' Name +' ' Text +'+' Operator +'=' Operator +' ' Text +'sizeof' Keyword +'(' Punctuation +'str' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +' ' Text +'// FIXME: write callback\n' Comment.Single + +' ' Text +'return' Keyword +' ' Text +'sizeof' Keyword +'(' Punctuation +'str' Name +')' Punctuation +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->set_blocking]\n' Comment.Single + +'void' Keyword.Type +' ' Text +'set_blocking' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'close_cb' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'read_cb' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'read_oob_cb' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'write_cb' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'write_oob_cb' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->set_blocking_keep_callbacks]\n' Comment.Single + +'void' Keyword.Type +' ' Text +'set_blocking_keep_callbacks' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->set_blocking]\n' Comment.Single + +'void' Keyword.Type +' ' Text +'set_nonblocking' Name +'(' Punctuation +'function' Keyword.Type +' ' Text +'rcb' Name +',' Punctuation +' ' Text +'function' Keyword.Type +' ' Text +'wcb' Name +',' Punctuation +' ' Text +'function' Keyword.Type +' ' Text +'ccb' Name +',' Punctuation +'\n' Text + +'\t\t ' Text +'function' Keyword.Type +' ' Text +'rocb' Name +',' Punctuation +' ' Text +'function' Keyword.Type +' ' Text +'wocb' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'read_cb' Name +' ' Text +'=' Operator +' ' Text +'rcb' Name +';' Punctuation +'\n' Text + +' ' Text +'write_cb' Name +' ' Text +'=' Operator +' ' Text +'wcb' Name +';' Punctuation +'\n' Text + +' ' Text +'close_cb' Name +' ' Text +'=' Operator +' ' Text +'ccb' Name +';' Punctuation +'\n' Text + +' ' Text +'read_oob_cb' Name +' ' Text +'=' Operator +' ' Text +'rocb' Name +';' Punctuation +'\n' Text + +' ' Text +'write_oob_cb' Name +' ' Text +'=' Operator +' ' Text +'wocb' Name +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->set_blocking_keep_callbacks]\n' Comment.Single + +'void' Keyword.Type +' ' Text +'set_nonblocking_keep_callbacks' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->set_close_callback]\n' Comment.Single + +'void' Keyword.Type +' ' Text +'set_close_callback' Name +'(' Punctuation +'function' Keyword.Type +' ' Text +'cb' Name +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'close_cb' Name +' ' Text +'=' Operator +' ' Text +'cb' Name +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->set_read_callback]\n' Comment.Single + +'void' Keyword.Type +' ' Text +'set_read_callback' Name +'(' Punctuation +'function' Keyword.Type +' ' Text +'cb' Name +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'read_cb' Name +' ' Text +'=' Operator +' ' Text +'cb' Name +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->set_read_oob_callback]\n' Comment.Single + +'void' Keyword.Type +' ' Text +'set_read_oob_callback' Name +'(' Punctuation +'function' Keyword.Type +' ' Text +'cb' Name +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'read_oob_cb' Name +' ' Text +'=' Operator +' ' Text +'cb' Name +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->set_write_callback]\n' Comment.Single + +'void' Keyword.Type +' ' Text +'set_write_callback' Name +'(' Punctuation +'function' Keyword.Type +' ' Text +'cb' Name +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'write_cb' Name +' ' Text +'=' Operator +' ' Text +'cb' Name +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->set_write_oob_callback]\n' Comment.Single + +'void' Keyword.Type +' ' Text +'set_write_oob_callback' Name +'(' Punctuation +'function' Keyword.Type +' ' Text +'cb' Name +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'write_oob_cb' Name +' ' Text +'=' Operator +' ' Text +'cb' Name +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->query_close_callback]\n' Comment.Single + +'function' Keyword.Type +' ' Text +'query_close_callback' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +' ' Text +'close_cb' Name +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->query_read_callback]\n' Comment.Single + +'function' Keyword.Type +' ' Text +'query_read_callback' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +' ' Text +'read_cb' Name +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->query_read_oob_callback]\n' Comment.Single + +'function' Keyword.Type +' ' Text +'query_read_oob_callback' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +' ' Text +'read_oob_cb' Name +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->query_write_callback]\n' Comment.Single + +'function' Keyword.Type +' ' Text +'query_write_callback' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +' ' Text +'write_cb' Name +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @seealso\n' Comment.Single + +'//! @[Stdio.File()->query_write_oob_callback]\n' Comment.Single + +'function' Keyword.Type +' ' Text +'query_write_oob_callback' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +' ' Text +'write_oob_cb' Name +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'\n' Text + +'string' Keyword.Type +' ' Text +'_sprintf' Name +'(' Punctuation +'int' Keyword.Type +' ' Text +'t' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'t' Name +'=' Operator +'=' Operator +"'" Literal.String.Char +'O' Literal.String.Char +"'" Literal.String.Char +' ' Text +'&' Operator +'&' Operator +' ' Text +'sprintf' Name +'(' Punctuation +'"' Literal.String +'%O(%d,%O)' Literal.String +'"' Literal.String +',' Punctuation +' ' Text +'this_program' Name +',' Punctuation +' ' Text +'sizeof' Keyword +'(' Punctuation +'data' Name +')' Punctuation +',' Punctuation +'\n' Text + +'\t\t\t ' Text +'make_type_str' Name +'(' Punctuation +')' Punctuation +')' Punctuation +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'\n' Text + +'// FakeFile specials.\n' Comment.Single + +'\n' Text + +'//! A FakeFile can be casted to a string.\n' Comment.Single + +'mixed' Keyword.Type +' ' Text +'cast' Name +'(' Punctuation +'string' Keyword.Type +' ' Text +'to' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'switch' Keyword +'(' Punctuation +'to' Name +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'case' Keyword +' ' Text +'"' Literal.String +'string' Literal.String +'"' Literal.String +':' Operator +' ' Text +'return' Keyword +' ' Text +'data' Name +';' Punctuation +'\n' Text + +' ' Text +'case' Keyword +' ' Text +'"' Literal.String +'object' Literal.String +'"' Literal.String +':' Operator +' ' Text +'return' Keyword +' ' Text +'this' Keyword +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'error' Name +'(' Punctuation +'"' Literal.String +'Can not cast object to %O.' Literal.String +'\\n' Literal.String.Escape +'"' Literal.String +',' Punctuation +' ' Text +'to' Name +')' Punctuation +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! Sizeof on a FakeFile returns the size of its contents.\n' Comment.Single + +'int' Keyword.Type +'(' Punctuation +'0.' Literal.Number.Float +'.' Punctuation +')' Punctuation +' ' Text +'_sizeof' Name +'(' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'sizeof' Name.Function +'(' Punctuation +'data' Name +')' Punctuation +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'\n' Text + +'//! @ignore\n' Comment.Single + +'\n' Text + +'#' Comment.Preproc +'define NOPE(X) mixed X (mixed ... args) { error("This is a FakeFile. %s is not available.\\n", #X); }' Comment.Preproc +'\n' Comment.Preproc + +'NOPE' Name +'(' Punctuation +'assign' Name +')' Punctuation +';' Punctuation +'\n' Text + +'NOPE' Name +'(' Punctuation +'async_connect' Name +')' Punctuation +';' Punctuation +'\n' Text + +'NOPE' Name +'(' Punctuation +'connect' Name +')' Punctuation +';' Punctuation +'\n' Text + +'NOPE' Name +'(' Punctuation +'connect_unix' Name +')' Punctuation +';' Punctuation +'\n' Text + +'NOPE' Name +'(' Punctuation +'open' Name +')' Punctuation +';' Punctuation +'\n' Text + +'NOPE' Name +'(' Punctuation +'open_socket' Name +')' Punctuation +';' Punctuation +'\n' Text + +'NOPE' Name +'(' Punctuation +'pipe' Name +')' Punctuation +';' Punctuation +'\n' Text + +'NOPE' Name +'(' Punctuation +'tcgetattr' Name +')' Punctuation +';' Punctuation +'\n' Text + +'NOPE' Name +'(' Punctuation +'tcsetattr' Name +')' Punctuation +';' Punctuation +'\n' Text + +'\n' Text + +'// Stdio.Fd\n' Comment.Single + +'NOPE' Name +'(' Punctuation +'dup2' Name +')' Punctuation +';' Punctuation +'\n' Text + +'NOPE' Name +'(' Punctuation +'lock' Name +')' Punctuation +';' Punctuation +' ' Text +'// We could implement this\n' Comment.Single + +'NOPE' Name +'(' Punctuation +'mode' Name +')' Punctuation +';' Punctuation +' ' Text +'// We could implement this\n' Comment.Single + +'NOPE' Name +'(' Punctuation +'proxy' Name +')' Punctuation +';' Punctuation +' ' Text +'// We could implement this\n' Comment.Single + +'NOPE' Name +'(' Punctuation +'query_fd' Name +')' Punctuation +';' Punctuation +'\n' Text + +'NOPE' Name +'(' Punctuation +'read_oob' Name +')' Punctuation +';' Punctuation +'\n' Text + +'NOPE' Name +'(' Punctuation +'set_close_on_exec' Name +')' Punctuation +';' Punctuation +'\n' Text + +'NOPE' Name +'(' Punctuation +'set_keepalive' Name +')' Punctuation +';' Punctuation +'\n' Text + +'NOPE' Name +'(' Punctuation +'trylock' Name +')' Punctuation +';' Punctuation +' ' Text +'// We could implement this\n' Comment.Single + +'NOPE' Name +'(' Punctuation +'write_oob' Name +')' Punctuation +';' Punctuation +'\n' Text + +'\n' Text + +'//! @endignore\n' Comment.Single diff --git a/tests/lexers/pike/example2.txt b/tests/lexers/pike/example2.txt new file mode 100644 index 00000000..42bbfe37 --- /dev/null +++ b/tests/lexers/pike/example2.txt @@ -0,0 +1,333 @@ +---input--- +#pike __REAL_VERSION__ + +constant Generic = __builtin.GenericError; + +constant Index = __builtin.IndexError; + +constant BadArgument = __builtin.BadArgumentError; + +constant Math = __builtin.MathError; + +constant Resource = __builtin.ResourceError; + +constant Permission = __builtin.PermissionError; + +constant Decode = __builtin.DecodeError; + +constant Cpp = __builtin.CppError; + +constant Compilation = __builtin.CompilationError; + +constant MasterLoad = __builtin.MasterLoadError; + +constant ModuleLoad = __builtin.ModuleLoadError; + +//! Returns an Error object for any argument it receives. If the +//! argument already is an Error object or is empty, it does nothing. +object mkerror(mixed error) +{ + if (error == UNDEFINED) + return error; + if (objectp(error) && error->is_generic_error) + return error; + if (arrayp(error)) + return Error.Generic(@error); + if (stringp(error)) + return Error.Generic(error); + return Error.Generic(sprintf("%O", error)); +} + +---tokens--- +'#' Comment.Preproc +'pike __REAL_VERSION__' Comment.Preproc +'\n' Comment.Preproc + +'\n' Text + +'constant' Keyword +' ' Text +'Generic' Name +' ' Text +'=' Operator +' ' Text +'__builtin' Name +'.' Punctuation +'GenericError' Name +';' Punctuation +'\n' Text + +'\n' Text + +'constant' Keyword +' ' Text +'Index' Name +' ' Text +'=' Operator +' ' Text +'__builtin' Name +'.' Punctuation +'IndexError' Name +';' Punctuation +'\n' Text + +'\n' Text + +'constant' Keyword +' ' Text +'BadArgument' Name +' ' Text +'=' Operator +' ' Text +'__builtin' Name +'.' Punctuation +'BadArgumentError' Name +';' Punctuation +'\n' Text + +'\n' Text + +'constant' Keyword +' ' Text +'Math' Name +' ' Text +'=' Operator +' ' Text +'__builtin' Name +'.' Punctuation +'MathError' Name +';' Punctuation +'\n' Text + +'\n' Text + +'constant' Keyword +' ' Text +'Resource' Name +' ' Text +'=' Operator +' ' Text +'__builtin' Name +'.' Punctuation +'ResourceError' Name +';' Punctuation +'\n' Text + +'\n' Text + +'constant' Keyword +' ' Text +'Permission' Name +' ' Text +'=' Operator +' ' Text +'__builtin' Name +'.' Punctuation +'PermissionError' Name +';' Punctuation +'\n' Text + +'\n' Text + +'constant' Keyword +' ' Text +'Decode' Name +' ' Text +'=' Operator +' ' Text +'__builtin' Name +'.' Punctuation +'DecodeError' Name +';' Punctuation +'\n' Text + +'\n' Text + +'constant' Keyword +' ' Text +'Cpp' Name +' ' Text +'=' Operator +' ' Text +'__builtin' Name +'.' Punctuation +'CppError' Name +';' Punctuation +'\n' Text + +'\n' Text + +'constant' Keyword +' ' Text +'Compilation' Name +' ' Text +'=' Operator +' ' Text +'__builtin' Name +'.' Punctuation +'CompilationError' Name +';' Punctuation +'\n' Text + +'\n' Text + +'constant' Keyword +' ' Text +'MasterLoad' Name +' ' Text +'=' Operator +' ' Text +'__builtin' Name +'.' Punctuation +'MasterLoadError' Name +';' Punctuation +'\n' Text + +'\n' Text + +'constant' Keyword +' ' Text +'ModuleLoad' Name +' ' Text +'=' Operator +' ' Text +'__builtin' Name +'.' Punctuation +'ModuleLoadError' Name +';' Punctuation +'\n' Text + +'\n' Text + +'//! Returns an Error object for any argument it receives. If the\n' Comment.Single + +'//! argument already is an Error object or is empty, it does nothing.\n' Comment.Single + +'object' Keyword.Type +' ' Text +'mkerror' Name.Function +'(' Punctuation +'mixed' Keyword.Type +' ' Text +'error' Name +')' Punctuation +'\n' Text + +'{' Punctuation +'\n' Text + +' ' Text +'if' Keyword +' ' Text +'(' Punctuation +'error' Name +' ' Text +'=' Operator +'=' Operator +' ' Text +'UNDEFINED' Name +')' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'error' Name +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +' ' Text +'(' Punctuation +'objectp' Name +'(' Punctuation +'error' Name +')' Punctuation +' ' Text +'&' Operator +'&' Operator +' ' Text +'error' Name +'-' Operator +'>' Operator +'is_generic_error' Name +')' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'error' Name +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +' ' Text +'(' Punctuation +'arrayp' Name +'(' Punctuation +'error' Name +')' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'Error' Name +'.' Punctuation +'Generic' Name +'(' Punctuation +'@' Operator +'error' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +' ' Text +'(' Punctuation +'stringp' Name +'(' Punctuation +'error' Name +')' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'Error' Name +'.' Punctuation +'Generic' Name +'(' Punctuation +'error' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'return' Keyword +' ' Text +'Error' Name +'.' Punctuation +'Generic' Name +'(' Punctuation +'sprintf' Name +'(' Punctuation +'"' Literal.String +'%O' Literal.String +'"' Literal.String +',' Punctuation +' ' Text +'error' Name +')' Punctuation +')' Punctuation +';' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text |
