different approach to present code

I have to write this function

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
int cppfsm::updateState(int& state, char c) {

int inState = state;

    switch(state){
    case start:
    if(ident_st.find(c) != ident_st.end()){
    state = scanid;
    }
    else if(c == '"'){
    state = strlit;
    }
    else if(num.find(c) != num.end()){
    state = scannum;
    }
    else if(c == '/'){
    state = readfs;
    }
    break;

    case scanid:
    if(iddelim.find(c) != iddelim.end()){
    state = start;
    }
    else if(c == '\"'){
    state = strlit;
    }
    else if(num.find(c) != num.end()){
    state = scannum;
    }
    else if(c == '/'){
    state = readfs;
    }
    break;

    case comment:
    break;

    case strlit:
    if(c == '\\'){
    state = readesc;
    }
    else if(c == '"'){
    state = start;
    }
    break;

    case readfs:
    if(c == '/'){
    state = comment;
    }
    else if(c == '"'){
    state = strlit;
    }
    else if(num.find(c) != num.end()){
    state = scannum;
    }
    else if(ident_st.find(c) != ident_st.end()){
    state = scanid;
    }
    break;

    case readesc:
    if(escseq.find(c) != escseq.end()){
    state = strlit;
    }
    else {
    state = error;
    }
    break;

    case scannum:
    if(iddelim.find(c) != iddelim.end()){
    state = start;
    }
    else if(num.find(c) != num.end());

    else {
    state = error;
    }
    break;

    case error:
    break;
    }
   	return inState;
	return 0;
    }


is there a different approach to solving it? I mean, is it possible to make it more efficient by coding it in a different way???
Topic archived. No new replies allowed.