Tokens
Snippet 1
init;
if (failure) {
has error;
break;
}
submit;
↓↓↓
Token { type: 'node', value: 'init' },
Token { type: 'punctuation', value: ';' },
Token { type: 'keyword', value: 'if' },
Token { type: 'punctuation', value: '(' },
Token { type: 'node', value: 'failure' },
Token { type: 'punctuation', value: ')' },
Token { type: 'punctuation', value: '{' },
Token { type: 'node', value: 'has error' },
Token { type: 'punctuation', value: ';' },
Token { type: 'keyword', value: 'break' },
Token { type: 'punctuation', value: ';' },
Token { type: 'punctuation', value: '}' },
Token { type: 'node', value: 'submit' },
Token { type: 'punctuation', value: ';' }
Snippet 2
switch (num) {
case 1:
something for 1;
break;
case 2:
something for 2;
default:
something default;
}
something last;
↓↓↓
Token { type: 'keyword', value: 'switch' },
Token { type: 'punctuation', value: '(' },
Token { type: 'node', value: 'num' },
Token { type: 'punctuation', value: ')' },
Token { type: 'punctuation', value: '{' },
Token { type: 'keyword', value: 'case' },
Token { type: 'node', value: '1' },
Token { type: 'punctuation', value: ':' },
Token { type: 'node', value: 'something for 1' },
Token { type: 'punctuation', value: ';' },
Token { type: 'keyword', value: 'break' },
Token { type: 'punctuation', value: ';' },
Token { type: 'keyword', value: 'case' },
Token { type: 'node', value: '2' },
Token { type: 'punctuation', value: ':' },
Token { type: 'node', value: 'something for 2' },
Token { type: 'punctuation', value: ';' },
Token { type: 'keyword', value: 'default' },
Token { type: 'punctuation', value: ':' },
Token { type: 'node', value: 'something default' },
Token { type: 'punctuation', value: ';' },
Token { type: 'punctuation', value: '}' },
Token { type: 'node', value: 'something last' },
Token { type: 'punctuation', value: ';' }
Snippet 3
if (a) {
something for A;
} elif (b) {
something for B;
} else {
something else;
}
something last;
↓↓↓
Token { type: 'keyword', value: 'if' },
Token { type: 'punctuation', value: '(' },
Token { type: 'node', value: 'a' },
Token { type: 'punctuation', value: ')' },
Token { type: 'punctuation', value: '{' },
Token { type: 'node', value: 'something for A' },
Token { type: 'punctuation', value: ';' },
Token { type: 'punctuation', value: '}' },
Token { type: 'keyword', value: 'elif' },
Token { type: 'punctuation', value: '(' },
Token { type: 'node', value: 'b' },
Token { type: 'punctuation', value: ')' },
Token { type: 'punctuation', value: '{' },
Token { type: 'node', value: 'something for B' },
Token { type: 'punctuation', value: ';' },
Token { type: 'punctuation', value: '}' },
Token { type: 'keyword', value: 'else' },
Token { type: 'punctuation', value: '{' },
Token { type: 'node', value: 'something else' },
Token { type: 'punctuation', value: ';' },
Token { type: 'punctuation', value: '}' },
Token { type: 'node', value: 'something last' },
Token { type: 'punctuation', value: ';' }
Snippet 4
init;
do {
retry;
} while (failure)
submit;
↓↓↓
Token { type: 'node', value: 'init' },
Token { type: 'punctuation', value: ';' },
Token { type: 'keyword', value: 'do' },
Token { type: 'punctuation', value: '{' },
Token { type: 'node', value: 'retry' },
Token { type: 'punctuation', value: ';' },
Token { type: 'punctuation', value: '}' },
Token { type: 'keyword', value: 'while' },
Token { type: 'punctuation', value: '(' },
Token { type: 'node', value: 'failure' },
Token { type: 'punctuation', value: ')' },
Token { type: 'node', value: 'submit' },
Token { type: 'punctuation', value: ';'