// File: /workspace/github_c_makefile_star2_O2/martincameron[P]towntalk/towntalk.c
// Function: validate_syntax
struct element* validate_syntax( char *syntax, struct element *elem,
	struct element *prev, struct environment *env, char *message ) {
	int idx = 1, chr = syntax[ 0 ];
	struct element *next;
	while( message[ 0 ] == 0 ) {
		switch( chr ) {
			case 0:
				return elem;
			case '0': /* List end. */
				if( elem ) {
					sprintf( message, "Unexpected '%.64s' after '%.64s' on line %d.", elem->str.string, prev->str.string, elem->line );
				}
				break;
			case '"': case ',': case ';': case '=': case '{':
				/* Strings, separators or blocks. */
				if( elem && elem->str.string[ 0 ] == chr ) {
					prev = elem;
					elem = elem->next;
				} else {
					sprintf( message, "Expected '%c' after '%.64s' on line %d.", chr, prev->str.string, prev->line );
				}
				break;
			case '(': /* Bracketed function parameter list. */
				if( elem && elem->str.string[ 0 ] == '(' ) {
					if( elem->child ) {
						validate_syntax( "P0", elem->child, elem, env, message );
					}
					prev = elem;
					elem = elem->next;
				} else {
					sprintf( message, "Expected '(' after '%.64s' on line %d.", prev->str.string, prev->line );
				}
				break;
			case '[': /* Index expression. */
				if( elem && elem->str.string[ 0 ] == '[' ) {
					if( elem->child ) {
						validate_syntax( "xx0", elem->child, elem, env, message );
						prev = elem;
						elem = elem->next;
					} else {
						sprintf( message, "Invalid index expression after '%.64s' on line %d.", prev->str.string, elem->line );
					}
				} else {
					sprintf( message, "Expected '[' after '%.64s' on line %d.", prev->str.string, prev->line );
				}
				break;
			case 'c': /* Catch or finally. */
				if( elem && ( is_keyword( elem->str.string, "catch" ) || is_keyword( elem->str.string, "finally" ) ) ) {
					chr = elem->str.string[ 0 ];
					prev = elem;
					elem = elem->next;
					if( strchr( "Cc", chr ) ) {
						if( elem && elem->str.string[ 0 ] == '(' ) {
							validate_syntax( "n0", elem->child, elem, env, message );
							prev = elem->child;
							elem = elem->next;
						}
						if( message[ 0 ] == 0 ) {
							next = validate_syntax( "n", elem, prev, env, message );
							prev = elem;
							elem = next;
						}
					}
					if( message[ 0 ] == 0 ) {
						next = validate_syntax( "{", elem, prev, env, message );
						prev = elem;
						elem = next;
						if( message[ 0 ] == 0 && elem
						&& ( is_keyword( elem->str.string, "catch" ) || is_keyword( elem->str.string, "finally" ) ) ) {
							prev = elem;
							elem = validate_syntax( "c", elem, prev, env, message );
						}
					}
				} else {
					sprintf( message, "Expected 'catch' or 'finally' after '%.64s' on line %d.", prev->str.string, prev->line );
				}
				break;
			case 'f': /* From. */
				if( elem && is_keyword( elem->str.string, "from" ) ) {
					prev = elem;
					elem = elem->next;
				} else {
					sprintf( message, "Expected 'from' after '%.64s' on line %d.", prev->str.string, prev->line );
				}
				break;
			case 'n': /* Name. */
				if( elem && elem->str.string[ 0 ] != ';' ) {
					validate_name( elem, message );
					prev = elem;
					elem = elem->next;
				} else {
					sprintf( message, "Expected name after '%.64s' on line %d.", prev->str.string, prev->line );
				}
				break;
			case 'P': /* Function parameter list. */
				while( message[ 0 ] == 0 && elem ) {
					if( elem && elem->str.string[ 0 ] == '(' ) {
						validate_syntax( "n0", elem->child, elem, env, message );
						prev = elem->child;
						elem = elem->next;
					}
					if( message[ 0 ] == 0 ) {
						next = validate_syntax( "n", elem, prev, env, message );
						prev = elem;
						elem = next;
						if( elem && elem->str.string[ 0 ] == ',' && elem->next ) {
							prev = elem;
							elem = elem->next;
						}
					}
				}
				break;
			case 'x': /* Expression. */
				if( elem && strchr( ",;({", elem->str.string[ 0 ] ) == NULL ) {
					if( elem->str.string[ 0 ] == '[' ) {
						validate_syntax( "[", elem, prev, env, message );
					} else if( elem->str.string[ 0 ] == '\\' && elem->str.string[ 1 ] == 0 ) {
						prev = elem;
						elem = elem->next;
						validate_syntax( "\"", elem, prev, env, message );
					} else if( elem->str.string[ 0 ] == '$' && elem->str.string[ 1 ] == 0 ) {
						prev = elem;
						elem = elem->next;
						validate_syntax( "{", elem, prev, env, message );
					} else if( elem->next && elem->next->str.string[ 0 ] == '(' ) {
						prev = elem;
						elem = elem->next;
					}
					if( elem ) {
						prev = elem;
						elem = elem->next;
						if( syntax[ idx ] == 'x' && elem && elem->str.string[ 0 ] == ',' ) {
							prev = elem;
							elem = elem->next;
						}
					}
				} else {
					sprintf( message, "Expected expression after '%.64s' on line %d.", prev->str.string, prev->line );
				}
				break;
			case 'X': /* Expression list, terminated by '{' or NULL. */
				next = NULL;
				while( message[ 0 ] == 0 && elem && elem->str.string[ 0 ] != '{' ) {
					if( next && elem->str.string[ 0 ] == ',' ) {
						prev = elem;
						elem = elem->next;
					}
					next = validate_syntax( "x", elem, prev, env, message );
					prev = elem;
					elem = next;
				}
				break;
			case 'v': /* Variable declaration. */
				if( elem && elem->str.string[ 0 ] == '(' ) {
					validate_syntax( "n0", elem->child, elem, env, message );
					prev = elem->child;
					elem = elem->next;
				}
				if( message[ 0 ] == 0 ) {
					if( elem && elem->str.string[ 0 ] == '[' ) {
						validate_syntax( "nx0", elem->child, elem, env, message );
						prev = elem->child;
						elem = elem->next;
					} else {
						next = validate_syntax( "n", elem, prev, env, message );
						prev = elem;
						elem = next;
						if( message[ 0 ] == 0 && elem && elem->str.string[ 0 ] == '=' ) {
							prev = elem;
							elem = validate_syntax( "x", elem->next, prev, env, message );
						}
					}
				}
				break;
			case 'V': /* Variable declaration list, terminated by ';' or NULL. */
				next = NULL;
				while( message[ 0 ] == 0 && elem && elem->str.string[ 0 ] != ';' ) {
					if( next && elem->str.string[ 0 ] == ',' ) {
						prev = elem;
						elem = elem->next;
					}
					next = validate_syntax( "v", elem, prev, env, message );
					prev = elem;
					elem = next;
				}
				break;
			case 'A': /* Variable assignment list, terminated by ';' or NULL. */
				next = NULL;
				while( message[ 0 ] == 0 && elem && elem->str.string[ 0 ] != ';' ) {
					if( next && elem->str.string[ 0 ] == ',' ) {
						prev = elem;
						elem = elem->next;
					}
					next = validate_syntax( "x=x", elem, prev, env, message );
					prev = elem;
					elem = next;
				}
				break;
			default: /* Internal error. */
				sprintf( message, "Internal error. Unknown specifier '%c' while parsing line %d.", chr, ( elem ? elem : prev )->line );
		}
		chr = syntax[ idx++ ];
	}
	return elem;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %rbp
pushq $0x1
popq %r15
movq %rdi, 0x10(%rsp)
movq %rdi, %rax
cmpb $0x0, (%rbx)
jne 0x6915
movsbl (%rax), %edx
cmpb $0x22, %dl
je 0x62ce
movzbl %dl, %eax
cmpl $0x28, %eax
je 0x66a5
cmpl $0x2c, %eax
je 0x62ce
cmpl $0x30, %eax
je 0x667a
cmpl $0x3b, %eax
je 0x62ce
cmpl $0x3d, %eax
je 0x62ce
cmpl $0x41, %eax
je 0x6623
cmpl $0x50, %eax
je 0x6305
cmpl $0x56, %eax
je 0x6393
cmpl $0x58, %eax
je 0x65cc
cmpl $0x5b, %eax
je 0x64c8
cmpl $0x63, %eax
je 0x652b
cmpl $0x66, %eax
je 0x64f7
cmpl $0x6e, %eax
je 0x63ea
cmpl $0x76, %eax
je 0x6454
cmpl $0x78, %eax
je 0x6413
cmpl $0x7b, %eax
je 0x62ce
testl %eax, %eax
je 0x6915
testq %rbp, %rbp
movq %rbp, %rax
cmoveq %r13, %rax
movl 0x28(%rax), %ecx
movq %rbx, %rdi
leaq 0xb232(%rip), %rsi      # 0x114f4
xorl %eax, %eax
callq 0x3200
jmp 0x6888
testq %rbp, %rbp
je 0x62e7
movq 0x8(%rbp), %rax
cmpb %dl, (%rax)
jne 0x62e7
movq %rbp, %r13
movq 0x20(%rbp), %rbp
jmp 0x6888
movq 0x8(%r13), %rcx
movl 0x28(%r13), %r8d
movq %rbx, %rdi
leaq 0xb06c(%rip), %rsi      # 0x11365
xorl %eax, %eax
callq 0x3200
jmp 0x6888
xorl %ecx, %ecx
testb %cl, %cl
jne 0x6888
testq %rbp, %rbp
je 0x6888
movq 0x8(%rbp), %rax
cmpb $0x28, (%rax)
jne 0x634a
movq 0x18(%rbp), %rsi
leaq 0xb0f7(%rip), %rdi      # 0x11423
movq %rbp, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
movq 0x18(%rbp), %r13
movq 0x20(%rbp), %rbp
cmpb $0x0, (%rbx)
movq %rbp, %rax
jne 0x6389
leaq 0xbbf7(%rip), %rdi      # 0x11f48
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
testq %rax, %rax
je 0x6384
movq 0x8(%rax), %rcx
cmpb $0x2c, (%rcx)
jne 0x637f
movq 0x20(%rax), %rcx
testq %rcx, %rcx
cmovneq %rax, %rbp
cmovneq %rcx, %rax
movq %rbp, %r13
jmp 0x6389
movq %rbp, %r13
xorl %eax, %eax
movb (%rbx), %cl
movq %rax, %rbp
jmp 0x6307
xorl %ecx, %ecx
xorl %eax, %eax
testb %cl, %cl
jne 0x6888
testq %rbp, %rbp
je 0x6888
movq 0x8(%rbp), %rcx
movb (%rcx), %cl
cmpb $0x3b, %cl
je 0x6888
testq %rax, %rax
je 0x63c8
cmpb $0x2c, %cl
jne 0x63c8
movq %rbp, %r13
movq 0x20(%rbp), %rbp
leaq 0xbbb8(%rip), %rdi      # 0x11f87
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
movb (%rbx), %cl
movq %rbp, %r13
movq %rax, %rbp
jmp 0x6397
testq %rbp, %rbp
je 0x63fc
movq 0x8(%rbp), %rax
cmpb $0x3b, (%rax)
jne 0x677d
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
movq %rbx, %rdi
leaq 0xb07f(%rip), %rsi      # 0x1148d
jmp 0x6881
testq %rbp, %rbp
je 0x643d
movq 0x8(%rbp), %r12
movsbl (%r12), %esi
leaq 0xb08d(%rip), %rdi      # 0x114b5
movl %esi, 0xc(%rsp)
pushq $0x5
popq %rdx
callq 0x3110
testq %rax, %rax
je 0x678d
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
movq %rbx, %rdi
leaq 0xb06f(%rip), %rsi      # 0x114be
jmp 0x6881
testq %rbp, %rbp
je 0x671f
movq 0x8(%rbp), %rax
cmpb $0x28, (%rax)
jne 0x6499
movq 0x18(%rbp), %rsi
leaq 0xafb2(%rip), %rdi      # 0x11423
movq %rbp, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
movq 0x18(%rbp), %r13
movq 0x20(%rbp), %rbp
cmpb $0x0, (%rbx)
jne 0x6888
testq %rbp, %rbp
je 0x671f
movq 0x8(%rbp), %rax
cmpb $0x5b, (%rax)
jne 0x6721
movq 0x18(%rbp), %rsi
leaq 0xb03b(%rip), %rdi      # 0x114ec
movq %rbp, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
movq 0x18(%rbp), %r13
jmp 0x62de
testq %rbp, %rbp
je 0x66da
movq 0x8(%rbp), %rax
cmpb $0x5b, (%rax)
jne 0x66da
movq 0x18(%rbp), %rsi
testq %rsi, %rsi
je 0x6870
leaq 0xaec5(%rip), %rdi      # 0x113b7
jmp 0x66c7
testq %rbp, %rbp
je 0x6514
movq 0x8(%rbp), %rdi
leaq 0xaf57(%rip), %rsi      # 0x1145e
callq 0x6197
testl %eax, %eax
jne 0x62db
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
movq %rbx, %rdi
leaq 0xaf3d(%rip), %rsi      # 0x11463
jmp 0x6881
testq %rbp, %rbp
je 0x6708
movq 0x8(%rbp), %r12
movq %r12, %rdi
leaq 0xaed3(%rip), %rsi      # 0x11415
callq 0x6197
testl %eax, %eax
jne 0x6562
movq %r12, %rdi
leaq 0xaec6(%rip), %rsi      # 0x1141b
callq 0x6197
testl %eax, %eax
je 0x6708
movzbl (%r12), %eax
movq 0x20(%rbp), %r12
testl %eax, %eax
je 0x657d
cmpl $0x63, %eax
je 0x657d
cmpl $0x43, %eax
jne 0x67f9
testq %r12, %r12
je 0x67ca
movq 0x8(%r12), %rax
cmpb $0x28, (%rax)
jne 0x67cd
movq 0x18(%r12), %rsi
leaq 0xae83(%rip), %rdi      # 0x11423
movq %r12, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
movq 0x18(%r12), %rdx
movq 0x20(%r12), %r12
cmpb $0x0, (%rbx)
movq %rdx, %r13
movq %r12, %rbp
jne 0x6888
jmp 0x67d0
xorl %ecx, %ecx
xorl %eax, %eax
testb %cl, %cl
jne 0x6888
testq %rbp, %rbp
je 0x6888
movq 0x8(%rbp), %rcx
movb (%rcx), %cl
cmpb $0x7b, %cl
je 0x6888
testq %rax, %rax
je 0x6601
cmpb $0x2c, %cl
jne 0x6601
movq %rbp, %r13
movq 0x20(%rbp), %rbp
leaq 0xaeea(%rip), %rdi      # 0x114f2
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
movb (%rbx), %cl
movq %rbp, %r13
movq %rax, %rbp
jmp 0x65d0
xorl %ecx, %ecx
xorl %eax, %eax
testb %cl, %cl
jne 0x6888
testq %rbp, %rbp
je 0x6888
movq 0x8(%rbp), %rcx
movb (%rcx), %cl
cmpb $0x3b, %cl
je 0x6888
testq %rax, %rax
je 0x6658
cmpb $0x2c, %cl
jne 0x6658
movq %rbp, %r13
movq 0x20(%rbp), %rbp
leaq 0xae91(%rip), %rdi      # 0x114f0
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
movb (%rbx), %cl
movq %rbp, %r13
movq %rax, %rbp
jmp 0x6627
testq %rbp, %rbp
je 0x690e
movq 0x8(%rbp), %rdx
movq 0x8(%r13), %rcx
movl 0x28(%rbp), %r8d
movq %rbx, %rdi
leaq 0xac9f(%rip), %rsi      # 0x11338
xorl %eax, %eax
callq 0x3200
jmp 0x6888
testq %rbp, %rbp
je 0x66f1
movq 0x8(%rbp), %rax
cmpb $0x28, (%rax)
jne 0x66f1
movq 0x18(%rbp), %rsi
testq %rsi, %rsi
je 0x62db
leaq 0xacc6(%rip), %rdi      # 0x1138d
movq %rbp, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
jmp 0x62db
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
movq %rbx, %rdi
leaq 0xad02(%rip), %rsi      # 0x113ee
jmp 0x6881
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
movq %rbx, %rdi
leaq 0xac8d(%rip), %rsi      # 0x11390
jmp 0x6881
movq 0x8(%r13), %rdx
movl 0x28(%r13), %ecx
movq %rbx, %rdi
leaq 0xad0c(%rip), %rsi      # 0x11426
jmp 0x6881
xorl %ebp, %ebp
leaq 0xb820(%rip), %rdi      # 0x11f48
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
movq %rax, %r12
cmpb $0x0, (%rbx)
jne 0x6772
testq %r12, %r12
je 0x6772
movq 0x8(%r12), %rax
cmpb $0x3d, (%rax)
jne 0x6772
movq 0x20(%r12), %rsi
leaq 0xad96(%rip), %rdi      # 0x114f2
movq %r12, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
movq %rax, %rbp
jmp 0x686b
movq %rbp, %r13
movq %r12, %rbp
jmp 0x6888
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x6927
jmp 0x62db
movzbl 0xc(%rsp), %eax
cmpl $0x24, %eax
je 0x68e2
cmpl $0x5c, %eax
je 0x6898
cmpl $0x5b, %eax
jne 0x68a7
leaq 0xad06(%rip), %rdi      # 0x114ba
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
jmp 0x68bb
xorl %r12d, %r12d
movq %rbp, %rdx
movq %r12, %r13
leaq 0xb76e(%rip), %rdi      # 0x11f48
movq %r12, %rsi
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
movq %rax, %r12
cmpb $0x0, (%rbx)
movq %rax, %rbp
jne 0x6888
jmp 0x67fc
movq %rbp, %r13
leaq 0xacb5(%rip), %rdi      # 0x114b8
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
movq %rax, %rbp
cmpb $0x0, (%rbx)
jne 0x686b
testq %rbp, %rbp
je 0x686b
movq 0x8(%rbp), %r13
movq %r13, %rdi
leaq 0xabe6(%rip), %rsi      # 0x11415
callq 0x6197
testl %eax, %eax
jne 0x684b
movq %r13, %rdi
leaq 0xabd9(%rip), %rsi      # 0x1141b
callq 0x6197
testl %eax, %eax
je 0x686b
leaq 0xb4cc(%rip), %rdi      # 0x11d1e
movq %rbp, %rsi
movq %rbp, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
movq %rbp, %r13
movq %rax, %rbp
jmp 0x6888
movq %r12, %r13
jmp 0x6888
movq 0x8(%r13), %rdx
movl 0x28(%rbp), %ecx
movq %rbx, %rdi
leaq 0xab3a(%rip), %rsi      # 0x113bb
xorl %eax, %eax
callq 0x3200
movq 0x10(%rsp), %rax
addq %r15, %rax
incq %r15
jmp 0x61ff
cmpb $0x0, 0x1(%r12)
leaq 0xac17(%rip), %rdi      # 0x114bc
je 0x68f1
movq 0x20(%rbp), %rax
testq %rax, %rax
je 0x68bb
movq 0x8(%rax), %rcx
cmpb $0x28, (%rcx)
cmoveq %rax, %rbp
movq %rbp, %r13
movq 0x20(%r13), %rbp
movq 0x10(%rsp), %rax
cmpb $0x78, (%rax,%r15)
jne 0x6888
testq %rbp, %rbp
je 0x6888
movq 0x8(%rbp), %rax
cmpb $0x2c, (%rax)
je 0x62db
jmp 0x6888
cmpb $0x0, 0x1(%r12)
leaq 0xabc9(%rip), %rdi      # 0x114b8
jne 0x68a7
movq 0x20(%rbp), %r13
movq %r13, %rsi
movq %rbp, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x61d9
testq %r13, %r13
jne 0x68be
movq %rbp, %r13
xorl %ebp, %ebp
jmp 0x6888
movq %rbp, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq