Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(309)

Delta Between Two Patch Sets: Parser/listnode.c

Issue 3353: make built-in tokenizer available via Python C API
Left Patch Set: Created 5 years, 8 months ago
Right Patch Set: Created 4 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « Parser/grammar.c ('k') | Parser/parser.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 1
2 /* List a node on a file */ 2 /* List a node on a file */
3 3
4 #include "pgenheaders.h" 4 #include "pgenheaders.h"
5 #include "token.h" 5 #include "token.h"
6 #include "node.h" 6 #include "node.h"
7 7
8 /* Forward */ 8 /* Forward */
9 static void list1node(FILE *, node *); 9 static void list1node(FILE *, node *);
10 static void listnode(FILE *, node *); 10 static void listnode(FILE *, node *);
(...skipping 12 matching lines...) Expand all
23 level = 0; 23 level = 0;
24 atbol = 1; 24 atbol = 1;
25 list1node(fp, n); 25 list1node(fp, n);
26 } 26 }
27 27
28 static void 28 static void
29 list1node(FILE *fp, node *n) 29 list1node(FILE *fp, node *n)
30 { 30 {
31 if (n == 0) 31 if (n == 0)
32 return; 32 return;
33 if (ISNONTERMINAL(TYPE(n))) { 33 if (PYTOK_ISNONTERMINAL(TYPE(n))) {
34 int i; 34 int i;
35 for (i = 0; i < NCH(n); i++) 35 for (i = 0; i < NCH(n); i++)
36 list1node(fp, CHILD(n, i)); 36 list1node(fp, CHILD(n, i));
37 } 37 }
38 else if (ISTERMINAL(TYPE(n))) { 38 else if (PYTOK_ISTERMINAL(TYPE(n))) {
39 switch (TYPE(n)) { 39 switch (TYPE(n)) {
40 case INDENT: 40 case PYTOK_INDENT:
41 ++level; 41 ++level;
42 break; 42 break;
43 case DEDENT: 43 case PYTOK_DEDENT:
44 --level; 44 --level;
45 break; 45 break;
46 default: 46 default:
47 if (atbol) { 47 if (atbol) {
48 int i; 48 int i;
49 for (i = 0; i < level; ++i) 49 for (i = 0; i < level; ++i)
50 fprintf(fp, "\t"); 50 fprintf(fp, "\t");
51 atbol = 0; 51 atbol = 0;
52 } 52 }
53 if (TYPE(n) == NEWLINE) { 53 if (TYPE(n) == PYTOK_NEWLINE) {
54 if (STR(n) != NULL) 54 if (STR(n) != NULL)
55 fprintf(fp, "%s", STR(n)); 55 fprintf(fp, "%s", STR(n));
56 fprintf(fp, "\n"); 56 fprintf(fp, "\n");
57 atbol = 1; 57 atbol = 1;
58 } 58 }
59 else 59 else
60 fprintf(fp, "%s ", STR(n)); 60 fprintf(fp, "%s ", STR(n));
61 break; 61 break;
62 } 62 }
63 } 63 }
64 else 64 else
65 fprintf(fp, "? "); 65 fprintf(fp, "? ");
66 } 66 }
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+