all: remove commas between enum vals

pull/4555/head
yuyi 2020-04-23 07:16:16 +08:00 committed by GitHub
parent d7ee4755c2
commit 4e1abc8503
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 170 additions and 170 deletions

View File

@ -122,8 +122,8 @@ struct Ray {
// material types, used in radiance() // material types, used in radiance()
enum Refl_t { enum Refl_t {
diff, diff
spec, spec
refr refr
} }

View File

@ -85,15 +85,15 @@ const (
// in the future, maybe we can extend this // in the future, maybe we can extend this
// to support other mime types // to support other mime types
enum AtomType { enum AtomType {
xa_atom = 0, //value 4 xa_atom = 0 //value 4
xa_string = 1, //value 31 xa_string = 1 //value 31
targets = 2, targets = 2
clipboard = 3, clipboard = 3
primary = 4, primary = 4
secondary = 5, secondary = 5
text = 6, text = 6
utf8_string = 7 utf8_string = 7
text_plain = 8, text_plain = 8
text_html = 9 text_html = 9
} }

View File

@ -48,20 +48,20 @@ pub struct Message {
} }
pub enum OPCode { pub enum OPCode {
continuation = 0x00, continuation = 0x00
text_frame = 0x01, text_frame = 0x01
binary_frame = 0x02, binary_frame = 0x02
close = 0x08, close = 0x08
ping = 0x09, ping = 0x09
pong = 0x0A pong = 0x0A
} }
enum State { enum State {
connecting = 0, connecting = 0
connected, connected
open, open
closing, closing
closed closed
} }
struct Uri { struct Uri {
@ -73,15 +73,15 @@ struct Uri {
} }
enum Flag { enum Flag {
has_accept, has_accept
has_connection, has_connection
has_upgrade has_upgrade
} }
struct Frame { struct Frame {
mut: mut:
fin bool fin bool
rsv1 bool rsv1 bool
rsv2 bool rsv2 bool
rsv3 bool rsv3 bool
opcode OPCode opcode OPCode
@ -145,7 +145,7 @@ pub fn (ws mut Client) connect() int {
ai_socktype := C.SOCK_STREAM ai_socktype := C.SOCK_STREAM
handshake := "GET ${uri.resource}${uri.querystring} HTTP/1.1\r\nHost: ${uri.hostname}:${uri.port}\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Key: ${seckey}\r\nSec-WebSocket-Version: 13\r\n\r\n" handshake := "GET ${uri.resource}${uri.querystring} HTTP/1.1\r\nHost: ${uri.hostname}:${uri.port}\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Key: ${seckey}\r\nSec-WebSocket-Version: 13\r\n\r\n"
socket := net.new_socket(ai_family, ai_socktype, 0) or { socket := net.new_socket(ai_family, ai_socktype, 0) or {
l.f(err) l.f(err)
return -1 return -1
@ -155,7 +155,7 @@ pub fn (ws mut Client) connect() int {
l.f(err) l.f(err)
return -1 return -1
} }
optval := 1 optval := 1
ws.socket.setsockopt(C.SOL_SOCKET, C.SO_KEEPALIVE, &optval) or { ws.socket.setsockopt(C.SOL_SOCKET, C.SO_KEEPALIVE, &optval) or {
l.f(err) l.f(err)
@ -169,7 +169,7 @@ pub fn (ws mut Client) connect() int {
ws.lock.lock() ws.lock.lock()
ws.state = .connected ws.state = .connected
ws.lock.unlock() ws.lock.unlock()
res := ws.write_to_server(handshake.str, handshake.len) res := ws.write_to_server(handshake.str, handshake.len)
if res <= 0 { if res <= 0 {
l.f("Handshake failed.") l.f("Handshake failed.")
@ -193,7 +193,7 @@ pub fn (ws mut Client) connect() int {
pub fn (ws mut Client) close(code int, message string){ pub fn (ws mut Client) close(code int, message string){
if ws.state != .closed && ws.socket.sockfd > 1 { if ws.state != .closed && ws.socket.sockfd > 1 {
ws.lock.lock() ws.lock.lock()
ws.state = .closing ws.state = .closing
ws.lock.unlock() ws.lock.unlock()
@ -310,7 +310,7 @@ pub fn (ws mut Client) write(payload byteptr, payload_len int, code OPCode) int
} }
l.d("write: ${bytes_written} bytes written.") l.d("write: ${bytes_written} bytes written.")
free_data: free_data:
unsafe { unsafe {
free(payload) free(payload)
frame_buf.free() frame_buf.free()
header.free() header.free()
@ -325,20 +325,20 @@ pub fn (ws mut Client) listen() {
ws.read() ws.read()
} }
l.i("Listener stopped as websocket was closed.") l.i("Listener stopped as websocket was closed.")
} }
pub fn (ws mut Client) read() int { pub fn (ws mut Client) read() int {
mut bytes_read := u64(0) mut bytes_read := u64(0)
initial_buffer := u64(256) initial_buffer := u64(256)
mut header_len := 2 mut header_len := 2
header_len_offset := 2 header_len_offset := 2
extended_payload16_end_byte := 4 extended_payload16_end_byte := 4
extended_payload64_end_byte := 10 extended_payload64_end_byte := 10
mut payload_len := u64(0) mut payload_len := u64(0)
mut data := C.calloc(initial_buffer, 1)//[`0`].repeat(int(max_buffer)) mut data := C.calloc(initial_buffer, 1)//[`0`].repeat(int(max_buffer))
mut frame := Frame{} mut frame := Frame{}
mut frame_size := u64(header_len) mut frame_size := u64(header_len)
@ -434,7 +434,7 @@ pub fn (ws mut Client) read() int {
} }
} }
} }
// unmask the payload // unmask the payload
if frame.mask { if frame.mask {
for i in 0..payload_len { for i in 0..payload_len {
@ -446,7 +446,7 @@ pub fn (ws mut Client) read() int {
ws.close(0, "") ws.close(0, "")
goto free_data goto free_data
return -1 return -1
} else if frame.opcode in [.text_frame, .binary_frame] { } else if frame.opcode in [.text_frame, .binary_frame] {
data_node: data_node:
l.d("read: recieved text_frame or binary_frame") l.d("read: recieved text_frame or binary_frame")
mut payload := malloc(sizeof(byte) * int(payload_len) + 1) mut payload := malloc(sizeof(byte) * int(payload_len) + 1)
@ -526,7 +526,7 @@ pub fn (ws mut Client) read() int {
return -1 return -1
} }
goto data_node goto data_node
return 0 return 0
} }
else if frame.opcode == .ping { else if frame.opcode == .ping {
l.d("read: ping") l.d("read: ping")
@ -595,7 +595,7 @@ pub fn (ws mut Client) read() int {
ws.send_error_event("Recieved unsupported opcode: ${frame.opcode}") ws.send_error_event("Recieved unsupported opcode: ${frame.opcode}")
ws.close(1002, "Unsupported opcode") ws.close(1002, "Unsupported opcode")
free_data: free_data:
unsafe { unsafe {
free(data) free(data)
} }
return -1 return -1

View File

@ -31,7 +31,7 @@ pub const(
// Results // Results
NO_MATCH_FOUND = -1 NO_MATCH_FOUND = -1
// Errors // Errors
COMPILE_OK = 0 // the regex string compiled, all ok COMPILE_OK = 0 // the regex string compiled, all ok
ERR_CHAR_UNKNOWN = -2 // the char used is unknow to the system ERR_CHAR_UNKNOWN = -2 // the char used is unknow to the system
@ -72,7 +72,7 @@ const(
IST_GROUP_END = 0x94000000 // group end ) IST_GROUP_END = 0x94000000 // group end )
// control instructions // control instructions
IST_PROG_END = u32(0x88000000) //10 0010 xx xxxxxxxx IST_PROG_END = u32(0x88000000) //10 0010 xx xxxxxxxx
//************************************* //*************************************
) )
@ -92,9 +92,9 @@ fn utf8util_char_len(b byte) int {
fn (re RE) get_char(in_txt string, i int) (u32,int) { fn (re RE) get_char(in_txt string, i int) (u32,int) {
// ascii 8 bit // ascii 8 bit
if (re.flag & F_BIN) !=0 || if (re.flag & F_BIN) !=0 ||
in_txt.str[i] & 0x80 == 0 in_txt.str[i] & 0x80 == 0
{ {
return u32(in_txt.str[i]), 1 return u32(in_txt.str[i]), 1
} }
// unicode char // unicode char
char_len := utf8util_char_len(in_txt.str[i]) char_len := utf8util_char_len(in_txt.str[i])
@ -110,11 +110,11 @@ fn (re RE) get_char(in_txt string, i int) (u32,int) {
// get_charb get a char from position i and return an u32 with the unicode code // get_charb get a char from position i and return an u32 with the unicode code
[inline] [inline]
fn (re RE) get_charb(in_txt byteptr, i int) (u32,int) { fn (re RE) get_charb(in_txt byteptr, i int) (u32,int) {
// ascii 8 bit // ascii 8 bit
if (re.flag & F_BIN) !=0 || if (re.flag & F_BIN) !=0 ||
in_txt[i] & 0x80 == 0 in_txt[i] & 0x80 == 0
{ {
return u32(in_txt[i]), 1 return u32(in_txt[i]), 1
} }
// unicode char // unicode char
char_len := utf8util_char_len(in_txt[i]) char_len := utf8util_char_len(in_txt[i])
@ -191,8 +191,8 @@ pub fn (re RE) get_parse_error_string(err int) string {
match err { match err {
COMPILE_OK { return "COMPILE_OK" } COMPILE_OK { return "COMPILE_OK" }
NO_MATCH_FOUND { return "NO_MATCH_FOUND" } NO_MATCH_FOUND { return "NO_MATCH_FOUND" }
ERR_CHAR_UNKNOWN { return "ERR_CHAR_UNKNOWN" } ERR_CHAR_UNKNOWN { return "ERR_CHAR_UNKNOWN" }
ERR_UNDEFINED { return "ERR_UNDEFINED" } ERR_UNDEFINED { return "ERR_UNDEFINED" }
ERR_INTERNAL_ERROR { return "ERR_INTERNAL_ERROR" } ERR_INTERNAL_ERROR { return "ERR_INTERNAL_ERROR" }
ERR_CC_ALLOC_OVERFLOW { return "ERR_CC_ALLOC_OVERFLOW" } ERR_CC_ALLOC_OVERFLOW { return "ERR_CC_ALLOC_OVERFLOW" }
ERR_SYNTAX_ERROR { return "ERR_SYNTAX_ERROR" } ERR_SYNTAX_ERROR { return "ERR_SYNTAX_ERROR" }
@ -256,7 +256,7 @@ mut:
group_id int = -1 // id of the group group_id int = -1 // id of the group
goto_pc int = -1 // jump to this PC if is needed goto_pc int = -1 // jump to this PC if is needed
// OR flag for the token // OR flag for the token
next_is_or bool = false // true if the next token is an OR next_is_or bool = false // true if the next token is an OR
} }
@ -267,13 +267,13 @@ fn (tok mut Token) reset() {
/****************************************************************************** /******************************************************************************
* *
* Regex struct * Regex struct
* *
******************************************************************************/ ******************************************************************************/
pub const ( pub const (
F_NL = 0x00000001 // end the match when find a new line symbol F_NL = 0x00000001 // end the match when find a new line symbol
F_MS = 0x00000002 // match true only if the match is at the start of the string F_MS = 0x00000002 // match true only if the match is at the start of the string
F_ME = 0x00000004 // match true only if the match is at the end of the string F_ME = 0x00000004 // match true only if the match is at the end of the string
F_EFM = 0x00000100 // exit on first token matched, used by search F_EFM = 0x00000100 // exit on first token matched, used by search
F_BIN = 0x00000200 // work only on bytes, ignore utf-8 F_BIN = 0x00000200 // work only on bytes, ignore utf-8
@ -303,7 +303,7 @@ pub mut:
// state index // state index
state_stack_index int= -1 state_stack_index int= -1
state_stack []StateDotObj state_stack []StateDotObj
// groups // groups
group_count int = 0 // number of groups in this regex struct group_count int = 0 // number of groups in this regex struct
@ -326,10 +326,10 @@ pub mut:
} }
// Reset RE object // Reset RE object
//[inline] //[inline]
fn (re mut RE) reset(){ fn (re mut RE) reset(){
re.cc_index = 0 re.cc_index = 0
mut i := 0 mut i := 0
for i < re.prog.len { for i < re.prog.len {
re.prog[i].group_rep = 0 // clear repetition of the group re.prog[i].group_rep = 0 // clear repetition of the group
@ -396,9 +396,9 @@ const(
) )
enum BSLS_parse_state { enum BSLS_parse_state {
start, start
bsls_found, bsls_found
bsls_char, bsls_char
normal_char normal_char
} }
@ -467,11 +467,11 @@ mut:
} }
enum CharClass_parse_state { enum CharClass_parse_state {
start, start
in_char, in_char
in_bsls, in_bsls
separator, separator
finish, finish
} }
fn (re RE) get_char_class(pc int) string { fn (re RE) get_char_class(pc int) string {
@ -482,7 +482,7 @@ fn (re RE) get_char_class(pc int) string {
mut i := 0 mut i := 0
mut tmp := 0 mut tmp := 0
for cc_i >= 0 && cc_i < re.cc.len && re.cc[cc_i].cc_type != CC_END { for cc_i >= 0 && cc_i < re.cc.len && re.cc[cc_i].cc_type != CC_END {
if re.cc[cc_i].cc_type == CC_BSLS { if re.cc[cc_i].cc_type == CC_BSLS {
buf_ptr[i++] = `\\` buf_ptr[i++] = `\\`
buf_ptr[i++] = byte(re.cc[cc_i].ch0) buf_ptr[i++] = byte(re.cc[cc_i].ch0)
@ -491,7 +491,7 @@ fn (re RE) get_char_class(pc int) string {
tmp = 3 tmp = 3
for tmp >= 0 { for tmp >= 0 {
x := byte((re.cc[cc_i].ch0 >> (tmp*8)) & 0xFF) x := byte((re.cc[cc_i].ch0 >> (tmp*8)) & 0xFF)
if x != 0 { if x != 0 {
buf_ptr[i++] = x buf_ptr[i++] = x
} }
tmp-- tmp--
@ -501,7 +501,7 @@ fn (re RE) get_char_class(pc int) string {
tmp = 3 tmp = 3
for tmp >= 0 { for tmp >= 0 {
x := byte((re.cc[cc_i].ch0 >> (tmp*8)) & 0xFF) x := byte((re.cc[cc_i].ch0 >> (tmp*8)) & 0xFF)
if x != 0 { if x != 0 {
buf_ptr[i++] = x buf_ptr[i++] = x
} }
tmp-- tmp--
@ -510,7 +510,7 @@ fn (re RE) get_char_class(pc int) string {
tmp = 3 tmp = 3
for tmp >= 0 { for tmp >= 0 {
x := byte((re.cc[cc_i].ch1 >> (tmp*8)) & 0xFF) x := byte((re.cc[cc_i].ch1 >> (tmp*8)) & 0xFF)
if x != 0 { if x != 0 {
buf_ptr[i++] = x buf_ptr[i++] = x
} }
tmp-- tmp--
@ -519,7 +519,7 @@ fn (re RE) get_char_class(pc int) string {
cc_i++ cc_i++
} }
buf_ptr[i] = byte(0) buf_ptr[i] = byte(0)
return tos_clone( buf_ptr ) return tos_clone( buf_ptr )
} }
@ -553,7 +553,7 @@ fn (re mut RE) parse_char_class(in_txt string, in_i int) (int, int, u32) {
// check if we are out of memory for char classes // check if we are out of memory for char classes
if tmp_index >= re.cc.len { if tmp_index >= re.cc.len {
return ERR_CC_ALLOC_OVERFLOW,0,u32(0) return ERR_CC_ALLOC_OVERFLOW,0,u32(0)
} }
// get our char // get our char
@ -601,11 +601,11 @@ fn (re mut RE) parse_char_class(in_txt string, in_i int) (int, int, u32) {
} }
// simple char // simple char
if (status == .start || status == .in_char) && if (status == .start || status == .in_char) &&
ch != `-` && ch != `]` ch != `-` && ch != `]`
{ {
status = .in_char status = .in_char
re.cc[tmp_index].cc_type = CC_CHAR re.cc[tmp_index].cc_type = CC_CHAR
re.cc[tmp_index].ch0 = char_tmp re.cc[tmp_index].ch0 = char_tmp
re.cc[tmp_index].ch1 = char_tmp re.cc[tmp_index].ch1 = char_tmp
@ -637,7 +637,7 @@ fn (re mut RE) parse_char_class(in_txt string, in_i int) (int, int, u32) {
re.cc[tmp_index].ch0 = 0 re.cc[tmp_index].ch0 = 0
re.cc[tmp_index].ch1 = 0 re.cc[tmp_index].ch1 = 0
re.cc_index = tmp_index+1 re.cc_index = tmp_index+1
return res_index, i-in_i+2, cc_type return res_index, i-in_i+2, cc_type
} }
@ -655,12 +655,12 @@ fn (re mut RE) parse_char_class(in_txt string, in_i int) (int, int, u32) {
// Quantifier // Quantifier
// //
enum Quant_parse_state { enum Quant_parse_state {
start, start
min_parse, min_parse
comma_checked, comma_checked
max_parse, max_parse
greedy, greedy
gredy_parse, gredy_parse
finish finish
} }
@ -676,7 +676,7 @@ fn (re RE) parse_quantifier(in_txt string, in_i int) (int, int, int, bool) {
for i < in_txt.len { for i < in_txt.len {
ch = in_txt.str[i] ch = in_txt.str[i]
//C.printf("%c status: %d\n",ch,status) //C.printf("%c status: %d\n",ch,status)
// exit on no compatible char with {} quantifier // exit on no compatible char with {} quantifier
@ -785,13 +785,13 @@ fn (re RE) parse_quantifier(in_txt string, in_i int) (int, int, int, bool) {
// Groups // Groups
// //
enum Group_parse_state { enum Group_parse_state {
start, start
q_mark, // (? q_mark // (?
q_mark1, // (?:|P checking q_mark1 // (?:|P checking
p_status, // (?P p_status // (?P
p_start, // (?P< p_start // (?P<
p_end, // (?P<...> p_end // (?P<...>
p_in_name, // (?P<... p_in_name // (?P<...
finish finish
} }
@ -921,7 +921,7 @@ pub fn (re mut RE) compile(in_txt string) (int,int) {
// IST_GROUP_START // IST_GROUP_START
if char_len == 1 && pc >= 0 && byte(char_tmp) == `(` { if char_len == 1 && pc >= 0 && byte(char_tmp) == `(` {
//check max groups allowed //check max groups allowed
if group_count > re.group_max { if group_count > re.group_max {
return ERR_GROUPS_OVERFLOW,i+1 return ERR_GROUPS_OVERFLOW,i+1
@ -934,7 +934,7 @@ pub fn (re mut RE) compile(in_txt string) (int,int) {
} }
tmp_res, cgroup_flag, cgroup_name, next_i := re.parse_groups(in_txt,i) tmp_res, cgroup_flag, cgroup_name, next_i := re.parse_groups(in_txt,i)
// manage question mark format error // manage question mark format error
if tmp_res < -1 { if tmp_res < -1 {
return ERR_GROUP_QM_NOTATION,next_i return ERR_GROUP_QM_NOTATION,next_i
@ -967,11 +967,11 @@ pub fn (re mut RE) compile(in_txt string) (int,int) {
re.prog[pc].ist = u32(0) | IST_GROUP_START re.prog[pc].ist = u32(0) | IST_GROUP_START
re.prog[pc].rep_min = 1 re.prog[pc].rep_min = 1
re.prog[pc].rep_max = 1 re.prog[pc].rep_max = 1
// set the group id // set the group id
if cgroup_flag == false { if cgroup_flag == false {
//println("NO CAPTURE GROUP") //println("NO CAPTURE GROUP")
re.prog[pc].group_id = -1 re.prog[pc].group_id = -1
} else { } else {
re.prog[pc].group_id = group_id re.prog[pc].group_id = group_id
} }
@ -996,7 +996,7 @@ pub fn (re mut RE) compile(in_txt string) (int,int) {
re.prog[pc].goto_pc = goto_pc // PC where to jump if a group need re.prog[pc].goto_pc = goto_pc // PC where to jump if a group need
re.prog[pc].group_id = re.prog[goto_pc].group_id // id of this group, used for storing data re.prog[pc].group_id = re.prog[goto_pc].group_id // id of this group, used for storing data
re.prog[goto_pc].goto_pc = pc // start goto point to the end group pc re.prog[goto_pc].goto_pc = pc // start goto point to the end group pc
//re.prog[goto_pc].group_id = group_count // id of this group, used for storing data //re.prog[goto_pc].group_id = group_count // id of this group, used for storing data
@ -1103,7 +1103,7 @@ pub fn (re mut RE) compile(in_txt string) (int,int) {
} }
} }
} }
// IST_BSLS_CHAR // IST_BSLS_CHAR
if char_len==1 && pc >= 0{ if char_len==1 && pc >= 0{
if byte(char_tmp) == `\\` { if byte(char_tmp) == `\\` {
@ -1118,7 +1118,7 @@ pub fn (re mut RE) compile(in_txt string) (int,int) {
re.prog[pc].ch = BSLS_VALIDATOR_ARRAY[bsls_index].ch re.prog[pc].ch = BSLS_VALIDATOR_ARRAY[bsls_index].ch
pc = pc + 1 pc = pc + 1
continue continue
} }
// this is an escape char, skip the bsls and continue as a normal char // this is an escape char, skip the bsls and continue as a normal char
else if bsls_index == NO_MATCH_FOUND { else if bsls_index == NO_MATCH_FOUND {
i += char_len i += char_len
@ -1156,7 +1156,7 @@ pub fn (re mut RE) compile(in_txt string) (int,int) {
if pc > 0 && re.prog[pc-1].ist == IST_OR_BRANCH { if pc > 0 && re.prog[pc-1].ist == IST_OR_BRANCH {
return ERR_SYNTAX_ERROR,in_txt.len return ERR_SYNTAX_ERROR,in_txt.len
} }
// store the number of groups in the query // store the number of groups in the query
re.group_count = group_count+1 re.group_count = group_count+1
@ -1175,8 +1175,8 @@ pub fn (re mut RE) compile(in_txt string) (int,int) {
} }
// init the state stack // init the state stack
re.state_stack = [StateDotObj{}].repeat(tmp_count+1) re.state_stack = [StateDotObj{}].repeat(tmp_count+1)
// OR branch // OR branch
// a|b|cd // a|b|cd
// d exit point // d exit point
@ -1191,13 +1191,13 @@ pub fn (re mut RE) compile(in_txt string) (int,int) {
// manange a|b chains like a|(b)|c|d... // manange a|b chains like a|(b)|c|d...
// standard solution // standard solution
if re.prog[pc1].ist != IST_OR_BRANCH && if re.prog[pc1].ist != IST_OR_BRANCH &&
re.prog[pc1+1].ist == IST_OR_BRANCH && re.prog[pc1+1].ist == IST_OR_BRANCH &&
re.prog[pc1+2].ist != IST_OR_BRANCH re.prog[pc1+2].ist != IST_OR_BRANCH
{ {
re.prog[pc1].next_is_or = true // set that the next token is an OR re.prog[pc1].next_is_or = true // set that the next token is an OR
re.prog[pc1+1].rep_min = pc1+2 // failed match jump re.prog[pc1+1].rep_min = pc1+2 // failed match jump
// match jump, if an OR chain the next token will be an OR token // match jump, if an OR chain the next token will be an OR token
mut pc2 := pc1+2 mut pc2 := pc1+2
for pc2 < pc-1 { for pc2 < pc-1 {
@ -1213,10 +1213,10 @@ pub fn (re mut RE) compile(in_txt string) (int,int) {
pc2++ pc2++
} }
//C.printf("Compile OR postproc. [%d,OR %d,%d]\n",pc1,pc1+1,pc2) //C.printf("Compile OR postproc. [%d,OR %d,%d]\n",pc1,pc1+1,pc2)
pc1 = pc2 pc1 = pc2
continue continue
} }
pc1++ pc1++
} }
@ -1236,13 +1236,13 @@ pub fn (re RE) get_code() string {
mut pc1 := 0 mut pc1 := 0
mut res := strings.new_builder(re.cc.len*2*re.prog.len) mut res := strings.new_builder(re.cc.len*2*re.prog.len)
res.write("========================================\nv RegEx compiler v $V_REGEX_VERSION output:\n") res.write("========================================\nv RegEx compiler v $V_REGEX_VERSION output:\n")
mut stop_flag := false mut stop_flag := false
for pc1 <= re.prog.len { for pc1 <= re.prog.len {
tk := re.prog[pc1] tk := re.prog[pc1]
res.write("PC:${pc1:3d}") res.write("PC:${pc1:3d}")
res.write(" ist: ") res.write(" ist: ")
res.write("${tk.ist:8x}".replace(" ","0") ) res.write("${tk.ist:8x}".replace(" ","0") )
res.write(" ") res.write(" ")
@ -1313,7 +1313,7 @@ pub fn (re RE) get_query() string {
for i < re.prog.len && re.prog[i].ist != IST_PROG_END && re.prog[i].ist != 0{ for i < re.prog.len && re.prog[i].ist != IST_PROG_END && re.prog[i].ist != 0{
tk := &re.prog[i] tk := &re.prog[i]
ch := tk.ist ch := tk.ist
// GROUP start // GROUP start
if ch == IST_GROUP_START { if ch == IST_GROUP_START {
if re.debug == 0 { if re.debug == 0 {
@ -1325,7 +1325,7 @@ pub fn (re RE) get_query() string {
res.write("#${tk.group_id}(") res.write("#${tk.group_id}(")
} }
} }
for x in re.group_map.keys() { for x in re.group_map.keys() {
if re.group_map[x] == (tk.group_id+1) { if re.group_map[x] == (tk.group_id+1) {
res.write("?P<${x}>") res.write("?P<${x}>")
@ -1414,18 +1414,18 @@ pub fn (re RE) get_query() string {
* *
******************************************************************************/ ******************************************************************************/
enum match_state{ enum match_state{
start = 0, start = 0
stop, stop
end, end
new_line, new_line
ist_load, // load and execute instruction ist_load // load and execute instruction
ist_next, // go to next instruction ist_next // go to next instruction
ist_next_ks, // go to next instruction without clenaning the state ist_next_ks // go to next instruction without clenaning the state
ist_quant_p, // match positive ,quantifier check ist_quant_p // match positive ,quantifier check
ist_quant_n, // match negative, quantifier check ist_quant_n // match negative, quantifier check
ist_quant_pg, // match positive ,group quantifier check ist_quant_pg // match positive ,group quantifier check
ist_quant_ng, // match negative ,group quantifier check ist_quant_ng // match negative ,group quantifier check
} }
fn state_str(s match_state) string { fn state_str(s match_state) string {
@ -1443,7 +1443,7 @@ fn state_str(s match_state) string {
.ist_quant_pg { return "ist_quant_pg" } .ist_quant_pg { return "ist_quant_pg" }
.ist_quant_ng { return "ist_quant_ng" } .ist_quant_ng { return "ist_quant_ng" }
else { return "UNKN" } else { return "UNKN" }
} }
} }
struct StateObj { struct StateObj {
@ -1459,7 +1459,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
mut first_match := -1 //index of the first match mut first_match := -1 //index of the first match
mut i := 0 // source string index mut i := 0 // source string index
mut ch := u32(0) // examinated char mut ch := u32(0) // examinated char
mut char_len := 0 // utf8 examinated char len mut char_len := 0 // utf8 examinated char len
mut m_state := match_state.start // start point for the matcher FSM mut m_state := match_state.start // start point for the matcher FSM
@ -1475,7 +1475,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
mut step_count := 0 // stats for debug mut step_count := 0 // stats for debug
mut dbg_line := 0 // count debug line printed mut dbg_line := 0 // count debug line printed
re.reset() re.reset()
if re.debug>0 { if re.debug>0 {
@ -1488,7 +1488,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
} }
for m_state != .end { for m_state != .end {
if pc >= 0 && pc < re.prog.len { if pc >= 0 && pc < re.prog.len {
ist = re.prog[pc].ist ist = re.prog[pc].ist
}else if pc >= re.prog.len { }else if pc >= re.prog.len {
@ -1502,7 +1502,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
if re.debug>0 { if re.debug>0 {
mut buf2 := strings.new_builder(re.cc.len+128) mut buf2 := strings.new_builder(re.cc.len+128)
// print all the instructions // print all the instructions
// end of the input text // end of the input text
if i >= in_txt_len { if i >= in_txt_len {
@ -1513,7 +1513,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
// print only the exe instruction // print only the exe instruction
if (re.debug == 1 && m_state == .ist_load) || if (re.debug == 1 && m_state == .ist_load) ||
re.debug == 2 re.debug == 2
{ {
if ist == IST_PROG_END { if ist == IST_PROG_END {
buf2.write("# ${step_count:3d} PROG_END\n") buf2.write("# ${step_count:3d} PROG_END\n")
} }
@ -1521,7 +1521,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
buf2.write("# ${step_count:3d} s: ${state_str(m_state):12s} PC: NA\n") buf2.write("# ${step_count:3d} s: ${state_str(m_state):12s} PC: NA\n")
}else{ }else{
ch, char_len = re.get_charb(in_txt,i) ch, char_len = re.get_charb(in_txt,i)
buf2.write("# ${step_count:3d} s: ${state_str(m_state):12s} PC: ${pc:3d}=>") buf2.write("# ${step_count:3d} s: ${state_str(m_state):12s} PC: ${pc:3d}=>")
buf2.write("${ist:8x}".replace(" ","0")) buf2.write("${ist:8x}".replace(" ","0"))
buf2.write(" i,ch,len:[${i:3d},'${utf8_str(ch)}',${char_len}] f.m:[${first_match:3d},${state.match_index:3d}] ") buf2.write(" i,ch,len:[${i:3d},'${utf8_str(ch)}',${char_len}] f.m:[${first_match:3d},${state.match_index:3d}] ")
@ -1569,7 +1569,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
// we're out of text, manage it // we're out of text, manage it
if i >= in_txt_len || m_state == .new_line { if i >= in_txt_len || m_state == .new_line {
// manage groups // manage groups
if group_index >= 0 && state.match_index >= 0 { if group_index >= 0 && state.match_index >= 0 {
//C.printf("End text with open groups!\n") //C.printf("End text with open groups!\n")
@ -1604,7 +1604,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
if (re.group_csave_index + 3) < re.group_csave.len { if (re.group_csave_index + 3) < re.group_csave.len {
// incrment counter // incrment counter
re.group_csave[0]++ re.group_csave[0]++
// save the record // save the record
re.group_csave[re.group_csave_index++] = g_index >> 1 // group id re.group_csave[re.group_csave_index++] = g_index >> 1 // group id
re.group_csave[re.group_csave_index++] = re.groups[g_index] // start re.group_csave[re.group_csave_index++] = re.groups[g_index] // start
re.group_csave[re.group_csave_index++] = re.groups[g_index+1] // end re.group_csave[re.group_csave_index++] = re.groups[g_index+1] // end
@ -1640,7 +1640,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
if pc < 0 || pc > re.prog.len { if pc < 0 || pc > re.prog.len {
//C.printf("ERROR!! PC overflow!!\n") //C.printf("ERROR!! PC overflow!!\n")
return ERR_INTERNAL_ERROR, i return ERR_INTERNAL_ERROR, i
} }
m_state = .ist_load m_state = .ist_load
continue continue
} }
@ -1652,7 +1652,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
if pc < 0 || pc > re.prog.len { if pc < 0 || pc > re.prog.len {
//C.printf("ERROR!! PC overflow!!\n") //C.printf("ERROR!! PC overflow!!\n")
return ERR_INTERNAL_ERROR, i return ERR_INTERNAL_ERROR, i
} }
m_state = .ist_load m_state = .ist_load
continue continue
} }
@ -1666,9 +1666,9 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
continue continue
} }
// check if stop // check if stop
if m_state == .stop { if m_state == .stop {
// we are in search mode, don't exit until the end // we are in search mode, don't exit until the end
if re.flag & F_SRC != 0 && ist != IST_PROG_END { if re.flag & F_SRC != 0 && ist != IST_PROG_END {
pc = -1 pc = -1
@ -1692,21 +1692,21 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
continue continue
} }
if ist == IST_PROG_END { if ist == IST_PROG_END {
return first_match,i return first_match,i
} }
// exit on no match // exit on no match
return result,0 return result,0
} }
// ist_load // ist_load
if m_state == .ist_load { if m_state == .ist_load {
// program end // program end
if ist == IST_PROG_END { if ist == IST_PROG_END {
// if we are in match exit well // if we are in match exit well
if group_index >= 0 && state.match_index >= 0 { if group_index >= 0 && state.match_index >= 0 {
group_index = -1 group_index = -1
} }
@ -1721,7 +1721,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
re.state_stack_index = -1 re.state_stack_index = -1
m_state = .stop m_state = .stop
continue continue
} }
// check GROUP start, no quantifier is checkd for this token!! // check GROUP start, no quantifier is checkd for this token!!
@ -1730,7 +1730,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
group_data[group_index] = re.prog[pc].goto_pc // save where is IST_GROUP_END, we will use it for escape group_data[group_index] = re.prog[pc].goto_pc // save where is IST_GROUP_END, we will use it for escape
group_stack[group_index]=i // index where we start to manage group_stack[group_index]=i // index where we start to manage
//C.printf("group_index %d rep %d\n", group_index, re.prog[re.prog[pc].goto_pc].group_rep) //C.printf("group_index %d rep %d\n", group_index, re.prog[re.prog[pc].goto_pc].group_rep)
m_state = .ist_next m_state = .ist_next
continue continue
} }
@ -1740,7 +1740,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
// we are in matching streak // we are in matching streak
if state.match_index >= 0 { if state.match_index >= 0 {
// restore txt index stack and save the group data // restore txt index stack and save the group data
//C.printf("g.id: %d group_index: %d\n", re.prog[pc].group_id, group_index) //C.printf("g.id: %d group_index: %d\n", re.prog[pc].group_id, group_index)
if group_index >= 0 && re.prog[pc].group_id >= 0 { if group_index >= 0 && re.prog[pc].group_id >= 0 {
start_i := group_stack[group_index] start_i := group_stack[group_index]
@ -1762,30 +1762,30 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
if (re.group_csave_index + 3) < re.group_csave.len { if (re.group_csave_index + 3) < re.group_csave.len {
// incrment counter // incrment counter
re.group_csave[0]++ re.group_csave[0]++
// save the record // save the record
re.group_csave[re.group_csave_index++] = g_index >> 1 // group id re.group_csave[re.group_csave_index++] = g_index >> 1 // group id
re.group_csave[re.group_csave_index++] = re.groups[g_index] // start re.group_csave[re.group_csave_index++] = re.groups[g_index] // start
re.group_csave[re.group_csave_index++] = re.groups[g_index+1] // end re.group_csave[re.group_csave_index++] = re.groups[g_index+1] // end
} }
} }
} }
re.prog[pc].group_rep++ // increase repetitions re.prog[pc].group_rep++ // increase repetitions
//C.printf("GROUP %d END %d\n", group_index, re.prog[pc].group_rep) //C.printf("GROUP %d END %d\n", group_index, re.prog[pc].group_rep)
m_state = .ist_quant_pg m_state = .ist_quant_pg
continue continue
} }
m_state = .ist_quant_ng m_state = .ist_quant_ng
continue continue
} }
// check OR // check OR
else if ist == IST_OR_BRANCH { else if ist == IST_OR_BRANCH {
if state.match_index >= 0 { if state.match_index >= 0 {
pc = re.prog[pc].rep_max pc = re.prog[pc].rep_max
//C.printf("IST_OR_BRANCH True pc: %d\n", pc) //C.printf("IST_OR_BRANCH True pc: %d\n", pc)
}else{ }else{
pc = re.prog[pc].rep_min pc = re.prog[pc].rep_min
//C.printf("IST_OR_BRANCH False pc: %d\n", pc) //C.printf("IST_OR_BRANCH False pc: %d\n", pc)
@ -1805,13 +1805,13 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
first_match = i first_match = i
} }
state.match_index = i state.match_index = i
re.prog[pc].rep++ re.prog[pc].rep++
//if re.prog[pc].rep >= re.prog[pc].rep_min && re.prog[pc].rep <= re.prog[pc].rep_max { //if re.prog[pc].rep >= re.prog[pc].rep_min && re.prog[pc].rep <= re.prog[pc].rep_max {
if re.prog[pc].rep >= 0 && re.prog[pc].rep <= re.prog[pc].rep_max { if re.prog[pc].rep >= 0 && re.prog[pc].rep <= re.prog[pc].rep_max {
//C.printf("DOT CHAR save state : %d\n", re.state_stack_index) //C.printf("DOT CHAR save state : %d\n", re.state_stack_index)
// save the state // save the state
// manage first dot char // manage first dot char
if re.state_stack_index < 0 { if re.state_stack_index < 0 {
re.state_stack_index++ re.state_stack_index++
@ -1828,7 +1828,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
if re.prog[pc].rep >= 1 && re.state_stack_index >= 0 { if re.prog[pc].rep >= 1 && re.state_stack_index >= 0 {
re.state_stack[re.state_stack_index].i = i + char_len re.state_stack[re.state_stack_index].i = i + char_len
} }
// manage * and {0,} quantifier // manage * and {0,} quantifier
if re.prog[pc].rep_min > 0 { if re.prog[pc].rep_min > 0 {
@ -1845,12 +1845,12 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
else if ist == IST_CHAR_CLASS_POS || ist == IST_CHAR_CLASS_NEG { else if ist == IST_CHAR_CLASS_POS || ist == IST_CHAR_CLASS_NEG {
state.match_flag = false state.match_flag = false
mut cc_neg := false mut cc_neg := false
if ist == IST_CHAR_CLASS_NEG { if ist == IST_CHAR_CLASS_NEG {
cc_neg = true cc_neg = true
} }
mut cc_res := re.check_char_class(pc,ch) mut cc_res := re.check_char_class(pc,ch)
if cc_neg { if cc_neg {
cc_res = !cc_res cc_res = !cc_res
} }
@ -1858,11 +1858,11 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
if cc_res { if cc_res {
state.match_flag = true state.match_flag = true
l_ist = u32(IST_CHAR_CLASS_POS) l_ist = u32(IST_CHAR_CLASS_POS)
if first_match < 0 { if first_match < 0 {
first_match = i first_match = i
} }
state.match_index = i state.match_index = i
re.prog[pc].rep++ // increase repetitions re.prog[pc].rep++ // increase repetitions
@ -1882,11 +1882,11 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
if tmp_res { if tmp_res {
state.match_flag = true state.match_flag = true
l_ist = u32(IST_BSLS_CHAR) l_ist = u32(IST_BSLS_CHAR)
if first_match < 0 { if first_match < 0 {
first_match = i first_match = i
} }
state.match_index = i state.match_index = i
re.prog[pc].rep++ // increase repetitions re.prog[pc].rep++ // increase repetitions
@ -1907,7 +1907,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
{ {
state.match_flag = true state.match_flag = true
l_ist = IST_SIMPLE_CHAR l_ist = IST_SIMPLE_CHAR
if first_match < 0 { if first_match < 0 {
first_match = i first_match = i
} }
@ -1921,19 +1921,19 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
} }
m_state = .ist_quant_n m_state = .ist_quant_n
continue continue
} }
/* UNREACHABLE */ /* UNREACHABLE */
//C.printf("PANIC2!! state: %d\n", m_state) //C.printf("PANIC2!! state: %d\n", m_state)
return ERR_INTERNAL_ERROR, i return ERR_INTERNAL_ERROR, i
} }
/*********************************** /***********************************
* Quantifier management * Quantifier management
***********************************/ ***********************************/
// ist_quant_ng // ist_quant_ng
if m_state == .ist_quant_ng { if m_state == .ist_quant_ng {
// we are finished here // we are finished here
if group_index < 0 { if group_index < 0 {
//C.printf("Early stop!\n") //C.printf("Early stop!\n")
@ -1943,14 +1943,14 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
} }
tmp_pc := group_data[group_index] // PC to the end of the group token tmp_pc := group_data[group_index] // PC to the end of the group token
rep := re.prog[tmp_pc].group_rep // use a temp variable rep := re.prog[tmp_pc].group_rep // use a temp variable
re.prog[tmp_pc].group_rep = 0 // clear the repetitions re.prog[tmp_pc].group_rep = 0 // clear the repetitions
//C.printf(".ist_quant_ng group_pc_end: %d rep: %d\n", tmp_pc,rep) //C.printf(".ist_quant_ng group_pc_end: %d rep: %d\n", tmp_pc,rep)
if rep >= re.prog[tmp_pc].rep_min { if rep >= re.prog[tmp_pc].rep_min {
//C.printf("ist_quant_ng GROUP CLOSED OK group_index: %d\n", group_index) //C.printf("ist_quant_ng GROUP CLOSED OK group_index: %d\n", group_index)
i = group_stack[group_index] i = group_stack[group_index]
pc = tmp_pc pc = tmp_pc
group_index-- group_index--
@ -1968,7 +1968,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
} }
else if rep>0 && rep < re.prog[tmp_pc].rep_min { else if rep>0 && rep < re.prog[tmp_pc].rep_min {
//C.printf("ist_quant_ng UNDER THE MINIMUM g.i: %d\n", group_index) //C.printf("ist_quant_ng UNDER THE MINIMUM g.i: %d\n", group_index)
// check if we are inside a group, if yes exit from the nested groups // check if we are inside a group, if yes exit from the nested groups
if group_index > 0{ if group_index > 0{
group_index-- group_index--
@ -2013,14 +2013,14 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
//C.printf(".ist_quant_pg\n") //C.printf(".ist_quant_pg\n")
mut tmp_pc := pc mut tmp_pc := pc
if group_index >= 0 { if group_index >= 0 {
tmp_pc = group_data[group_index] tmp_pc = group_data[group_index]
} }
rep := re.prog[tmp_pc].group_rep rep := re.prog[tmp_pc].group_rep
if rep < re.prog[tmp_pc].rep_min { if rep < re.prog[tmp_pc].rep_min {
//C.printf("ist_quant_pg UNDER RANGE\n") //C.printf("ist_quant_pg UNDER RANGE\n")
pc = re.prog[tmp_pc].goto_pc pc = re.prog[tmp_pc].goto_pc
m_state = .ist_next m_state = .ist_next
continue continue
} }
@ -2047,12 +2047,12 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
m_state = .ist_next m_state = .ist_next
continue continue
} }
/* UNREACHABLE */ /* UNREACHABLE */
//C.printf("PANIC3!! state: %d\n", m_state) //C.printf("PANIC3!! state: %d\n", m_state)
return ERR_INTERNAL_ERROR, i return ERR_INTERNAL_ERROR, i
} }
// ist_quant_n // ist_quant_n
else if m_state == .ist_quant_n { else if m_state == .ist_quant_n {
rep := re.prog[pc].rep rep := re.prog[pc].rep
@ -2091,7 +2091,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
result = NO_MATCH_FOUND result = NO_MATCH_FOUND
m_state = .stop m_state = .stop
continue continue
//return NO_MATCH_FOUND, 0 //return NO_MATCH_FOUND, 0
} }
// ist_quant_p // ist_quant_p
@ -2102,7 +2102,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
} }
rep := re.prog[pc].rep rep := re.prog[pc].rep
// under range // under range
if rep > 0 && rep < re.prog[pc].rep_min { if rep > 0 && rep < re.prog[pc].rep_min {
//C.printf("ist_quant_p UNDER RANGE\n") //C.printf("ist_quant_p UNDER RANGE\n")
@ -2113,7 +2113,7 @@ pub fn (re mut RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
// range ok, continue loop // range ok, continue loop
else if rep >= re.prog[pc].rep_min && rep < re.prog[pc].rep_max { else if rep >= re.prog[pc].rep_min && rep < re.prog[pc].rep_max {
//C.printf("ist_quant_p IN RANGE\n") //C.printf("ist_quant_p IN RANGE\n")
// check greedy flag, if true exit on minimum // check greedy flag, if true exit on minimum
if re.prog[pc].greedy == true { if re.prog[pc].greedy == true {
m_state = .ist_next m_state = .ist_next
@ -2182,7 +2182,7 @@ pub fn new_regex_by_size(mult int) RE {
re.prog = [Token{}].repeat(MAX_CODE_LEN*mult) // max program length, default 256 istructions re.prog = [Token{}].repeat(MAX_CODE_LEN*mult) // max program length, default 256 istructions
re.cc = [CharClass{}].repeat(MAX_CODE_LEN*mult) // char class list re.cc = [CharClass{}].repeat(MAX_CODE_LEN*mult) // char class list
re.group_max_nested = 3*mult // max nested group re.group_max_nested = 3*mult // max nested group
return re return re
} }
@ -2192,7 +2192,7 @@ pub fn new_regex_by_size(mult int) RE {
pub fn (re mut RE) match_string(in_txt string) (int,int) { pub fn (re mut RE) match_string(in_txt string) (int,int) {
start, end := re.match_base(in_txt.str,in_txt.len) start, end := re.match_base(in_txt.str,in_txt.len)
if start >= 0 && end > start { if start >= 0 && end > start {
if (re.flag & F_MS) != 0 && start > 0 { if (re.flag & F_MS) != 0 && start > 0 {
return NO_MATCH_FOUND, 0 return NO_MATCH_FOUND, 0
} }
@ -2240,7 +2240,7 @@ pub fn (re mut RE) find_all(in_txt string) []int {
} else { } else {
i++ i++
} }
} }
return res return res
} }
@ -2254,7 +2254,7 @@ pub fn (re mut RE) replace(in_txt string, repl string) string {
mut s1 := 0 mut s1 := 0
mut e1 := in_txt.len mut e1 := in_txt.len
for i < pos.len { for i < pos.len {
e1 = pos[i] e1 = pos[i]
res += in_txt[s1..e1] + repl res += in_txt[s1..e1] + repl

View File

@ -10,7 +10,7 @@ struct Companies {
} }
enum POSITION { enum POSITION {
GO_BACK, GO_BACK
DONT_GO_BACK DONT_GO_BACK
} }
@ -67,8 +67,8 @@ fn (it Companies) method() int {
} }
a, b := hello(2, 'google', 'not google') a, b := hello(2, 'google', 'not google')
glue := if a > 2 { 'more_glue' } else if a > 5 {'more glueee'} else { 'less glue' } glue := if a > 2 { 'more_glue' } else if a > 5 {'more glueee'} else { 'less glue' }
if a != 2 {} if a != 2 {}