Example #1
0
int main(int argc, char *argv[])
{
	int c = 0;
	argv[1]="example.txt";
	init_token(argv[1]);
	program();
	printf("Congratulation : No error is found\n");
	return 0;
}
Example #2
0
int main(int argc, char *argv[])
{
	argv[1]="praktek2.txt";
	init_token(argv[1]);
	while(get_token()!=EOF){
		printf("%3d %3d %s \n",token.attr, token.value, token.charvalue);
		clear_token();
	}
	return 0;
}
Example #3
0
/************************
 * FUNCTION DEFINITIONS *
 ************************/
struct Token *make_token(char *token_string, char mod) {
  struct Token *token;
  struct SLList *args;

  if (!(token = (struct Token *)malloc(sizeof(struct Token)))) {
    fprintf(stderr, "error: %s\n", strerror(errno));
  }
  if (!(args = (struct SLList *)malloc(sizeof(struct SLList)))) {
    fprintf(stderr, "error: %s\n", strerror(errno));
  }

  init_token(token);
  init_list(args);
  
  //extract the necessary data from the command token string.
  char *working_token_string = strdup(token_string);
  if (!working_token_string) {
    fprintf(stderr,
	    "error: could not allocate memory for token string, %s\n",
	    strerror(errno));
  }
  char *token_part = strtok(working_token_string, " ");
  char *token_part_dyn = malloc(strlen(token_part)+1);
  strcpy(token_part_dyn, token_part);
  token->name = token_part_dyn;
  do {
    add_back(args, token_part_dyn);
    token_part = strtok(NULL, " ");
    if (token_part) {
      token_part_dyn = malloc(strlen(token_part)+1);
      strcpy(token_part_dyn, token_part);
    }
  } while (token_part);

  free(working_token_string);
  token->args = args;

  //assign correct modifier indicator based on mod character.
  if (mod == '|') {
    token->mod = PIPE;
  } else if (mod == '>') {
    token->mod = OUTPUT_REDIR;
  } else if (mod == 'e') {
    token->mod = ERR_OUTPUT_REDIR;
  } else if (mod == '<') {
    token->mod = INPUT_REDIR;
  } else {
    token->mod = NO_MODIFIER;
  }

