Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
GLSL
Go
Haskell
HLSL
Hook
Hylo
IL
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Nim
Objective-C
Objective-C++
OCaml
OpenCL C
Pascal
Pony
Python
Racket
Ruby
Rust
Snowball
Scala
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
TypeScript Native
V
Vala
Visual Basic
WASM
Zig
Javascript
GIMPLE
Ygen
go source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
ARM gc (tip)
ARM gc 1.14
ARM gc 1.15
ARM gc 1.16
ARM gc 1.17
ARM gc 1.18
ARM gc 1.19
ARM gc 1.20
ARM gc 1.21
ARM gc 1.22.1
ARM gc 1.23.2
ARM gccgo 12.2.0
ARM gccgo 12.3.0
ARM gccgo 12.4.0
ARM gccgo 13.1.0
ARM gccgo 13.2.0
ARM gccgo 13.3.0
ARM gccgo 14.1.0
ARM gccgo 14.2.0
ARM64 gc (tip)
ARM64 gc 1.14
ARM64 gc 1.15
ARM64 gc 1.16
ARM64 gc 1.17
ARM64 gc 1.18
ARM64 gc 1.19
ARM64 gc 1.20
ARM64 gc 1.21
ARM64 gc 1.22.1
ARM64 gc 1.23.2
ARM64 gccgo 12.2.0
ARM64 gccgo 12.3.0
ARM64 gccgo 12.4.0
ARM64 gccgo 13.1.0
ARM64 gccgo 13.2.0
ARM64 gccgo 13.3.0
ARM64 gccgo 14.1.0
ARM64 gccgo 14.2.0
MIPS gc (tip)
MIPS gc 1.14
MIPS gc 1.15
MIPS gc 1.16
MIPS gc 1.17
MIPS gc 1.18
MIPS gc 1.19
MIPS gc 1.20
MIPS gc 1.21
MIPS gc 1.22.1
MIPS gc 1.23.2
MIPS gccgo 12.2.0
MIPS gccgo 12.3.0
MIPS gccgo 12.4.0
MIPS gccgo 13.1.0
MIPS gccgo 13.2.0
MIPS gccgo 13.3.0
MIPS gccgo 14.1.0
MIPS gccgo 14.2.0
MIPS64 gc (tip)
MIPS64 gc 1.14
MIPS64 gc 1.15
MIPS64 gc 1.16
MIPS64 gc 1.17
MIPS64 gc 1.18
MIPS64 gc 1.19
MIPS64 gc 1.20
MIPS64 gc 1.21
MIPS64 gc 1.22.1
MIPS64 gc 1.23.2
MIPS64 gccgo 12.2.0
MIPS64 gccgo 12.3.0
MIPS64 gccgo 12.4.0
MIPS64 gccgo 13.1.0
MIPS64 gccgo 13.2.0
MIPS64 gccgo 13.3.0
MIPS64 gccgo 14.1.0
MIPS64 gccgo 14.2.0
MIPS64EL gccgo 12.2.0
MIPS64EL gccgo 12.3.0
MIPS64EL gccgo 12.4.0
MIPS64EL gccgo 13.1.0
MIPS64EL gccgo 13.2.0
MIPS64EL gccgo 13.3.0
MIPS64EL gccgo 14.1.0
MIPS64EL gccgo 14.2.0
MIPS64LE gc (tip)
MIPS64LE gc 1.14
MIPS64LE gc 1.15
MIPS64LE gc 1.16
MIPS64LE gc 1.17
MIPS64LE gc 1.18
MIPS64LE gc 1.19
MIPS64LE gc 1.20
MIPS64LE gc 1.21
MIPS64LE gc 1.22.1
MIPS64LE gc 1.23.2
MIPSEL gccgo 12.2.0
MIPSEL gccgo 12.3.0
MIPSEL gccgo 12.4.0
MIPSEL gccgo 13.1.0
MIPSEL gccgo 13.2.0
MIPSEL gccgo 13.3.0
MIPSEL gccgo 14.1.0
MIPSEL gccgo 14.2.0
MIPSLE gc (tip)
MIPSLE gc 1.14
MIPSLE gc 1.15
MIPSLE gc 1.16
MIPSLE gc 1.17
MIPSLE gc 1.18
MIPSLE gc 1.19
MIPSLE gc 1.20
MIPSLE gc 1.21
MIPSLE gc 1.22.1
MIPSLE gc 1.23.2
POWER gccgo 12.2.0
POWER gccgo 12.3.0
POWER gccgo 12.4.0
POWER gccgo 13.1.0
POWER gccgo 13.2.0
POWER gccgo 13.3.0
POWER gccgo 14.1.0
POWER gccgo 14.2.0
POWER64 gc (tip)
POWER64 gc 1.14
POWER64 gc 1.15
POWER64 gc 1.16
POWER64 gc 1.17
POWER64 gc 1.18
POWER64 gc 1.19
POWER64 gc 1.20
POWER64 gc 1.21
POWER64 gc 1.22.1
POWER64 gc 1.23.2
POWER64 gccgo 12.2.0
POWER64 gccgo 12.3.0
POWER64 gccgo 12.4.0
POWER64 gccgo 13.1.0
POWER64 gccgo 13.2.0
POWER64 gccgo 13.3.0
POWER64 gccgo 14.1.0
POWER64 gccgo 14.2.0
POWER64 gccgo AT12.0
POWER64 gccgo AT13.0
POWER64 gccgo trunk
POWER64LE gc (tip)
POWER64LE gc 1.14
POWER64LE gc 1.15
POWER64LE gc 1.16
POWER64LE gc 1.17
POWER64LE gc 1.18
POWER64LE gc 1.19
POWER64LE gc 1.20
POWER64LE gc 1.21
POWER64LE gc 1.22.1
POWER64LE gc 1.23.2
POWER64LE gccgo 12.2.0
POWER64LE gccgo 12.3.0
POWER64LE gccgo 12.4.0
POWER64LE gccgo 13.1.0
POWER64LE gccgo 13.2.0
POWER64LE gccgo 13.3.0
POWER64LE gccgo 14.1.0
POWER64LE gccgo 14.2.0
POWER64LE gccgo AT12.0
POWER64LE gccgo AT13.0
POWER64LE gccgo trunk
RISC-V 64 gc (tip)
RISC-V 64 gc 1.14
RISC-V 64 gc 1.15
RISC-V 64 gc 1.16
RISC-V 64 gc 1.17
RISC-V 64 gc 1.18
RISC-V 64 gc 1.19
RISC-V 64 gc 1.20
RISC-V 64 gc 1.21
RISC-V 64 gc 1.22.1
RISC-V 64 gc 1.23.2
RISC-V 64 gccgo 12.2.0
RISC-V 64 gccgo 12.3.0
RISC-V 64 gccgo 12.4.0
RISC-V 64 gccgo 13.1.0
RISC-V 64 gccgo 13.2.0
RISC-V 64 gccgo 13.3.0
RISC-V 64 gccgo 14.1.0
RISC-V 64 gccgo 14.2.0
S390X gc (tip)
S390X gc 1.14
S390X gc 1.15
S390X gc 1.16
S390X gc 1.17
S390X gc 1.18
S390X gc 1.19
S390X gc 1.20
S390X gc 1.21
S390X gc 1.22.1
S390X gc 1.23.2
S390X gccgo 12.2.0
S390X gccgo 12.3.0
S390X gccgo 12.4.0
S390X gccgo 13.1.0
S390X gccgo 13.2.0
S390X gccgo 13.3.0
S390X gccgo 14.1.0
S390X gccgo 14.2.0
SPARC gccgo 12.2.0
SPARC gccgo 12.3.0
SPARC gccgo 12.4.0
SPARC gccgo 13.1.0
SPARC gccgo 13.2.0
SPARC gccgo 13.3.0
SPARC gccgo 14.1.0
SPARC gccgo 14.2.0
SPARC64 gccgo 12.2.0
SPARC64 gccgo 12.3.0
SPARC64 gccgo 12.4.0
SPARC64 gccgo 13.1.0
SPARC64 gccgo 13.2.0
SPARC64 gccgo 13.3.0
SPARC64 gccgo 14.1.0
SPARC64 gccgo 14.2.0
WASM gc (tip)
WASM gc 1.14
WASM gc 1.15
WASM gc 1.16
WASM gc 1.17
WASM gc 1.18
WASM gc 1.19
WASM gc 1.20
WASM gc 1.21
WASM gc 1.22.1
WASM gc 1.23.2
x86 gc (tip)
x86 gc 1.14
x86 gc 1.15
x86 gc 1.16
x86 gc 1.17
x86 gc 1.18
x86 gc 1.19
x86 gc 1.20
x86 gc 1.21
x86 gc 1.22.1
x86 gc 1.23.2
x86 gccgo 10.2.0
x86 gccgo 10.5.0
x86 gccgo 11.1.0
x86 gccgo 11.2.0
x86 gccgo 11.3.0
x86 gccgo 11.4.0
x86 gccgo 12.1.0
x86 gccgo 12.2.0
x86 gccgo 12.3.0
x86 gccgo 12.4.0
x86 gccgo 13.1
x86 gccgo 13.2
x86 gccgo 13.3
x86 gccgo 14.1
x86 gccgo 14.2
x86 gccgo 4.9.4
x86 gccgo 6.3.0
x86 gccgo 7.2.0
x86 gccgo 8.3.0
x86 gccgo 9.3.0
x86 gccgo 9.5.0
x86-64 gc (tip)
x86-64 gc 1.10
x86-64 gc 1.10.1
x86-64 gc 1.11
x86-64 gc 1.12
x86-64 gc 1.13
x86-64 gc 1.14
x86-64 gc 1.15
x86-64 gc 1.16
x86-64 gc 1.17
x86-64 gc 1.18
x86-64 gc 1.19
x86-64 gc 1.20
x86-64 gc 1.21
x86-64 gc 1.22.1
x86-64 gc 1.23.2
x86-64 gc 1.4.1
x86-64 gc 1.7.2
x86-64 gc 1.8.5
x86-64 gc 1.8.7
x86-64 gc 1.9.2
x86-64 gc 1.9.4
Options
Source code
// Type your code here, or load an example. // Your function name should start with a capital letter. package main func main() {} func keyword(s string) (Token, string) { switch len(s) { case 2: if s == "if" { return If, "if" } if s == "is" { return Is, "is" } if s == "in" { return In, "in" } if s == "or" { return Or, "or" } if s == "do" { return Do, "do" } case 3: if s == "and" { return And, "and" } if s == "for" { return For, "for" } if s == "not" { return Not, "not" } if s == "new" { return New, "new" } if s == "try" { return Try, "try" } case 4: if s == "true" { return True, "true" } if s == "isnt" { return Isnt, "isnt" } if s == "else" { return Else, "else" } if s == "this" { return This, "this" } if s == "case" { return Case, "case" } case 5: if s == "false" { return False, "false" } if s == "super" { return Super, "super" } if s == "class" { return Class, "class" } if s == "throw" { return Throw, "throw" } if s == "catch" { return Catch, "catch" } if s == "while" { return While, "while" } if s == "break" { return Break, "break" } case 6: if s == "return" { return Return, "return" } if s == "switch" { return Switch, "switch" } case 7: if s == "default" { return Default, "default" } if s == "forever" { return Forever, "forever" } case 8: // function, continue if s == "function" { return Function, "function" } if s == "continue" { return Continue, "continue" } } return Identifier, s } type Token uint8 const ( Nil Token = iota Eof Error Identifier Number String // Symbol is a #identifier string Symbol Whitespace Comment Newline // punctuation Hash Comma Semicolon At LParen RParen LBracket RBracket LCurly RCurly RangeTo RangeLen OpsStart // operators Not BitNot New Dot CompareStart // must be consecutive Is Isnt Match MatchNot Lt // must be consecutive Lte Gt Gte CompareEnd QMark Colon AssocStart // must be consecutive And Or BitOr BitAnd BitXor Add Sub Cat Mul Div AssocEnd Mod LShift RShift IncDecStart Inc PostInc Dec PostDec IncDecEnd AssignStart // must be consecutive Eq AddEq SubEq CatEq MulEq DivEq ModEq LShiftEq RShiftEq BitOrEq BitAndEq BitXorEq AssignEnd In // other language keywords Break Case Catch Class Continue Default Do Else False For Forever Function If Return Switch Super This Throw True Try While // query keywords QueryStart SummarizeStart Average Count List Max Min Total SummarizeEnd Alter By Cascade Create Delete Drop Ensure Extend History Index Insert Intersect Into Join Key Leftjoin Lower Minus Project Remove Rename Reverse Set Sort Summarize Sview TempIndex Times To Union Unique Update View Where Ntokens )
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
About the author
Statistics
Changelog
Version tree