use logos::Logos;
#[derive(Logos, Debug, PartialEq, Clone)]
#[logos(skip r"[ \t\r\n\f]+")]
#[logos(skip r"//[^\r\n]*")]
pub enum Token<'a> {
#[token("HOST", ignore(ascii_case))] Host,
#[token("FLOW", ignore(ascii_case))] Flow,
#[token("IP", ignore(ascii_case))] Ip,
#[token("MAC", ignore(ascii_case))] Mac,
#[token("COMPILE", ignore(ascii_case))] Compile,
#[token("LOOP", ignore(ascii_case))] Loop,
#[token("TCP", ignore(ascii_case))] Tcp,
#[token("UDP", ignore(ascii_case))] Udp,
#[token("SYN", ignore(ascii_case))] Syn,
#[token("ACK", ignore(ascii_case))] Ack,
#[token("FIN", ignore(ascii_case))] Fin,
#[token("RST", ignore(ascii_case))] Rst,
#[token("PSH", ignore(ascii_case))] Psh,
#[token("URG", ignore(ascii_case))] Urg,
#[token("ECE", ignore(ascii_case))] Ece,
#[token("CWR", ignore(ascii_case))] Cwr,
#[token("SRCPORT", ignore(ascii_case))] SrcPort,
#[token("DSTPORT", ignore(ascii_case))] DstPort,
#[token("SEQ", ignore(ascii_case))] Seq,
#[token("ACKNUM", ignore(ascii_case))] AckNum,
#[token("WIN", ignore(ascii_case))] Win,
#[token("PAYLOAD", ignore(ascii_case))] Payload,
#[token("HEXPAYLOAD", ignore(ascii_case))] HexPayload,
#[token("WAIT", ignore(ascii_case))] Wait,
#[token("VLAN", ignore(ascii_case))] Vlan,
#[token("DSCP", ignore(ascii_case))] Dscp,
#[token("ECN", ignore(ascii_case))] Ecn,
#[token("TTL", ignore(ascii_case))] Ttl,
#[token("FLOWLABEL", ignore(ascii_case))] FlowLabel,
#[token("SNMP1", ignore(ascii_case))] Snmp1,
#[token("SNMP2", ignore(ascii_case))] Snmp2,
#[token("SNMP3", ignore(ascii_case))] Snmp3,
#[token("TRAP", ignore(ascii_case))] Trap,
#[token("GET", ignore(ascii_case))] Get,
#[token("SET", ignore(ascii_case))] Set,
#[token("RESPONSE", ignore(ascii_case))] Response,
#[token("INFORM", ignore(ascii_case))] Inform,
#[token("GETNEXT", ignore(ascii_case))] GetNext,
#[token("GETBULK", ignore(ascii_case))] GetBulk,
#[token("COMMUNITY", ignore(ascii_case))] Community,
#[token("USER", ignore(ascii_case))] User,
#[token("OID", ignore(ascii_case))] Oid,
#[token("SYSUPTIME", ignore(ascii_case))] SysUpTime,
#[token("VARBIND", ignore(ascii_case))] VarBind,
#[token("NULLVAL", ignore(ascii_case))]
#[token("NULL", ignore(ascii_case))] NullVal,
#[token("STRING", ignore(ascii_case))] StringVal,
#[token("INT", ignore(ascii_case))] IntVal,
#[token("TIMETICKS", ignore(ascii_case))] TimeTicksVal,
#[token("IPVAL", ignore(ascii_case))] IpVal,
#[token("OIDVAL", ignore(ascii_case))] OidVal,
#[token("COUNTER32", ignore(ascii_case))] Counter32Val,
#[token("GAUGE32", ignore(ascii_case))] Gauge32Val,
#[token("COUNTER64", ignore(ascii_case))] Counter64Val,
#[token("ENTERPRISE", ignore(ascii_case))] Enterprise,
#[token("AGENTIP", ignore(ascii_case))] AgentIp,
#[token("GENTRAP", ignore(ascii_case))] GenTrap,
#[token("SPECTRAP", ignore(ascii_case))] SpecTrap,
#[token("ENGINEID", ignore(ascii_case))] EngineId,
#[token("ENGINEBOOTS", ignore(ascii_case))] EngineBoots,
#[token("ENGINETIME", ignore(ascii_case))] EngineTime,
#[token("CONTEXTNAME", ignore(ascii_case))] ContextName,
#[token("AUTH", ignore(ascii_case))] Auth,
#[token("PRIV", ignore(ascii_case))] Priv,
#[token("MD5", ignore(ascii_case))] Md5,
#[token("SHA", ignore(ascii_case))] Sha,
#[token("SHA256", ignore(ascii_case))] Sha256,
#[token("SHA384", ignore(ascii_case))] Sha384,
#[token("SHA512", ignore(ascii_case))] Sha512,
#[token("DES", ignore(ascii_case))] Des,
#[token("AES", ignore(ascii_case))] Aes,
#[token("NONREPEATERS", ignore(ascii_case))] NonRepeaters,
#[token("MAXREPETITIONS", ignore(ascii_case))] MaxRepetitions,
#[token("REQID", ignore(ascii_case))] ReqId,
#[token("PCP", ignore(ascii_case))] Pcp,
#[token("DEI", ignore(ascii_case))] Dei,
#[token("QINQ", ignore(ascii_case))] Qinq,
#[token("INNER_VLAN", ignore(ascii_case))] InnerVlan,
#[token("MPLS", ignore(ascii_case))] Mpls,
#[token("EXP", ignore(ascii_case))]
#[token("TC", ignore(ascii_case))] Exp,
#[token("BOS", ignore(ascii_case))] Bos,
#[token("MPLS_TTL", ignore(ascii_case))] MplsTtl,
#[token("SRCMAC", ignore(ascii_case))] SrcMac,
#[token("DSTMAC", ignore(ascii_case))] DstMac,
#[token("ETHERTYPE", ignore(ascii_case))] EtherType,
#[token("IPID", ignore(ascii_case))] IpId,
#[token("DF", ignore(ascii_case))] Df,
#[token("MF", ignore(ascii_case))] Mf,
#[token("FRAGOFFSET", ignore(ascii_case))] FragOffset,
#[token("TRANSPORT", ignore(ascii_case))] Transport,
#[token("WINDOW", ignore(ascii_case))] Window,
#[token("URGENT", ignore(ascii_case))] Urgent,
#[token("MSS", ignore(ascii_case))] Mss,
#[token("WSCALE", ignore(ascii_case))] Wscale,
#[token("SACK_PERM", ignore(ascii_case))]
#[token("SACKPERM", ignore(ascii_case))] SackPerm,
#[token("TSVAL", ignore(ascii_case))] Tsval,
#[token("TSECR", ignore(ascii_case))] Tsecr,
#[token("VTAG", ignore(ascii_case))] Vtag,
#[token("STREAM", ignore(ascii_case))] Stream,
#[token("SSN", ignore(ascii_case))] Ssn,
#[token("PPID", ignore(ascii_case))] Ppid,
#[token("CHUNK", ignore(ascii_case))] Chunk,
#[token("ARP", ignore(ascii_case))] Arp,
#[token("LLDP", ignore(ascii_case))] Lldp,
#[token("STP", ignore(ascii_case))] Stp,
#[token("LACP", ignore(ascii_case))] Lacp,
#[token("EAPOL", ignore(ascii_case))] Eapol,
#[token("ICMP", ignore(ascii_case))] Icmp,
#[token("NDP", ignore(ascii_case))] Ndp,
#[token("IGMP", ignore(ascii_case))] Igmp,
#[token("MLD", ignore(ascii_case))] Mld,
#[token("GRE", ignore(ascii_case))] Gre,
#[token("VXLAN", ignore(ascii_case))] Vxlan,
#[token("GENEVE", ignore(ascii_case))] Geneve,
#[token("IPSEC", ignore(ascii_case))] Ipsec,
#[token("ESP", ignore(ascii_case))] Esp,
#[token("AH", ignore(ascii_case))] Ah,
#[token("IKEV2", ignore(ascii_case))] Ikev2,
#[token("WIREGUARD", ignore(ascii_case))] Wireguard,
#[token("OSPF", ignore(ascii_case))] Ospf,
#[token("BGP", ignore(ascii_case))] Bgp,
#[token("RIP", ignore(ascii_case))] Rip,
#[token("VRRP", ignore(ascii_case))] Vrrp,
#[token("HSRP", ignore(ascii_case))] Hsrp,
#[token("PIM", ignore(ascii_case))] Pim,
#[token("BFD", ignore(ascii_case))] Bfd,
#[token("OPENFLOW", ignore(ascii_case))] Openflow,
#[token("SCTP", ignore(ascii_case))] Sctp,
#[token("REQUEST", ignore(ascii_case))] Request,
#[token("REPLY", ignore(ascii_case))] Reply,
#[token("GRATUITOUS", ignore(ascii_case))] Gratuitous,
#[token("GARP", ignore(ascii_case))] Garp,
#[token("SPA", ignore(ascii_case))] Spa,
#[token("THA", ignore(ascii_case))] Tha,
#[token("TPA", ignore(ascii_case))] Tpa,
#[token("SENDERMAC", ignore(ascii_case))] SenderMac,
#[token("TARGETMAC", ignore(ascii_case))] TargetMac,
#[token("SENDERIP", ignore(ascii_case))] SenderIp,
#[token("TARGETIP", ignore(ascii_case))] TargetIp,
#[token("CHASSIS_ID", ignore(ascii_case))] ChassisId,
#[token("PORT_ID", ignore(ascii_case))] PortId,
#[token("SYSNAME", ignore(ascii_case))] SysName,
#[token("SYSDESC", ignore(ascii_case))] SysDesc,
#[token("ROOT_ID", ignore(ascii_case))] RootId,
#[token("BRIDGE_ID", ignore(ascii_case))] BridgeId,
#[token("COST", ignore(ascii_case))] Cost,
#[token("MAX_AGE", ignore(ascii_case))] MaxAge,
#[token("HELLO_TIME", ignore(ascii_case))] HelloTime,
#[token("FORWARD_DELAY", ignore(ascii_case))] ForwardDelay,
#[token("RSTP", ignore(ascii_case))] Rstp,
#[token("FLAGS", ignore(ascii_case))] Flags,
#[token("ACTOR_SYS", ignore(ascii_case))] ActorSys,
#[token("ACTOR_KEY", ignore(ascii_case))] ActorKey,
#[token("ACTOR_PORT", ignore(ascii_case))] ActorPort,
#[token("PARTNER_SYS", ignore(ascii_case))] PartnerSys,
#[token("PARTNER_KEY", ignore(ascii_case))] PartnerKey,
#[token("PARTNER_PORT", ignore(ascii_case))] PartnerPort,
#[token("ACTOR_STATE", ignore(ascii_case))] ActorState,
#[token("PARTNER_STATE", ignore(ascii_case))] PartnerState,
#[token("VERSION", ignore(ascii_case))] Version,
#[token("TYPE", ignore(ascii_case))] Type,
#[token("EAP_PACKET", ignore(ascii_case))] EapPacket,
#[token("START", ignore(ascii_case))] Start,
#[token("LOGOFF", ignore(ascii_case))] Logoff,
#[token("KEY", ignore(ascii_case))] Key,
#[token("EAP_CODE", ignore(ascii_case))] EapCode,
#[token("EAP_ID", ignore(ascii_case))] EapId,
#[token("EAP_METHOD", ignore(ascii_case))] EapMethod,
#[token("IDENTITY", ignore(ascii_case))] Identity,
#[token("LABEL", ignore(ascii_case))] Label,
#[token("ECHO_REQUEST", ignore(ascii_case))] EchoRequest,
#[token("ECHO_REPLY", ignore(ascii_case))] EchoReply,
#[token("DEST_UNREACH", ignore(ascii_case))] DestUnreach,
#[token("TIME_EXCEEDED", ignore(ascii_case))] TimeExceeded,
#[token("REDIRECT", ignore(ascii_case))] Redirect,
#[token("CODE", ignore(ascii_case))] Code,
#[token("ID", ignore(ascii_case))] Id,
#[token("GATEWAY", ignore(ascii_case))] Gateway,
#[token("ROUTER_SOLICIT", ignore(ascii_case))] RouterSolicit,
#[token("ROUTER_ADVERT", ignore(ascii_case))] RouterAdvert,
#[token("NEIGHBOR_SOLICIT", ignore(ascii_case))] NeighborSolicit,
#[token("NEIGHBOR_ADVERT", ignore(ascii_case))] NeighborAdvert,
#[token("TARGET", ignore(ascii_case))] Target,
#[token("SLLA", ignore(ascii_case))] Slla,
#[token("TLLA", ignore(ascii_case))] Tlla,
#[token("ROUTER_LIFETIME", ignore(ascii_case))] RouterLifetime,
#[token("QUERY", ignore(ascii_case))] Query,
#[token("REPORT", ignore(ascii_case))] Report,
#[token("LEAVE", ignore(ascii_case))] Leave,
#[token("GROUP", ignore(ascii_case))] Group,
#[token("MAX_RESP", ignore(ascii_case))] MaxResp,
#[token("V1", ignore(ascii_case))] V1,
#[token("V2", ignore(ascii_case))] V2,
#[token("V3", ignore(ascii_case))] V3,
#[token("DONE", ignore(ascii_case))] Done,
#[token("MULTICAST_ADDR", ignore(ascii_case))] MulticastAddr,
#[token("MAX_RESP_DELAY", ignore(ascii_case))] MaxRespDelay,
#[token("GRE_KEY", ignore(ascii_case))] GreKey,
#[token("GRE_SEQ", ignore(ascii_case))] GreSeq,
#[token("GRE_PROTO", ignore(ascii_case))] GreProto,
#[token("CHECKSUM", ignore(ascii_case))] Checksum,
#[token("VNI", ignore(ascii_case))] Vni,
#[token("VNID", ignore(ascii_case))] Vnid,
#[token("OPT_CLASS", ignore(ascii_case))] OptClass,
#[token("OPT_TYPE", ignore(ascii_case))] OptType,
#[token("PROTOCOL_TYPE", ignore(ascii_case))] ProtocolType,
#[token("SPI", ignore(ascii_case))] Spi,
#[token("IV", ignore(ascii_case))] Iv,
#[token("ICV", ignore(ascii_case))] Icv,
#[token("NEXT_HEADER", ignore(ascii_case))] NextHeader,
#[token("INITIATOR_SPI", ignore(ascii_case))] InitiatorSpi,
#[token("RESPONDER_SPI", ignore(ascii_case))] ResponderSpi,
#[token("EXCHANGE", ignore(ascii_case))] Exchange,
#[token("SA_INIT", ignore(ascii_case))] SaInit,
#[token("CREATE_CHILD_SA", ignore(ascii_case))] CreateChildSa,
#[token("INFORMATIONAL", ignore(ascii_case))] Informational,
#[token("MSGID", ignore(ascii_case))] MsgId,
#[token("NEXT_PAYLOAD", ignore(ascii_case))] NextPayload,
#[token("INITIATION", ignore(ascii_case))] Initiation,
#[token("COOKIE", ignore(ascii_case))] Cookie,
#[token("DATA", ignore(ascii_case))] Data,
#[token("SENDER", ignore(ascii_case))] Sender,
#[token("RECEIVER", ignore(ascii_case))] Receiver,
#[token("COUNTER", ignore(ascii_case))] Counter,
#[token("HELLO", ignore(ascii_case))] Hello,
#[token("DBD", ignore(ascii_case))] Dbd,
#[token("LSR", ignore(ascii_case))] Lsr,
#[token("LSU", ignore(ascii_case))] Lsu,
#[token("LSACK", ignore(ascii_case))] LsAck,
#[token("ROUTER_ID", ignore(ascii_case))] RouterId,
#[token("AREA_ID", ignore(ascii_case))] AreaId,
#[token("HELLO_INTERVAL", ignore(ascii_case))] HelloInterval,
#[token("DEAD_INTERVAL", ignore(ascii_case))] DeadInterval,
#[token("PRIORITY", ignore(ascii_case))] Priority,
#[token("OPEN", ignore(ascii_case))] Open,
#[token("UPDATE", ignore(ascii_case))] Update,
#[token("NOTIFICATION", ignore(ascii_case))] Notification,
#[token("KEEPALIVE", ignore(ascii_case))] Keepalive,
#[token("ASN", ignore(ascii_case))] Asn,
#[token("HOLDTIME", ignore(ascii_case))] HoldTime,
#[token("BGPID", ignore(ascii_case))] BgpId,
#[token("PREFIX", ignore(ascii_case))] Prefix,
#[token("NLRI", ignore(ascii_case))] Nlri,
#[token("NEXTHOP", ignore(ascii_case))] NextHop,
#[token("METRIC", ignore(ascii_case))] Metric,
#[token("TAG", ignore(ascii_case))] Tag,
#[token("VRID", ignore(ascii_case))] Vrid,
#[token("ADV_INT", ignore(ascii_case))] AdvInt,
#[token("VIP", ignore(ascii_case))] Vip,
#[token("HELLOTIME", ignore(ascii_case))] HelloTimeHsrp,
#[token("STATE", ignore(ascii_case))] State,
#[token("JOIN_PRUNE", ignore(ascii_case))] JoinPrune,
#[token("REGISTER", ignore(ascii_case))] Register,
#[token("SOURCE", ignore(ascii_case))] Source,
#[token("RP", ignore(ascii_case))] Rp,
#[token("DR_PRIORITY", ignore(ascii_case))] DrPriority,
#[token("DIAG", ignore(ascii_case))] Diag,
#[token("MY_DISC", ignore(ascii_case))] MyDisc,
#[token("YOUR_DISC", ignore(ascii_case))] YourDisc,
#[token("MIN_TX", ignore(ascii_case))] MinTx,
#[token("MIN_RX", ignore(ascii_case))] MinRx,
#[token("MULT", ignore(ascii_case))] Mult,
#[token("FEATURES_REQ", ignore(ascii_case))] FeaturesReq,
#[token("FEATURES_REPLY", ignore(ascii_case))] FeaturesReply,
#[token("PACKET_IN", ignore(ascii_case))] PacketIn,
#[token("PACKET_OUT", ignore(ascii_case))] PacketOut,
#[token("FLOW_MOD", ignore(ascii_case))] FlowMod,
#[token("ECHO_REQ", ignore(ascii_case))] EchoReq,
#[token("XID", ignore(ascii_case))] Xid,
#[token("DPID", ignore(ascii_case))] Dpid,
#[token("TABLE_ID", ignore(ascii_case))] TableId,
#[token("INIT", ignore(ascii_case))] Init,
#[token("INIT_ACK", ignore(ascii_case))] InitAck,
#[token("SACK", ignore(ascii_case))] Sack,
#[token("HEARTBEAT", ignore(ascii_case))] Heartbeat,
#[token("HEARTBEAT_ACK", ignore(ascii_case))] HeartbeatAck,
#[token("ABORT", ignore(ascii_case))] Abort,
#[token("SHUTDOWN", ignore(ascii_case))] Shutdown,
#[token("COOKIE_ECHO", ignore(ascii_case))] CookieEcho,
#[token("COOKIE_ACK", ignore(ascii_case))] CookieAck,
#[token("TSN", ignore(ascii_case))] Tsn,
#[token("DNS", ignore(ascii_case))] Dns,
#[token("MDNS", ignore(ascii_case))] Mdns,
#[token("DHCP", ignore(ascii_case))] Dhcp,
#[token("NTP", ignore(ascii_case))] Ntp,
#[token("PTP", ignore(ascii_case))] Ptp,
#[token("RADIUS", ignore(ascii_case))] Radius,
#[token("TACACS", ignore(ascii_case))] Tacacs,
#[token("SYSLOG", ignore(ascii_case))] Syslog,
#[token("NETFLOW", ignore(ascii_case))] Netflow,
#[token("IPFIX", ignore(ascii_case))] Ipfix,
#[token("SFLOW", ignore(ascii_case))] Sflow,
#[token("TFTP", ignore(ascii_case))] Tftp,
#[token("FTP", ignore(ascii_case))] Ftp,
#[token("SSH", ignore(ascii_case))] Ssh,
#[token("TELNET", ignore(ascii_case))] Telnet,
#[token("HTTP", ignore(ascii_case))] Http,
#[token("HTTP2", ignore(ascii_case))] Http2,
#[token("GRPC", ignore(ascii_case))] Grpc,
#[token("WEBSOCKET", ignore(ascii_case))] Websocket,
#[token("TLS", ignore(ascii_case))] Tls,
#[token("QUIC", ignore(ascii_case))] Quic,
#[token("STUN", ignore(ascii_case))] Stun,
#[token("SIP", ignore(ascii_case))] Sip,
#[token("RTP", ignore(ascii_case))] Rtp,
#[token("RTSP", ignore(ascii_case))] Rtsp,
#[token("SMTP", ignore(ascii_case))] Smtp,
#[token("IMAP", ignore(ascii_case))] Imap,
#[token("POP3", ignore(ascii_case))] Pop3,
#[token("KERBEROS", ignore(ascii_case))] Kerberos,
#[token("LDAP", ignore(ascii_case))] Ldap,
#[token("SMB", ignore(ascii_case))] Smb,
#[token("NFS", ignore(ascii_case))] Nfs,
#[token("REDIS", ignore(ascii_case))] Redis,
#[token("MEMCACHED", ignore(ascii_case))] Memcached,
#[token("MYSQL", ignore(ascii_case))] Mysql,
#[token("POSTGRES", ignore(ascii_case))] Postgres,
#[token("MQTT", ignore(ascii_case))] Mqtt,
#[token("COAP", ignore(ascii_case))] Coap,
#[token("AMQP", ignore(ascii_case))] Amqp,
#[token("SSDP", ignore(ascii_case))] Ssdp,
#[token("WHOIS", ignore(ascii_case))] Whois,
#[token("MODBUS", ignore(ascii_case))] Modbus,
#[token("BACNET", ignore(ascii_case))] Bacnet,
#[token("DNP3", ignore(ascii_case))] Dnp3,
#[token("S7COMM", ignore(ascii_case))] S7comm,
#[token("ETHERNETIP", ignore(ascii_case))] Ethernetip,
#[token("OPCUA", ignore(ascii_case))] Opcua,
#[token("TXID", ignore(ascii_case))] Txid,
#[token("QNAME", ignore(ascii_case))] Qname,
#[token("QTYPE", ignore(ascii_case))] Qtype,
#[token("RDATA", ignore(ascii_case))] Rdata,
#[token("RCODE", ignore(ascii_case))] Rcode,
#[token("ANS_TTL", ignore(ascii_case))] AnsTtl,
#[token("DISCOVER", ignore(ascii_case))] Discover,
#[token("SOLICIT", ignore(ascii_case))] Solicit,
#[token("OFFER", ignore(ascii_case))] Offer,
#[token("ADVERTISE", ignore(ascii_case))] Advertise,
#[token("RELEASE", ignore(ascii_case))] Release,
#[token("CIADDR", ignore(ascii_case))] Ciaddr,
#[token("YIADDR", ignore(ascii_case))] Yiaddr,
#[token("SIADDR", ignore(ascii_case))] Siaddr,
#[token("CHADDR", ignore(ascii_case))] Chaddr,
#[token("HOSTNAME", ignore(ascii_case))] Hostname,
#[token("DNS_SERVER", ignore(ascii_case))] DnsServer,
#[token("ROUTER", ignore(ascii_case))] Router,
#[token("SUBNET_MASK", ignore(ascii_case))] SubnetMask,
#[token("LEASE_TIME", ignore(ascii_case))] LeaseTime,
#[token("LI", ignore(ascii_case))] Li,
#[token("VN", ignore(ascii_case))] Vn,
#[token("MODE", ignore(ascii_case))] Mode,
#[token("STRATUM", ignore(ascii_case))] Stratum,
#[token("POLL", ignore(ascii_case))] Poll,
#[token("PRECISION", ignore(ascii_case))] Precision,
#[token("REFID", ignore(ascii_case))] RefId,
#[token("TX_TIMESTAMP", ignore(ascii_case))] TxTimestamp,
#[token("MSG_TYPE", ignore(ascii_case))] MsgType,
#[token("SYNC", ignore(ascii_case))] Sync,
#[token("DELAY_REQ", ignore(ascii_case))] DelayReq,
#[token("FOLLOW_UP", ignore(ascii_case))] FollowUp,
#[token("DELAY_RESP", ignore(ascii_case))] DelayResp,
#[token("ANNOUNCE", ignore(ascii_case))] Announce,
#[token("DOMAIN", ignore(ascii_case))] Domain,
#[token("SEQ_ID", ignore(ascii_case))] SeqId,
#[token("CLOCK_ID", ignore(ascii_case))] ClockId,
#[token("ACCESS_REQUEST", ignore(ascii_case))] AccessRequest,
#[token("ACCESS_ACCEPT", ignore(ascii_case))] AccessAccept,
#[token("ACCESS_REJECT", ignore(ascii_case))] AccessReject,
#[token("ACCESS_CHALLENGE", ignore(ascii_case))] AccessChallenge,
#[token("ACCOUNTING_REQUEST", ignore(ascii_case))] AccountingRequest,
#[token("ACCOUNTING_RESPONSE", ignore(ascii_case))] AccountingResponse,
#[token("NAS_IP", ignore(ascii_case))] NasIp,
#[token("SERVICE_TYPE", ignore(ascii_case))] ServiceType,
#[token("FRAMED_IP", ignore(ascii_case))] FramedIp,
#[token("AUTHEN", ignore(ascii_case))] Authen,
#[token("AUTHOR", ignore(ascii_case))] Author,
#[token("ACCT", ignore(ascii_case))] Acct,
#[token("SESSION_ID", ignore(ascii_case))] SessionId,
#[token("FACILITY", ignore(ascii_case))] Facility,
#[token("SEVERITY", ignore(ascii_case))] Severity,
#[token("PRI", ignore(ascii_case))] Pri,
#[token("APP", ignore(ascii_case))] App,
#[token("PROCID", ignore(ascii_case))] Procid,
#[token("MSG", ignore(ascii_case))] Msg,
#[token("SRCIP", ignore(ascii_case))] SrcIp,
#[token("DSTIP", ignore(ascii_case))] DstIp,
#[token("PROTO", ignore(ascii_case))] Proto,
#[token("PACKETS", ignore(ascii_case))] Packets,
#[token("OCTETS", ignore(ascii_case))] Octets,
#[token("DOMAIN_ID", ignore(ascii_case))] DomainId,
#[token("AGENT_IP", ignore(ascii_case))] AgentIpSflow,
#[token("SUB_AGENT_ID", ignore(ascii_case))] SubAgentId,
#[token("UPTIME", ignore(ascii_case))] Uptime,
#[token("SAMPLES", ignore(ascii_case))] Samples,
#[token("RRQ", ignore(ascii_case))] Rrq,
#[token("WRQ", ignore(ascii_case))] Wrq,
#[token("FILENAME", ignore(ascii_case))] Filename,
#[token("BLOCK", ignore(ascii_case))] Block,
#[token("ERRCODE", ignore(ascii_case))] ErrCode,
#[token("ERRMSG", ignore(ascii_case))] ErrMsg,
#[token("CMD", ignore(ascii_case))] Cmd,
#[token("ARG", ignore(ascii_case))] Arg,
#[token("BANNER", ignore(ascii_case))] Banner,
#[token("KEXINIT", ignore(ascii_case))] KexInit,
#[token("NEWKEYS", ignore(ascii_case))] NewKeys,
#[token("MSG_CODE", ignore(ascii_case))] MsgCode,
#[token("WILL", ignore(ascii_case))] Will,
#[token("WONT", ignore(ascii_case))] Wont,
#[token("DO", ignore(ascii_case))] DoCmd,
#[token("DONT", ignore(ascii_case))] Dont,
#[token("OPTION", ignore(ascii_case))] Option,
#[token("POST", ignore(ascii_case))] Post,
#[token("PUT", ignore(ascii_case))] Put,
#[token("DELETE", ignore(ascii_case))] Delete,
#[token("HEAD", ignore(ascii_case))] Head,
#[token("OPTIONS", ignore(ascii_case))] Options,
#[token("PATCH", ignore(ascii_case))] Patch,
#[token("URI", ignore(ascii_case))] Uri,
#[token("HOST_HDR", ignore(ascii_case))] HostHdr,
#[token("USER_AGENT", ignore(ascii_case))] UserAgent,
#[token("CONTENT_TYPE", ignore(ascii_case))] ContentType,
#[token("STATUS", ignore(ascii_case))] Status,
#[token("REASON", ignore(ascii_case))] Reason,
#[token("HEADER", ignore(ascii_case))] Header,
#[token("BODY", ignore(ascii_case))] Body,
#[token("PREFACE", ignore(ascii_case))] Preface,
#[token("SETTINGS", ignore(ascii_case))] Settings,
#[token("HEADERS", ignore(ascii_case))] Headers,
#[token("WINDOW_UPDATE", ignore(ascii_case))] WindowUpdate,
#[token("PING", ignore(ascii_case))] Ping,
#[token("GOAWAY", ignore(ascii_case))] Goaway,
#[token("STREAM_ID", ignore(ascii_case))] StreamId,
#[token("SERVICE", ignore(ascii_case))] Service,
#[token("METHOD", ignore(ascii_case))] Method,
#[token("GRPC_STATUS", ignore(ascii_case))] GrpcStatus,
#[token("OPCODE", ignore(ascii_case))] Opcode,
#[token("TEXT", ignore(ascii_case))] Text,
#[token("BINARY", ignore(ascii_case))] Binary,
#[token("PONG", ignore(ascii_case))] Pong,
#[token("CLOSE", ignore(ascii_case))] Close,
#[token("FIN_BIT", ignore(ascii_case))] FinBit,
#[token("MASK_KEY", ignore(ascii_case))] MaskKey,
#[token("CLIENT_HELLO", ignore(ascii_case))] ClientHello,
#[token("SERVER_HELLO", ignore(ascii_case))] ServerHello,
#[token("CERTIFICATE", ignore(ascii_case))] Certificate,
#[token("FINISHED", ignore(ascii_case))] Finished,
#[token("APP_DATA", ignore(ascii_case))] AppData,
#[token("ALERT", ignore(ascii_case))] Alert,
#[token("RECORD_VERSION", ignore(ascii_case))] RecordVersion,
#[token("HANDSHAKE_VERSION", ignore(ascii_case))] HandshakeVersion,
#[token("SNI", ignore(ascii_case))] Sni,
#[token("CIPHERSUITE", ignore(ascii_case))] Ciphersuite,
#[token("ALPN", ignore(ascii_case))] Alpn,
#[token("INITIAL", ignore(ascii_case))] Initial,
#[token("ZERO_RTT", ignore(ascii_case))] ZeroRtt,
#[token("HANDSHAKE", ignore(ascii_case))] Handshake,
#[token("RETRY", ignore(ascii_case))] Retry,
#[token("SHORT", ignore(ascii_case))] Short,
#[token("DCID", ignore(ascii_case))] Dcid,
#[token("SCID", ignore(ascii_case))] Scid,
#[token("TOKEN", ignore(ascii_case))] Token,
#[token("PKT_NUM", ignore(ascii_case))] PktNum,
#[token("BINDING_REQUEST", ignore(ascii_case))] BindingRequest,
#[token("BINDING_RESPONSE", ignore(ascii_case))] BindingResponse,
#[token("BINDING_ERROR", ignore(ascii_case))] BindingError,
#[token("XOR_MAPPED_ADDR", ignore(ascii_case))] XorMappedAddr,
#[token("SOFTWARE", ignore(ascii_case))] Software,
#[token("INVITE", ignore(ascii_case))] Invite,
#[token("BYE", ignore(ascii_case))] Bye,
#[token("CANCEL", ignore(ascii_case))] Cancel,
#[token("FROM", ignore(ascii_case))] From,
#[token("TO", ignore(ascii_case))] To,
#[token("CALL_ID", ignore(ascii_case))] CallId,
#[token("CSEQ", ignore(ascii_case))] Cseq,
#[token("VIA", ignore(ascii_case))] Via,
#[token("CONTACT", ignore(ascii_case))] Contact,
#[token("PT", ignore(ascii_case))] Pt,
#[token("TIMESTAMP", ignore(ascii_case))] Timestamp,
#[token("SSRC", ignore(ascii_case))] Ssrc,
#[token("MARKER", ignore(ascii_case))] Marker,
#[token("DESCRIBE", ignore(ascii_case))] Describe,
#[token("SETUP", ignore(ascii_case))] Setup,
#[token("PLAY", ignore(ascii_case))] Play,
#[token("TEARDOWN", ignore(ascii_case))] Teardown,
#[token("TRANSPORT_HDR", ignore(ascii_case))] TransportHdr,
#[token("SESSION", ignore(ascii_case))] Session,
#[token("EHLO", ignore(ascii_case))] Ehlo,
#[token("HELO", ignore(ascii_case))] Helo,
#[token("MAIL_FROM", ignore(ascii_case))] MailFrom,
#[token("RCPT_TO", ignore(ascii_case))] RcptTo,
#[token("QUIT", ignore(ascii_case))] Quit,
#[token("PARAM", ignore(ascii_case))] Param,
#[token("OK", ignore(ascii_case))] Ok,
#[token("ERR", ignore(ascii_case))] Err,
#[token("AS_REQ", ignore(ascii_case))] AsReq,
#[token("AS_REP", ignore(ascii_case))] AsRep,
#[token("TGS_REQ", ignore(ascii_case))] TgsReq,
#[token("TGS_REP", ignore(ascii_case))] TgsRep,
#[token("KRB_ERROR", ignore(ascii_case))] KrbError,
#[token("REALM", ignore(ascii_case))] Realm,
#[token("CNAME", ignore(ascii_case))] Cname,
#[token("SNAME", ignore(ascii_case))] Sname,
#[token("ETYPE", ignore(ascii_case))] Etype,
#[token("BIND_REQ", ignore(ascii_case))] BindReq,
#[token("BIND_RES", ignore(ascii_case))] BindRes,
#[token("SEARCH_REQ", ignore(ascii_case))] SearchReq,
#[token("SEARCH_ENTRY", ignore(ascii_case))] SearchEntry,
#[token("SEARCH_DONE", ignore(ascii_case))] SearchDone,
#[token("UNBIND_REQ", ignore(ascii_case))] UnbindReq,
#[token("BASE_DN", ignore(ascii_case))] BaseDn,
#[token("FILTER", ignore(ascii_case))] Filter,
#[token("RESULT_CODE", ignore(ascii_case))] ResultCode,
#[token("COMMAND", ignore(ascii_case))] Command,
#[token("NEGOTIATE", ignore(ascii_case))] Negotiate,
#[token("SESSION_SETUP", ignore(ascii_case))] SessionSetup,
#[token("TREE_CONNECT", ignore(ascii_case))] TreeConnect,
#[token("CREATE", ignore(ascii_case))] Create,
#[token("TREE_DISCONNECT", ignore(ascii_case))] TreeDisconnect,
#[token("TREE_ID", ignore(ascii_case))] TreeId,
#[token("SHARE", ignore(ascii_case))] Share,
#[token("VERS", ignore(ascii_case))] Vers,
#[token("PROC", ignore(ascii_case))] Proc,
#[token("PATH", ignore(ascii_case))] Path,
#[token("COMPOUND", ignore(ascii_case))] Compound,
#[token("ARGS", ignore(ascii_case))] Args,
#[token("REPLY_TYPE", ignore(ascii_case))] ReplyType,
#[token("VALUE", ignore(ascii_case))] Value,
#[token("EXPTIME", ignore(ascii_case))] Exptime,
#[token("OPAQUE", ignore(ascii_case))] Opaque,
#[token("CAS", ignore(ascii_case))] Cas,
#[token("GREETING", ignore(ascii_case))] Greeting,
#[token("LOGIN", ignore(ascii_case))] Login,
#[token("SQL", ignore(ascii_case))] Sql,
#[token("EOF", ignore(ascii_case))] Eof,
#[token("SERVER_VERSION", ignore(ascii_case))] ServerVersion,
#[token("DB", ignore(ascii_case))] Db,
#[token("STARTUP", ignore(ascii_case))] Startup,
#[token("READY_FOR_QUERY", ignore(ascii_case))] ReadyForQuery,
#[token("COMMAND_COMPLETE", ignore(ascii_case))] CommandComplete,
#[token("ERROR_RESPONSE", ignore(ascii_case))] ErrorResponse,
#[token("AUTH_OK", ignore(ascii_case))] AuthOk,
#[token("CONNECT", ignore(ascii_case))] Connect,
#[token("CONNACK", ignore(ascii_case))] Connack,
#[token("PUBLISH", ignore(ascii_case))] Publish,
#[token("PUBACK", ignore(ascii_case))] Puback,
#[token("SUBSCRIBE", ignore(ascii_case))] Subscribe,
#[token("SUBACK", ignore(ascii_case))] Suback,
#[token("PINGREQ", ignore(ascii_case))] Pingreq,
#[token("PINGRESP", ignore(ascii_case))] Pingresp,
#[token("DISCONNECT", ignore(ascii_case))] Disconnect,
#[token("CLIENT_ID", ignore(ascii_case))] ClientId,
#[token("TOPIC", ignore(ascii_case))] Topic,
#[token("QOS", ignore(ascii_case))] Qos,
#[token("RETAIN", ignore(ascii_case))] Retain,
#[token("PKT_ID", ignore(ascii_case))] PktId,
#[token("RETURN_CODE", ignore(ascii_case))] ReturnCode,
#[token("CON", ignore(ascii_case))] Con,
#[token("NON", ignore(ascii_case))] Non,
#[token("CHANGED", ignore(ascii_case))] Changed,
#[token("CREATED", ignore(ascii_case))] Created,
#[token("NOT_FOUND", ignore(ascii_case))] NotFound,
#[token("URI_PATH", ignore(ascii_case))] UriPath,
#[token("CONTENT_FORMAT", ignore(ascii_case))] ContentFormat,
#[token("PROTOCOL_HEADER", ignore(ascii_case))] ProtocolHeader,
#[token("CONNECTION_START", ignore(ascii_case))] ConnectionStart,
#[token("CHANNEL_OPEN", ignore(ascii_case))] ChannelOpen,
#[token("BASIC_PUBLISH", ignore(ascii_case))] BasicPublish,
#[token("BASIC_DELIVER", ignore(ascii_case))] BasicDeliver,
#[token("CHANNEL", ignore(ascii_case))] Channel,
#[token("ROUTING_KEY", ignore(ascii_case))] RoutingKey,
#[token("MSEARCH", ignore(ascii_case))] Msearch,
#[token("NOTIFY", ignore(ascii_case))] Notify,
#[token("MAN", ignore(ascii_case))] Man,
#[token("MX", ignore(ascii_case))] Mx,
#[token("ST", ignore(ascii_case))] St,
#[token("NT", ignore(ascii_case))] Nt,
#[token("NTS", ignore(ascii_case))] Nts,
#[token("USN", ignore(ascii_case))] Usn,
#[token("LOCATION", ignore(ascii_case))] Location,
#[token("REGISTRAR", ignore(ascii_case))] Registrar,
#[token("PROTO_ID", ignore(ascii_case))] ProtoId,
#[token("UNITID", ignore(ascii_case))] UnitId,
#[token("FUNC", ignore(ascii_case))] Func,
#[token("READ_COILS", ignore(ascii_case))] ReadCoils,
#[token("READ_DISCRETE_INPUTS", ignore(ascii_case))] ReadDiscreteInputs,
#[token("READ_HOLDING_REGISTERS", ignore(ascii_case))] ReadHoldingRegisters,
#[token("READ_INPUT_REGISTERS", ignore(ascii_case))] ReadInputRegisters,
#[token("WRITE_SINGLE_COIL", ignore(ascii_case))] WriteSingleCoil,
#[token("WRITE_SINGLE_REGISTER", ignore(ascii_case))] WriteSingleRegister,
#[token("WRITE_MULTIPLE_REGISTERS", ignore(ascii_case))] WriteMultipleRegisters,
#[token("ADDR", ignore(ascii_case))] Addr,
#[token("COUNT", ignore(ascii_case))] Count,
#[token("IS_RESPONSE", ignore(ascii_case))] IsResponse,
#[token("WHO_IS", ignore(ascii_case))] WhoIs,
#[token("I_AM", ignore(ascii_case))] IAm,
#[token("READ_PROPERTY", ignore(ascii_case))] ReadProperty,
#[token("WRITE_PROPERTY", ignore(ascii_case))] WriteProperty,
#[token("INVOKE_ID", ignore(ascii_case))] InvokeId,
#[token("OBJECT_TYPE", ignore(ascii_case))] ObjectType,
#[token("OBJECT_INSTANCE", ignore(ascii_case))] ObjectInstance,
#[token("PROPERTY_ID", ignore(ascii_case))] PropertyId,
#[token("CONFIRM", ignore(ascii_case))] Confirm,
#[token("SELECT", ignore(ascii_case))] Select,
#[token("OPERATE", ignore(ascii_case))] Operate,
#[token("DIRECT_OPERATE", ignore(ascii_case))] DirectOperate,
#[token("UNSOLICITED_RESPONSE", ignore(ascii_case))] UnsolicitedResponse,
#[token("VARIATION", ignore(ascii_case))] Variation,
#[token("CRC", ignore(ascii_case))] Crc,
#[token("SRC", ignore(ascii_case))] Src,
#[token("DST", ignore(ascii_case))] Dst,
#[token("ROSCTR", ignore(ascii_case))] Rosctr,
#[token("PDU_REF", ignore(ascii_case))] PduRef,
#[token("SETUP_COMM", ignore(ascii_case))] SetupComm,
#[token("READ_VAR", ignore(ascii_case))] ReadVar,
#[token("WRITE_VAR", ignore(ascii_case))] WriteVar,
#[token("PLC_CONTROL", ignore(ascii_case))] PlcControl,
#[token("AREA", ignore(ascii_case))] Area,
#[token("DB_NUM", ignore(ascii_case))] DbNum,
#[token("OFFSET", ignore(ascii_case))] Offset,
#[token("LIST_SERVICES", ignore(ascii_case))] ListServices,
#[token("LIST_IDENTITY", ignore(ascii_case))] ListIdentity,
#[token("LIST_INTERFACES", ignore(ascii_case))] ListInterfaces,
#[token("REGISTER_SESSION", ignore(ascii_case))] RegisterSession,
#[token("UNREGISTER_SESSION", ignore(ascii_case))] UnregisterSession,
#[token("SEND_RR_DATA", ignore(ascii_case))] SendRrData,
#[token("SEND_UNIT_DATA", ignore(ascii_case))] SendUnitData,
#[token("SESSION_HANDLE", ignore(ascii_case))] SessionHandle,
#[token("CONTEXT", ignore(ascii_case))] ContextVal,
#[token("CIP_SERVICE", ignore(ascii_case))] CipService,
#[token("CIP_CLASS", ignore(ascii_case))] CipClass,
#[token("CIP_INSTANCE", ignore(ascii_case))] CipInstance,
#[token("CIP_ATTR", ignore(ascii_case))] CipAttr,
#[token("CHUNK_TYPE", ignore(ascii_case))] ChunkType,
#[token("SECURE_CHANNEL_ID", ignore(ascii_case))] SecureChannelId,
#[token("TOKEN_ID", ignore(ascii_case))] TokenId,
#[token("SEQ_NUM", ignore(ascii_case))] SeqNum,
#[token("ENDPOINT_URL", ignore(ascii_case))] EndpointUrl,
#[token("NODE_ID", ignore(ascii_case))] NodeId,
#[token("->")] RightArrow,
#[token("<-")] LeftArrow,
#[token("{")] LBrace,
#[token("}")] RBrace,
#[token("(")] LParen,
#[token(")")] RParen,
#[token(",")] Comma,
#[token("ns", priority = 2, ignore(ascii_case))] Ns,
#[token("us", priority = 2, ignore(ascii_case))] Us,
#[token("ms", priority = 2, ignore(ascii_case))] Ms,
#[token("s", priority = 2, ignore(ascii_case))] Sec,
#[token("m", priority = 2, ignore(ascii_case))] Min,
#[regex("[a-zA-Z_][a-zA-Z0-9_]*", priority = 1)]
Ident(&'a str),
#[regex(r#""([^"\\]|\\.)*""#)]
StringLit(&'a str),
#[regex(r"[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+", priority = 5)]
#[regex(r"::[0-9a-fA-F:.]*|[0-9a-fA-F]{1,4}(:[0-9a-fA-F:.]*)+", priority = 2)]
IpAddress(&'a str),
#[regex(r"([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}", priority = 6)]
#[regex(r"([0-9a-fA-F]{2}-){5}[0-9a-fA-F]{2}", priority = 6)]
#[regex(r"[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}\.[0-9a-fA-F]{4}", priority = 6)]
MacAddress(&'a str),
#[regex(r"\.?[0-9]+(\.[0-9]+)*", priority = 3)]
OidStr(&'a str),
#[regex(r"-?[0-9]+|0[xX][0-9a-fA-F]+", priority = 4)]
Number(&'a str),
}
fn expand_lex_error_span(input: &str, span: std::ops::Range<usize>) -> (usize, usize) {
let start = span.start.min(input.len());
let rest = &input[start..];
let bytes = rest.as_bytes();
let len = if bytes.starts_with(b"/*") || bytes.starts_with(b"*/") {
2
} else if bytes.first() == Some(&b'/') && bytes.get(1).is_some_and(|b| b.is_ascii_digit()) {
1 + bytes[1..].iter().take_while(|b| b.is_ascii_digit()).count()
} else if bytes.first() == Some(&b'\'') {
let line_rest = rest.lines().next().unwrap_or(rest);
if let Some(close_idx) = line_rest.get(1..).and_then(|s| s.find('\'')) {
close_idx + 2
} else {
span.end.saturating_sub(span.start).max(1)
}
} else {
span.end.saturating_sub(span.start).max(1)
};
(start, len)
}
pub fn lex<'a>(
input: &'a str,
) -> Result<alloc::vec::Vec<(Token<'a>, std::ops::Range<usize>)>, crate::error::CompilerError> {
let mut lexer = Token::lexer(input);
let mut tokens = alloc::vec::Vec::new();
while let Some(res) = lexer.next() {
match res {
Ok(token) => tokens.push((token, lexer.span())),
Err(_) => {
return Err(crate::error::CompilerError::LexError {
src: input.to_string(),
span: expand_lex_error_span(input, lexer.span()),
});
}
}
}
Ok(tokens)
}
#[cfg(test)]
mod tests;