clean up switch tokens

pull/2569/head
Alexander Medvednikov 2019-10-27 14:05:50 +03:00
parent 8358528888
commit 1390a39053
4 changed files with 6 additions and 14 deletions

View File

@ -957,8 +957,7 @@ fn (p mut Parser) statements_no_rcbr() string {
} }
mut i := 0 mut i := 0
mut last_st_typ := '' mut last_st_typ := ''
for p.tok != .rcbr && p.tok != .eof && p.tok != .key_case && for p.tok != .rcbr && p.tok != .eof {
p.tok != .key_default {
// println('stm: '+p.tok.str()+', next: '+p.peek().str()) // println('stm: '+p.tok.str()+', next: '+p.peek().str())
last_st_typ = p.statement(true) last_st_typ = p.statement(true)
// println('last st typ=$last_st_typ') // println('last st typ=$last_st_typ')
@ -972,13 +971,8 @@ fn (p mut Parser) statements_no_rcbr() string {
p.error('more than 50 000 statements in function `$p.cur_fn.name`') p.error('more than 50 000 statements in function `$p.cur_fn.name`')
} }
} }
if p.tok != .key_case && p.tok != .key_default && p.peek() != .arrow {
// p.next() // p.next()
p.check(.rcbr) p.check(.rcbr)
}
else {
// p.check(.rcbr)
}
//p.fmt_dec() //p.fmt_dec()
p.close_scope() p.close_scope()
@ -2565,6 +2559,7 @@ fn (p mut Parser) factor() string {
typ = p.name_expr() typ = p.name_expr()
return typ return typ
} }
/*
.key_default { .key_default {
p.next() p.next()
p.next() p.next()
@ -2576,6 +2571,7 @@ fn (p mut Parser) factor() string {
p.next() p.next()
return 'T' return 'T'
} }
*/
.lpar { .lpar {
//p.gen('(/*lpar*/') //p.gen('(/*lpar*/')
p.gen('(') p.gen('(')

View File

@ -83,10 +83,8 @@ enum TokenKind {
key_assert key_assert
key_atomic key_atomic
key_break key_break
key_case
key_const key_const
key_continue key_continue
key_default
key_defer key_defer
key_else key_else
key_embed key_embed
@ -212,7 +210,6 @@ fn build_token_str() []string {
s[TokenKind.key_type] = 'type' s[TokenKind.key_type] = 'type'
s[TokenKind.key_for] = 'for' s[TokenKind.key_for] = 'for'
s[TokenKind.key_switch] = 'switch' s[TokenKind.key_switch] = 'switch'
s[TokenKind.key_case] = 'case'
s[TokenKind.key_fn] = 'fn' s[TokenKind.key_fn] = 'fn'
s[TokenKind.key_true] = 'true' s[TokenKind.key_true] = 'true'
s[TokenKind.key_false] = 'false' s[TokenKind.key_false] = 'false'
@ -222,7 +219,6 @@ fn build_token_str() []string {
s[TokenKind.key_embed] = 'embed' s[TokenKind.key_embed] = 'embed'
s[TokenKind.key_unsafe] = 'unsafe' s[TokenKind.key_unsafe] = 'unsafe'
//Tokens[key_typeof] = 'typeof' //Tokens[key_typeof] = 'typeof'
s[TokenKind.key_default] = 'default'
s[TokenKind.key_enum] = 'enum' s[TokenKind.key_enum] = 'enum'
s[TokenKind.key_interface] = 'interface' s[TokenKind.key_interface] = 'interface'
s[TokenKind.key_pub] = 'pub' s[TokenKind.key_pub] = 'pub'

View File

@ -57,7 +57,7 @@ pub:
mono bool mono bool
} }
struct Image { pub struct Image {
mut: mut:
obj voidptr obj voidptr
pub: pub:

View File

@ -11,7 +11,7 @@ module stbi
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h" #include "stb_image.h"
struct Image { pub struct Image {
mut: mut:
width int width int
height int height int