1 rizwank 1.1 /**
2 * Name: python
3 * Description: Python programming language.
4 * Author: Andy Eskilsson <Andy.Eskilsson@telelogic.se>
5 */
6
7 state python_string extends Highlight
8 {
9 /\\\\./ {
10 language_print ($0);
11 }
12 python_string_end {
13 language_print ($0);
14 return;
15 }
16 }
17
18 state python extends HighlightEntry
19 {
20 /* Comments. */
21 /#/ {
22 rizwank 1.1 comment_face (true);
23 language_print ($0);
24 call (eat_one_line);
25 comment_face (false);
26 }
27 /* Python strings */
28 /(\"\"\"|[\'][\'][\'])/ {
29 python_string_end = regexp($0);
30 string_face (true);
31 language_print ($0);
32 call (python_string);
33 string_face (false);
34 }
35
36 /(\"|[\'])/ {
37 python_string_end = regexp( $0 );
38 string_face (true);
39 language_print ($0);
40 call (python_string);
41 string_face (false);
42 }
43 rizwank 1.1
44 /* Function */
45 /([ \t]*)(def)([ \t]+)([^(]*)/ {
46 /* indentation */
47 language_print ($1);
48
49 /* def */
50 keyword_face (true);
51 language_print ($2);
52 keyword_face (false);
53
54 /* middle */
55 language_print ($3);
56
57 /* Function name. */
58 function_name_face (true);
59 language_print ($4);
60 function_name_face (false);
61 }
62
63 /* Keywords */
64 rizwank 1.1 /\\b(a(nd|ssert)|break|c(lass|ontinue)|de(f|l)\\
65 |e(l(if|se(|:))|x(cept(|:)|ec))|f(inally:|or|rom)|global\\
66 |i(f|mport|n|s)|lambda|not|or|p(ass|rint)|r(aise|eturn)|try:|while)\\b/ {
67 keyword_face (true);
68 language_print ($0);
69 keyword_face (false);
70 }
71 }
72
73
74 /*
75 Local variables:
76 mode: c
77 End:
78 */
|