Jump to content

Compiler/lexical analyzer: Difference between revisions

Unfortunately, the <lang> tag treats the first and last newline as significant
(template "introheader" was renamed to "task heading")
(Unfortunately, the <lang> tag treats the first and last newline as significant)
Line 207:
|-
| style="vertical-align:top" |
<lang c>/*
/*
Hello world
*/
print("Hello, World!\n");</lang>
</lang>
 
| style="vertical-align:top" |
Line 226 ⟶ 224:
|-
| style="vertical-align:top" |
<lang c>/*
/*
Show Ident and Integers
*/
phoenix_number = 142857;
print(phoenix_number, "\n");</lang>
</lang>
 
| style="vertical-align:top" |
Line 252 ⟶ 248:
|-
| style="vertical-align:top" |
<lang c>/*
/*
All lexical tokens - not syntactically correct, but that will
have to wait until syntax analysis
Line 271 ⟶ 266:
/* character literal */ '\n'
/* character literal */ '\\'
/* character literal */ ' '</lang>
</lang>
 
| style="vertical-align:top" |
Line 316 ⟶ 310:
=={{header|C}}==
Tested with gcc 4.81 and later, compiles warning free with -Wall -Wextra
<lang C>#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
Line 537 ⟶ 530:
run();
return 0;
}</lang>
}
</lang>
 
Output from test case 3:
Line 577 ⟶ 569:
=={{header|Euphoria}}==
Tested with Euphoria 4.05.
<lang euphoria>include std/io.e
include std/io.e
include std/map.e
include std/types.e
Line 791 ⟶ 782:
end procedure
 
main(command_line())</lang>
</lang>
 
Output from test case 3:
Line 831 ⟶ 821:
=={{header|Flex}}==
Tested with Flex 2.5.4.
<lang C>%{
%{
#include <stdio.h>
#include <stdlib.h>
Line 994 ⟶ 983:
} while (tok != tk_EOI);
return 0;
}</lang>
}
</lang>
 
Output from test case 3:
Line 1,034 ⟶ 1,022:
=={{header|FreeBASIC}}==
Tested with FreeBASIC 1.05
<lang FreeBASIC>enum Token_type
enum Token_type
tk_EOI
tk_Mul
Line 1,301 ⟶ 1,288:
 
main()
system</lang>
</lang>
 
Output from test case 3:
Line 1,567 ⟶ 1,553:
=={{header|Python}}==
Tested with Python 2.7 and 3.x
<lang Python>from __future__ import print_function
from __future__ import print_function
import sys
 
Line 1,734 ⟶ 1,719:
 
if tok == tk_EOI:
break</lang>
</lang>
 
Output from test case 3:
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.