  return token;
}
Example #4
0
void				add_newline(t_token *cur_tok, t_list **l, char *input, \
int *index)
{
	char		cur;

	cur = input[*index];
	if (is_newline(cur))
	{
		if (cur_tok->token)
			append_and_reset(l, cur_tok);
		discard_whitespace(input, index);
		list_append(*l, init_token(NEWLINE, "\n"));
	}
}
Example #5
0
void handle_managent_package(IoT_Package *package_info)
{
	//printAllChar(package_info->data, package_info->data_length);
	const int temp_str_len = 50;
	int deviceIndex = -1;
	char str_temp[temp_str_len] = { '\0' };
	JsonData jsonData;
	charcat(jsonData.content, package_info->data, 0, package_info->data_length);
	init_token(&jsonData);
	range_t range;
	range.start = jsonData.tokens[1].start;
	range.end = jsonData.tokens[1].end;
	getPatteren(range, jsonData.content, str_temp);

	//Register
	if (strcmp("IOTDEV", str_temp) == 0)
	{
		puts("A Register package include device info");
		add_new_device(package_info->sor_ip, jsonData, package_info->belongSocketIdx);
	}
	//Command
	else if (strcmp("IOTCMD", str_temp) == 0)
	{
		puts("A Command package");
		IoT_Command cmd = generate_iot_command();
		decode_iot_cmd(package_info->data, &cmd);
		if (cmd.cmd_type != command_t_Management)
		{
			puts("IOTCMD has wrong command type");
			return;
		}

		//if (strcmp(cmd.ID,"Dis_All") == 0 && cmd.cmd_type==command_t_Management)
		if (memcmp(cmd.ID, "Dis_",4) == 0)
		{
			discover_package_replier(package_info,&cmd);
		}
		else if (strcmp(cmd.ID, "Del_Dev") == 0)
		{
			deviceIndex = find_device_index_with_ipstr(cmd.Value);
			if (deviceIndex >= 0)
			{
				printf("Device[%d]: has bean deleted\n", deviceIndex);
				free_device_info(registed_devices[deviceIndex]);
				registed_devices[deviceIndex] = NULL;
			}
		}
		else if (strcmp(cmd.ID, "Prx_Add") == 0)
		{
			deviceIndex = find_device_index_with_ipstr(cmd.Value);
			if (deviceIndex >= 0)
			{
				printf("Device[%d]: has bean proxied\n", deviceIndex);
				registed_devices[deviceIndex]->proxied = 1;
			}
		}
		else if (strcmp(cmd.ID, "Prx_Rmv") == 0)
		{
			deviceIndex = find_device_index_with_ipstr(cmd.Value);
			if (deviceIndex >= 0)
			{
				printf("Device[%d]: proxy released\n", deviceIndex);
				registed_devices[deviceIndex]->proxied = 0;
			}
		}
		else if (strcmp(cmd.ID, "Re_Conf") == 0)
		{
			printf("Reload config");
		}
		else
		{
			printf("unknow manage command:%s", cmd.ID);
		}
	}
}
Example #6
0
int main(int argc, char **argv)
{
	struct openconnect_info *vpninfo;
	char *urlpath = NULL;
	char *proxy = getenv("https_proxy");
	char *vpnc_script = NULL, *ifname = NULL;
	const struct oc_ip_info *ip_info;
	int autoproxy = 0;
	int opt;
	char *pidfile = NULL;
	int use_dtls = 1;
	FILE *fp = NULL;
	char *config_arg;
	char *token_str = NULL;
	oc_token_mode_t token_mode = OC_TOKEN_MODE_NONE;
	int reconnect_timeout = 300;
	int ret;
#ifndef _WIN32
	struct sigaction sa;
	struct utsname utsbuf;
	uid_t uid = getuid();
	int use_syslog = 0;
	int script_tun = 0;
#endif

#ifdef ENABLE_NLS
	bindtextdomain("openconnect", LOCALEDIR);
	setlocale(LC_ALL, "");
#endif

	if (strcmp(openconnect_version_str, openconnect_binary_version)) {
		fprintf(stderr, _("WARNING: This version of openconnect is %s but\n"
				  "         the libopenconnect library is %s\n"),
			openconnect_binary_version, openconnect_version_str);
	}

	openconnect_init_ssl();

	vpninfo = openconnect_vpninfo_new((char *)"Open AnyConnect VPN Agent",
		validate_peer_cert, NULL, process_auth_form_cb, write_progress, NULL);
	if (!vpninfo) {
		fprintf(stderr, _("Failed to allocate vpninfo structure\n"));
		exit(1);
	}

	vpninfo->cbdata = vpninfo;
#ifdef _WIN32
	set_default_vpncscript();
#else
	if (!uname(&utsbuf)) {
		free(vpninfo->localname);
		vpninfo->localname = xstrdup(utsbuf.nodename);
	}
#endif

	while ((opt = next_option(argc, argv, &config_arg))) {

		if (opt < 0)
			break;

		switch (opt) {
		case OPT_CONFIGFILE:
			if (config_file) {
				fprintf(stderr, _("Cannot use 'config' option inside config file\n"));
				exit(1);
			}
			config_file = fopen(config_arg, "r");
			if (!config_file) {
				fprintf(stderr, _("Cannot open config file '%s': %s\n"),
					config_arg, strerror(errno));
				exit(1);
			}
			config_line_num = 1;
			/* The next option will come from the file... */
			break;
		case OPT_CAFILE:
			openconnect_set_cafile(vpninfo, xstrdup(config_arg));
			break;
		case OPT_PIDFILE:
			pidfile = keep_config_arg();
			break;
		case OPT_PFS:
			openconnect_set_pfs(vpninfo, 1);
			break;
		case OPT_SERVERCERT:
			openconnect_set_server_cert_sha1(vpninfo, xstrdup(config_arg));
			break;
		case OPT_NO_DTLS:
			use_dtls = 0;
			break;
		case OPT_COOKIEONLY:
			cookieonly = 1;
			break;
		case OPT_PRINTCOOKIE:
			cookieonly = 2;
			break;
		case OPT_AUTHENTICATE:
			cookieonly = 3;
			break;
		case OPT_COOKIE_ON_STDIN:
			read_stdin(&vpninfo->cookie, 0);
			/* If the cookie is empty, ignore it */
			if (!*vpninfo->cookie)
				vpninfo->cookie = NULL;
			break;
		case OPT_PASSWORD_ON_STDIN:
			read_stdin(&password, 0);
			break;
		case OPT_NO_PASSWD:
			vpninfo->nopasswd = 1;
			break;
		case OPT_NO_XMLPOST:
			openconnect_set_xmlpost(vpninfo, 0);
			break;
		case OPT_NON_INTER:
			non_inter = 1;
			break;
		case OPT_RECONNECT_TIMEOUT:
			reconnect_timeout = atoi(config_arg);
			break;
		case OPT_DTLS_CIPHERS:
			vpninfo->dtls_ciphers = keep_config_arg();
			break;
		case OPT_AUTHGROUP:
			authgroup = keep_config_arg();
			break;
#ifndef _WIN32
		case 'b':
			background = 1;
			break;
#endif
		case 'C':
			vpninfo->cookie = strdup(config_arg);
			break;
		case 'c':
			vpninfo->cert = strdup(config_arg);
			break;
		case 'e':
			vpninfo->cert_expire_warning = 86400 * atoi(config_arg);
			break;
		case 'k':
			vpninfo->sslkey = strdup(config_arg);
			break;
		case 'd':
			vpninfo->deflate = 1;
			break;
		case 'D':
			vpninfo->deflate = 0;
			break;
		case 'g':
			free(urlpath);
			urlpath = strdup(config_arg);
			break;
		case 'h':
			usage();
		case 'i':
			ifname = xstrdup(config_arg);
			break;
#ifndef _WIN32
		case 'l':
			use_syslog = 1;
			break;
#endif
		case 'm': {
			int mtu = atol(config_arg);
			if (mtu < 576) {
				fprintf(stderr, _("MTU %d too small\n"), mtu);
				mtu = 576;
			}
			openconnect_set_reqmtu(vpninfo, mtu);
			break;
		}
		case OPT_BASEMTU:
			vpninfo->basemtu = atol(config_arg);
			if (vpninfo->basemtu < 576) {
				fprintf(stderr, _("MTU %d too small\n"), vpninfo->basemtu);
				vpninfo->basemtu = 576;
			}
			break;
		case 'p':
			vpninfo->cert_password = strdup(config_arg);
			break;
		case 'P':
			proxy = keep_config_arg();
			autoproxy = 0;
			break;
		case OPT_PROXY_AUTH:
			openconnect_set_proxy_auth(vpninfo, xstrdup(config_arg));
			break;
		case OPT_NO_PROXY:
			autoproxy = 0;
			proxy = NULL;
			break;
		case OPT_LIBPROXY:
			autoproxy = 1;
			proxy = NULL;
			break;
		case OPT_NO_HTTP_KEEPALIVE:
			fprintf(stderr,
				_("Disabling all HTTP connection re-use due to --no-http-keepalive option.\n"
				  "If this helps, please report to <*****@*****.**>.\n"));
			vpninfo->no_http_keepalive = 1;
			break;
		case OPT_NO_CERT_CHECK:
			nocertcheck = 1;
			break;
		case 's':
			vpnc_script = xstrdup(config_arg);
			break;
#ifndef _WIN32
		case 'S':
			script_tun = 1;
			break;
#endif
		case 'u':
			free(username);
			username = strdup(config_arg);
			break;
#ifndef _WIN32
		case 'U': {
			char *strend;
			uid = strtol(config_arg, &strend, 0);
			if (strend[0]) {
				struct passwd *pw = getpwnam(config_arg);
				if (!pw) {
					fprintf(stderr, _("Invalid user \"%s\"\n"),
						config_arg);
					exit(1);
				}
				uid = pw->pw_uid;
			}
			break;
		}
		case OPT_CSD_USER: {
			char *strend;
			vpninfo->uid_csd = strtol(config_arg, &strend, 0);
			if (strend[0]) {
				struct passwd *pw = getpwnam(config_arg);
				if (!pw) {
					fprintf(stderr, _("Invalid user \"%s\"\n"),
						config_arg);
					exit(1);
				}
				vpninfo->uid_csd = pw->pw_uid;
			}
			vpninfo->uid_csd_given = 1;
			break;
		}
		case OPT_CSD_WRAPPER:
			vpninfo->csd_wrapper = keep_config_arg();
			break;
#endif
		case OPT_DISABLE_IPV6:
			vpninfo->disable_ipv6 = 1;
			break;
		case 'Q':
			vpninfo->max_qlen = atol(config_arg);
			if (!vpninfo->max_qlen) {
				fprintf(stderr, _("Queue length zero not permitted; using 1\n"));
				vpninfo->max_qlen = 1;
			}
			break;
		case 'q':
			verbose = PRG_ERR;
			break;
		case OPT_DUMP_HTTP:
			vpninfo->dump_http_traffic = 1;
			break;
		case 'v':
			verbose++;
			break;
		case 'V':
			printf(_("OpenConnect version %s\n"), openconnect_version_str);
			print_build_opts();
			exit(0);
		case 'x':
			vpninfo->xmlconfig = keep_config_arg();
			vpninfo->write_new_config = write_new_config;
			break;
		case OPT_KEY_PASSWORD_FROM_FSID:
			do_passphrase_from_fsid = 1;
			break;
		case OPT_USERAGENT:
			free(vpninfo->useragent);
			vpninfo->useragent = strdup(config_arg);
			break;
		case OPT_FORCE_DPD:
			openconnect_set_dpd(vpninfo, atoi(config_arg));
			break;
		case OPT_DTLS_LOCAL_PORT:
			vpninfo->dtls_local_port = atoi(config_arg);
			break;
		case OPT_TOKEN_MODE:
			if (strcasecmp(config_arg, "rsa") == 0) {
				token_mode = OC_TOKEN_MODE_STOKEN;
			} else if (strcasecmp(config_arg, "totp") == 0) {
				token_mode = OC_TOKEN_MODE_TOTP;
			} else if (strcasecmp(config_arg, "hotp") == 0) {
				token_mode = OC_TOKEN_MODE_HOTP;
			} else {
				fprintf(stderr, _("Invalid software token mode \"%s\"\n"),
					config_arg);
				exit(1);
			}
			break;
		case OPT_TOKEN_SECRET:
			token_str = keep_config_arg();
			break;
		case OPT_OS:
			if (openconnect_set_reported_os(vpninfo, config_arg)) {
				fprintf(stderr, _("Invalid OS identity \"%s\"\n"),
					config_arg);
				exit(1);
			}
			if (!strcmp(config_arg, "android") || !strcmp(config_arg, "apple-ios")) {
				/* generic defaults */
				openconnect_set_mobile_info(vpninfo,
					xstrdup("1.0"),
					xstrdup(config_arg),
					xstrdup("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
			}
			break;
		case OPT_TIMESTAMP:
			timestamp = 1;
			break;
		default:
			usage();
		}
	}

	if (optind < argc - 1) {
		fprintf(stderr, _("Too many arguments on command line\n"));
		usage();
	} else if (optind > argc - 1) {
		fprintf(stderr, _("No server specified\n"));
		usage();
	}

	if (!vpninfo->sslkey)
		vpninfo->sslkey = vpninfo->cert;

	if (vpninfo->dump_http_traffic && verbose < PRG_DEBUG)
		verbose = PRG_DEBUG;

	vpninfo->progress = write_progress;

	if (autoproxy) {
#ifdef LIBPROXY_HDR
		vpninfo->proxy_factory = px_proxy_factory_new();
#else
		fprintf(stderr, _("This version of openconnect was built without libproxy support\n"));
		exit(1);
#endif
	}

	if (token_mode != OC_TOKEN_MODE_NONE)
		init_token(vpninfo, token_mode, token_str);

	if (proxy && openconnect_set_http_proxy(vpninfo, strdup(proxy)))
		exit(1);

#ifndef _WIN32
	if (use_syslog) {
#ifndef __ANDROID__
		openlog("openconnect", LOG_PID, LOG_DAEMON);
#endif
		vpninfo->progress = syslog_progress;
	}
#endif /* !_WIN32 */

	sig_cmd_fd = openconnect_setup_cmd_pipe(vpninfo);
	if (sig_cmd_fd < 0) {
		fprintf(stderr, _("Error opening cmd pipe\n"));
		exit(1);
	}

#ifndef _WIN32
	memset(&sa, 0, sizeof(sa));

	sa.sa_handler = handle_signal;
	sigaction(SIGINT, &sa, NULL);
	sigaction(SIGHUP, &sa, NULL);
	sigaction(SIGUSR2, &sa, NULL);
#endif /* !_WIN32 */

	if (vpninfo->sslkey && do_passphrase_from_fsid)
		openconnect_passphrase_from_fsid(vpninfo);

	if (config_lookup_host(vpninfo, argv[optind]))
		exit(1);

	if (!vpninfo->hostname) {
		char *url = strdup(argv[optind]);

		if (openconnect_parse_url(vpninfo, url))
			exit(1);

		free(url);
	}

	/* Historically, the path in the URL superseded the one in the
	 * --usergroup argument, just because of the order in which they
	 * were processed. Preserve that behaviour. */
	if (urlpath && !vpninfo->urlpath) {
		vpninfo->urlpath = urlpath;
		urlpath = NULL;
	}
	free(urlpath);

#ifdef SSL_UI
	set_openssl_ui();
#endif

	if (!vpninfo->cookie && openconnect_obtain_cookie(vpninfo)) {
		if (vpninfo->csd_scriptname) {
			unlink(vpninfo->csd_scriptname);
			vpninfo->csd_scriptname = NULL;
		}
		fprintf(stderr, _("Failed to obtain WebVPN cookie\n"));
		exit(1);
	}

	if (cookieonly == 3) {
		/* --authenticate */
		printf("COOKIE='%s'\n", vpninfo->cookie);
		printf("HOST='%s'\n", openconnect_get_hostname(vpninfo));
		if (vpninfo->peer_cert) {
			char buf[41] = {0, };
			openconnect_get_cert_sha1(vpninfo, vpninfo->peer_cert, buf);
			printf("FINGERPRINT='%s'\n", buf);
		}
		openconnect_vpninfo_free(vpninfo);
		exit(0);
	} else if (cookieonly) {
		printf("%s\n", vpninfo->cookie);
		if (cookieonly == 1) {
			/* We use cookieonly=2 for 'print it and continue' */
			openconnect_vpninfo_free(vpninfo);
			exit(0);
		}
	}
	if (openconnect_make_cstp_connection(vpninfo)) {
		fprintf(stderr, _("Creating SSL connection failed\n"));
		openconnect_vpninfo_free(vpninfo);
		exit(1);
	}

	if (!vpnc_script)
		vpnc_script = xstrdup(default_vpncscript);
#ifndef _WIN32
	if (script_tun) {
		if (openconnect_setup_tun_script(vpninfo, vpnc_script)) {
			fprintf(stderr, _("Set up tun script failed\n"));
			openconnect_vpninfo_free(vpninfo);
			exit(1);
		}
	} else
#endif
	if (openconnect_setup_tun_device(vpninfo, vpnc_script, ifname)) {
		fprintf(stderr, _("Set up tun device failed\n"));
		openconnect_vpninfo_free(vpninfo);
		exit(1);
	}

#ifndef _WIN32
	if (uid != getuid()) {
		if (setuid(uid)) {
			fprintf(stderr, _("Failed to set uid %ld\n"),
				(long)uid);
			openconnect_vpninfo_free(vpninfo);
			exit(1);
		}
	}
#endif

	if (use_dtls && openconnect_setup_dtls(vpninfo, 60))
		fprintf(stderr, _("Set up DTLS failed; using SSL instead\n"));

	openconnect_get_ip_info(vpninfo, &ip_info, NULL, NULL);
	vpn_progress(vpninfo, PRG_INFO,
		     _("Connected %s as %s%s%s, using %s\n"), openconnect_get_ifname(vpninfo),
		     ip_info->addr?:"",
		     (ip_info->netmask6 && ip_info->addr) ? " + " : "",
		     ip_info->netmask6 ? : "",
		     (vpninfo->dtls_state != DTLS_CONNECTED) ?
		     (vpninfo->deflate ? "SSL + deflate" : "SSL")
		     : "DTLS");

	if (!vpninfo->vpnc_script) {
		vpn_progress(vpninfo, PRG_INFO,
			     _("No --script argument provided; DNS and routing are not configured\n"));
		vpn_progress(vpninfo, PRG_INFO,
			     _("See http://www.infradead.org/openconnect/vpnc-script.html\n"));
	}

#ifndef _WIN32
	if (background) {
		int pid;

		/* Open the pidfile before forking, so we can report errors
		   more sanely. It's *possible* that we'll fail to write to
		   it, but very unlikely. */
		if (pidfile != NULL) {
			fp = fopen(pidfile, "w");
			if (!fp) {
				fprintf(stderr, _("Failed to open '%s' for write: %s\n"),
					pidfile, strerror(errno));
				openconnect_vpninfo_free(vpninfo);
				exit(1);
			}
		}
		if ((pid = fork())) {
			if (fp) {
				fprintf(fp, "%d\n", pid);
				fclose(fp);
			}
			vpn_progress(vpninfo, PRG_INFO,
				     _("Continuing in background; pid %d\n"),
				     pid);
			openconnect_vpninfo_free(vpninfo);
			exit(0);
		}
		if (fp)
			fclose(fp);
	}
#endif

	while (1) {
		ret = openconnect_mainloop(vpninfo, reconnect_timeout, RECONNECT_INTERVAL_MIN);
		if (ret)
			break;

		vpn_progress(vpninfo, PRG_INFO, _("User requested reconnect\n"));
	}

	if (fp)
		unlink(pidfile);

	switch (ret) {
	case -EPERM:
		vpn_progress(vpninfo, PRG_ERR, _("Cookie was rejected on reconnection; exiting.\n"));
		ret = 2;
		break;
	case -EPIPE:
		vpn_progress(vpninfo, PRG_ERR, _("Session terminated by server; exiting.\n"));
		ret = 1;
		break;
	case -EINTR:
		vpn_progress(vpninfo, PRG_INFO, _("User canceled (SIGINT); exiting.\n"));
		ret = 0;
		break;
	case -ECONNABORTED:
		vpn_progress(vpninfo, PRG_INFO, _("User detached from session (SIGHUP); exiting.\n"));
		ret = 0;
		break;
	default:
		vpn_progress(vpninfo, PRG_ERR, _("Unknown error; exiting.\n"));
		ret = 1;
		break;
	}

	openconnect_vpninfo_free(vpninfo);
	exit(ret);
}
Example #7
0
// Initialize the token set used by the language.
void
init_tokens(Symbol_table& syms)
{
  init_token(syms, lbrace_tok, "{");
  init_token(syms, rbrace_tok, "}");
  init_token(syms, lparen_tok, "(");
  init_token(syms, rparen_tok, ")");
  init_token(syms, lbracket_tok, "[");
  init_token(syms, rbracket_tok, "]");
  init_token(syms, comma_tok, ",");
  init_token(syms, colon_tok, ":");
  init_token(syms, colon_colon_tok, "::");
  init_token(syms, semicolon_tok, ";");
  init_token(syms, dot_tok, ".");
  init_token(syms, ellipsis_tok, "...");

  // Operators
  init_token(syms, plus_tok, "+");
  init_token(syms, minus_tok, "-");
  init_token(syms, star_tok, "*");
  init_token(syms, slash_tok, "/");
  init_token(syms, percent_tok, "%");
  init_token(syms, amp_tok, "&");
  init_token(syms, bar_tok, "|");
  init_token(syms, caret_tok, "^");
  init_token(syms, tilde_tok, "~");
  init_token(syms, eq_tok, "=");
  init_token(syms, eq_eq_tok, "==");
  init_token(syms, bang_eq_tok, "!=");
  init_token(syms, lt_tok, "<");
  init_token(syms, gt_tok, ">");
  init_token(syms, lt_eq_tok, "<=");
  init_token(syms, gt_eq_tok, ">=");
  init_token(syms, lt_lt_tok, "<<");
  init_token(syms, gt_gt_tok, ">>");
  init_token(syms, amp_amp_tok, "&&");
  init_token(syms, bar_bar_tok, "||");
  init_token(syms, bang_tok, "!");
  init_token(syms, arrow_tok, "->");
  init_token(syms, question_tok, "?");

  // Keywords
  init_token(syms, abstract_tok, "abstract");
  init_token(syms, axiom_tok, "axiom");
  init_token(syms, auto_tok, "auto");
  init_token(syms, bool_tok, "bool");
  init_token(syms, byte_tok, "byte");
  init_token(syms, char_tok, "char");
  init_token(syms, char8_tok, "char8");
  init_token(syms, char16_tok, "char16");
  init_token(syms, char32_tok, "char32");
  init_token(syms, case_tok, "case");
  init_token(syms, class_tok, "class");
  init_token(syms, concept_tok, "concept");
  init_token(syms, const_tok, "const");
  init_token(syms, decltype_tok, "decltype");
  init_token(syms, def_tok, "def");
  init_token(syms, default_tok, "default");
  init_token(syms, delete_tok, "delete");
  init_token(syms, do_tok, "do");
  init_token(syms, double_tok, "double");
  init_token(syms, dynamic_tok, "dynamic");
  init_token(syms, enum_tok, "enum");
  init_token(syms, explicit_tok, "explicit");
  init_token(syms, export_tok, "export");
  init_token(syms, false_tok, "false");
  init_token(syms, float_tok, "float");
  init_token(syms, float16_tok, "float16");
  init_token(syms, float32_tok, "float32");
  init_token(syms, float64_tok, "float64");
  init_token(syms, float128_tok, "float128");
  init_token(syms, for_tok, "for");
  init_token(syms, if_tok, "if");
  init_token(syms, implicit_tok, "implicit");
  init_token(syms, import_tok, "import");
  init_token(syms, int_tok, "int");
  init_token(syms, int8_tok, "int8");
  init_token(syms, int16_tok, "int16");
  init_token(syms, int32_tok, "int32");
  init_token(syms, int64_tok, "int64");
  init_token(syms, int128_tok, "int128");
  init_token(syms, namespace_tok, "namespace");
  init_token(syms, requires_tok, "requires");
  init_token(syms, return_tok, "return");
  init_token(syms, static_tok, "static");
  init_token(syms, struct_tok, "struct");
  init_token(syms, switch_tok, "switch");
  init_token(syms, this_tok, "this");
  init_token(syms, template_tok, "template");
  init_token(syms, true_tok, "true");
  init_token(syms, typename_tok, "typename");
  init_token(syms, uint_tok, "uint");
  init_token(syms, uint8_tok, "uint8");
  init_token(syms, uint16_tok, "uint16");
  init_token(syms, uint32_tok, "uint32");
  init_token(syms, uint64_tok, "uint64");
  init_token(syms, int128_tok, "int128");
  init_token(syms, union_tok, "union");
  init_token(syms, using_tok, "using");
  init_token(syms, virtual_tok, "virtual");
  init_token(syms, var_tok, "var");
  init_token(syms, void_tok, "void");
  init_token(syms, volatile_tok, "volatile");
  init_token(syms, while_tok, "while");

  init_token_class(syms, identifier_tok, "<identifier>");
  init_token_class(syms, integer_tok, "<integer>");
}
Example #8
0
void
init_tokens() {
  // Keywords
  init_token(def_tok, "def");
  init_token(else_tok, "else");
  init_token(false_tok, "false");
  init_token(if_tok, "if");
  init_token(iszero_tok, "iszero");
  init_token(print_tok, "print");
  init_token(pred_tok, "pred");
  init_token(succ_tok, "succ");
  init_token(then_tok, "then");
  init_token(true_tok, "true");
  init_token(typeof_tok, "typeof");
  init_token(unit_tok, "unit");
  init_token(and_tok, "and");
  init_token(or_tok, "or");
  init_token(not_tok, "not");
  init_token(eq_comp_tok, "eq");
  init_token(less_tok, "lt");
  // Type names
  init_token(bool_type_tok, "Bool");
  init_token(nat_type_tok, "Nat");
  init_token(unit_type_tok, "Unit");
  // Identifiers and literals
  init_token(identifier_tok, "identifier");
  init_token(decimal_literal_tok, "decimal");
  // Relational algebra identifiers
  init_token(select_tok, "select");
  init_token(from_tok, "from");
  init_token(where_tok, "where");
  init_token(join_tok, "join");
  init_token(on_tok, "on");
  init_token(union_tok, "union");
  init_token(intersect_tok, "intersect");
  init_token(except_tok, "except");
}