diff options
-rw-r--r-- | pygments/lexers/_julia_builtins.py | 401 | ||||
-rw-r--r-- | pygments/lexers/_mapping.py | 2 | ||||
-rw-r--r-- | pygments/lexers/julia.py | 318 | ||||
-rw-r--r-- | tests/examplefiles/julia/string.jl | 1311 | ||||
-rw-r--r-- | tests/examplefiles/julia/string.jl.output | 11660 | ||||
-rw-r--r-- | tests/snippets/julia-repl/test_repl.txt | 51 | ||||
-rw-r--r-- | tests/snippets/julia/test_keywords.txt | 89 | ||||
-rw-r--r-- | tests/snippets/julia/test_macros.txt | 56 | ||||
-rw-r--r-- | tests/snippets/julia/test_names.txt | 148 | ||||
-rw-r--r-- | tests/snippets/julia/test_numbers.txt | 261 | ||||
-rw-r--r-- | tests/snippets/julia/test_operators.txt | 172 | ||||
-rw-r--r-- | tests/snippets/julia/test_strings.txt | 225 | ||||
-rw-r--r-- | tests/snippets/julia/test_symbols.txt | 78 | ||||
-rw-r--r-- | tests/snippets/julia/test_types.txt | 196 |
14 files changed, 3968 insertions, 11000 deletions
diff --git a/pygments/lexers/_julia_builtins.py b/pygments/lexers/_julia_builtins.py new file mode 100644 index 00000000..c1dcca09 --- /dev/null +++ b/pygments/lexers/_julia_builtins.py @@ -0,0 +1,401 @@ +# operators +# see https://github.com/JuliaLang/julia/blob/master/src/julia-parser.scm +# Julia v1.6.0-rc1 +OPERATORS_LIST = [ + # other + '->', + # prec-assignment + ':=', '$=', + # prec-conditional, prec-lazy-or, prec-lazy-and + '?', '||', '&&', + # prec-colon + ':', + # prec-plus + '$', + # prec-decl + '::', +] +DOTTED_OPERATORS_LIST = [ + # prec-assignment + r'=', r'+=', r'-=', r'*=', r'/=', r'//=', r'\=', r'^=', r'÷=', r'%=', r'<<=', + r'>>=', r'>>>=', r'|=', r'&=', r'⊻=', r'≔', r'⩴', r"≕'", r'~', + # prec-pair + '=>', + # prec-arrow + r'→', r'↔', r'↚', r'↛', r'↞', r'↠', r'↢', r'↣', r'↦', r'↤', r'↮', r'⇎', r'⇍', r'⇏', + r'⇐', r'⇒', r'⇔', r'⇴', r'⇶', r'⇷', r'⇸', r'⇹', r'⇺', r'⇻', r'⇼', r'⇽', r'⇾', r'⇿', + r'⟵', r'⟶', r'⟷', r'⟹', r'⟺', r'⟻', r'⟼', r'⟽', r'⟾', r'⟿', r'⤀', r'⤁', r'⤂', r'⤃', + r'⤄', r'⤅', r'⤆', r'⤇', r'⤌', r'⤍', r'⤎', r'⤏', r'⤐', r'⤑', r'⤔', r'⤕', r'⤖', r'⤗', + r'⤘', r'⤝', r'⤞', r'⤟', r'⤠', r'⥄', r'⥅', r'⥆', r'⥇', r'⥈', r'⥊', r'⥋', r'⥎', r'⥐', + r'⥒', r'⥓', r'⥖', r'⥗', r'⥚', r'⥛', r'⥞', r'⥟', r'⥢', r'⥤', r'⥦', r'⥧', r'⥨', r'⥩', + r'⥪', r'⥫', r'⥬', r'⥭', r'⥰', r'⧴', r'⬱', r'⬰', r'⬲', r'⬳', r'⬴', r'⬵', r'⬶', r'⬷', + r'⬸', r'⬹', r'⬺', r'⬻', r'⬼', r'⬽', r'⬾', r'⬿', r'⭀', r'⭁', r'⭂', r'⭃', r'⭄', r'⭇', + r'⭈', r'⭉', r'⭊', r'⭋', r'⭌', r'←', r'→', r'⇜', r'⇝', r'↜', r'↝', r'↩', r'↪', r'↫', + r'↬', r'↼', r'↽', r'⇀', r'⇁', r'⇄', r'⇆', r'⇇', r'⇉', r'⇋', r'⇌', r'⇚', r'⇛', r'⇠', + r'⇢', r'↷', r'↶', r'↺', r'↻', r'-->', r'<--', r'<-->', + # prec-comparison + r'>', r'<', r'>=', r'≥', r'<=', r'≤', r'==', r'===', r'≡', r'!=', r'≠', r'!==', + r'≢', r'∈', r'∉', r'∋', r'∌', r'⊆', r'⊈', r'⊂', r'⊄', r'⊊', r'∝', r'∊', r'∍', r'∥', + r'∦', r'∷', r'∺', r'∻', r'∽', r'∾', r'≁', r'≃', r'≂', r'≄', r'≅', r'≆', r'≇', r'≈', + r'≉', r'≊', r'≋', r'≌', r'≍', r'≎', r'≐', r'≑', r'≒', r'≓', r'≖', r'≗', r'≘', r'≙', + r'≚', r'≛', r'≜', r'≝', r'≞', r'≟', r'≣', r'≦', r'≧', r'≨', r'≩', r'≪', r'≫', r'≬', + r'≭', r'≮', r'≯', r'≰', r'≱', r'≲', r'≳', r'≴', r'≵', r'≶', r'≷', r'≸', r'≹', r'≺', + r'≻', r'≼', r'≽', r'≾', r'≿', r'⊀', r'⊁', r'⊃', r'⊅', r'⊇', r'⊉', r'⊋', r'⊏', r'⊐', + r'⊑', r'⊒', r'⊜', r'⊩', r'⊬', r'⊮', r'⊰', r'⊱', r'⊲', r'⊳', r'⊴', r'⊵', r'⊶', r'⊷', + r'⋍', r'⋐', r'⋑', r'⋕', r'⋖', r'⋗', r'⋘', r'⋙', r'⋚', r'⋛', r'⋜', r'⋝', r'⋞', r'⋟', + r'⋠', r'⋡', r'⋢', r'⋣', r'⋤', r'⋥', r'⋦', r'⋧', r'⋨', r'⋩', r'⋪', r'⋫', r'⋬', r'⋭', + r'⋲', r'⋳', r'⋴', r'⋵', r'⋶', r'⋷', r'⋸', r'⋹', r'⋺', r'⋻', r'⋼', r'⋽', r'⋾', r'⋿', + r'⟈', r'⟉', r'⟒', r'⦷', r'⧀', r'⧁', r'⧡', r'⧣', r'⧤', r'⧥', r'⩦', r'⩧', r'⩪', r'⩫', + r'⩬', r'⩭', r'⩮', r'⩯', r'⩰', r'⩱', r'⩲', r'⩳', r'⩵', r'⩶', r'⩷', r'⩸', r'⩹', r'⩺', + r'⩻', r'⩼', r'⩽', r'⩾', r'⩿', r'⪀', r'⪁', r'⪂', r'⪃', r'⪄', r'⪅', r'⪆', r'⪇', r'⪈', + r'⪉', r'⪊', r'⪋', r'⪌', r'⪍', r'⪎', r'⪏', r'⪐', r'⪑', r'⪒', r'⪓', r'⪔', r'⪕', r'⪖', + r'⪗', r'⪘', r'⪙', r'⪚', r'⪛', r'⪜', r'⪝', r'⪞', r'⪟', r'⪠', r'⪡', r'⪢', r'⪣', r'⪤', + r'⪥', r'⪦', r'⪧', r'⪨', r'⪩', r'⪪', r'⪫', r'⪬', r'⪭', r'⪮', r'⪯', r'⪰', r'⪱', r'⪲', + r'⪳', r'⪴', r'⪵', r'⪶', r'⪷', r'⪸', r'⪹', r'⪺', r'⪻', r'⪼', r'⪽', r'⪾', r'⪿', r'⫀', + r'⫁', r'⫂', r'⫃', r'⫄', r'⫅', r'⫆', r'⫇', r'⫈', r'⫉', r'⫊', r'⫋', r'⫌', r'⫍', r'⫎', + r'⫏', r'⫐', r'⫑', r'⫒', r'⫓', r'⫔', r'⫕', r'⫖', r'⫗', r'⫘', r'⫙', r'⫷', r'⫸', r'⫹', + r'⫺', r'⊢', r'⊣', r'⟂', r'<:', r'>:', + # prec-pipe + '<|', '|>', + # prec-colon + r'…', r'⁝', r'⋮', r'⋱', r'⋰', r'⋯', + # prec-plus + r'+', r'-', r'¦', r'|', r'⊕', r'⊖', r'⊞', r'⊟', r'++', r'∪', r'∨', r'⊔', r'±', r'∓', + r'∔', r'∸', r'≏', r'⊎', r'⊻', r'⊽', r'⋎', r'⋓', r'⧺', r'⧻', r'⨈', r'⨢', r'⨣', r'⨤', + r'⨥', r'⨦', r'⨧', r'⨨', r'⨩', r'⨪', r'⨫', r'⨬', r'⨭', r'⨮', r'⨹', r'⨺', r'⩁', r'⩂', + r'⩅', r'⩊', r'⩌', r'⩏', r'⩐', r'⩒', r'⩔', r'⩖', r'⩗', r'⩛', r'⩝', r'⩡', r'⩢', r'⩣', + # prec-times + r'*', r'/', r'⌿', r'÷', r'%', r'&', r'⋅', r'∘', r'×', '\\', r'∩', r'∧', r'⊗', r'⊘', + r'⊙', r'⊚', r'⊛', r'⊠', r'⊡', r'⊓', r'∗', r'∙', r'∤', r'⅋', r'≀', r'⊼', r'⋄', r'⋆', + r'⋇', r'⋉', r'⋊', r'⋋', r'⋌', r'⋏', r'⋒', r'⟑', r'⦸', r'⦼', r'⦾', r'⦿', r'⧶', r'⧷', + r'⨇', r'⨰', r'⨱', r'⨲', r'⨳', r'⨴', r'⨵', r'⨶', r'⨷', r'⨸', r'⨻', r'⨼', r'⨽', r'⩀', + r'⩃', r'⩄', r'⩋', r'⩍', r'⩎', r'⩑', r'⩓', r'⩕', r'⩘', r'⩚', r'⩜', r'⩞', r'⩟', r'⩠', + r'⫛', r'⊍', r'▷', r'⨝', r'⟕', r'⟖', r'⟗', r'⨟', + # prec-rational, prec-bitshift + '//', '>>', '<<', '>>>', + # prec-power + r'^', r'↑', r'↓', r'⇵', r'⟰', r'⟱', r'⤈', r'⤉', r'⤊', r'⤋', r'⤒', r'⤓', r'⥉', r'⥌', + r'⥍', r'⥏', r'⥑', r'⥔', r'⥕', r'⥘', r'⥙', r'⥜', r'⥝', r'⥠', r'⥡', r'⥣', r'⥥', r'⥮', + r'⥯', r'↑', r'↓', + # unary-ops, excluding unary-and-binary-ops + '!', r'¬', r'√', r'∛', r'∜' +] + +# Generated with the following in Julia v1.6.0-rc1 +''' +#!/usr/bin/env julia + +import REPL.REPLCompletions +res = String["in", "isa", "where"] +for kw in collect(x.keyword for x in REPLCompletions.complete_keyword("")) + if !(contains(kw, " ") || kw == "struct") + push!(res, kw) + end +end +sort!(unique!(setdiff!(res, ["true", "false"]))) +foreach(x -> println("\'", x, "\',"), res) +''' +KEYWORD_LIST = ( + 'baremodule', + 'begin', + 'break', + 'catch', + 'ccall', + 'const', + 'continue', + 'do', + 'else', + 'elseif', + 'end', + 'export', + 'finally', + 'for', + 'function', + 'global', + 'if', + 'import', + 'in', + 'isa', + 'let', + 'local', + 'macro', + 'module', + 'quote', + 'return', + 'try', + 'using', + 'where', + 'while', +) + +# Generated with the following in Julia v1.6.0-rc1 +''' +#!/usr/bin/env julia + +import REPL.REPLCompletions +res = String[] +for compl in filter!(x -> isa(x, REPLCompletions.ModuleCompletion) && (x.parent === Base || x.parent === Core), + REPLCompletions.completions("", 0)[1]) + try + v = eval(Symbol(compl.mod)) + if (v isa Type || v isa TypeVar) && (compl.mod != "=>") + push!(res, compl.mod) + end + catch e + end +end +sort!(unique!(res)) +foreach(x -> println("\'", x, "\',"), res) +''' +BUILTIN_LIST = ( + 'AbstractArray', + 'AbstractChannel', + 'AbstractChar', + 'AbstractDict', + 'AbstractDisplay', + 'AbstractFloat', + 'AbstractIrrational', + 'AbstractMatch', + 'AbstractMatrix', + 'AbstractPattern', + 'AbstractRange', + 'AbstractSet', + 'AbstractString', + 'AbstractUnitRange', + 'AbstractVecOrMat', + 'AbstractVector', + 'Any', + 'ArgumentError', + 'Array', + 'AssertionError', + 'BigFloat', + 'BigInt', + 'BitArray', + 'BitMatrix', + 'BitSet', + 'BitVector', + 'Bool', + 'BoundsError', + 'CapturedException', + 'CartesianIndex', + 'CartesianIndices', + 'Cchar', + 'Cdouble', + 'Cfloat', + 'Channel', + 'Char', + 'Cint', + 'Cintmax_t', + 'Clong', + 'Clonglong', + 'Cmd', + 'Colon', + 'Complex', + 'ComplexF16', + 'ComplexF32', + 'ComplexF64', + 'ComposedFunction', + 'CompositeException', + 'Condition', + 'Cptrdiff_t', + 'Cshort', + 'Csize_t', + 'Cssize_t', + 'Cstring', + 'Cuchar', + 'Cuint', + 'Cuintmax_t', + 'Culong', + 'Culonglong', + 'Cushort', + 'Cvoid', + 'Cwchar_t', + 'Cwstring', + 'DataType', + 'DenseArray', + 'DenseMatrix', + 'DenseVecOrMat', + 'DenseVector', + 'Dict', + 'DimensionMismatch', + 'Dims', + 'DivideError', + 'DomainError', + 'EOFError', + 'Enum', + 'ErrorException', + 'Exception', + 'ExponentialBackOff', + 'Expr', + 'Float16', + 'Float32', + 'Float64', + 'Function', + 'GlobalRef', + 'HTML', + 'IO', + 'IOBuffer', + 'IOContext', + 'IOStream', + 'IdDict', + 'IndexCartesian', + 'IndexLinear', + 'IndexStyle', + 'InexactError', + 'InitError', + 'Int', + 'Int128', + 'Int16', + 'Int32', + 'Int64', + 'Int8', + 'Integer', + 'InterruptException', + 'InvalidStateException', + 'Irrational', + 'KeyError', + 'LinRange', + 'LineNumberNode', + 'LinearIndices', + 'LoadError', + 'MIME', + 'Matrix', + 'Method', + 'MethodError', + 'Missing', + 'MissingException', + 'Module', + 'NTuple', + 'NamedTuple', + 'Nothing', + 'Number', + 'OrdinalRange', + 'OutOfMemoryError', + 'OverflowError', + 'Pair', + 'PartialQuickSort', + 'PermutedDimsArray', + 'Pipe', + 'ProcessFailedException', + 'Ptr', + 'QuoteNode', + 'Rational', + 'RawFD', + 'ReadOnlyMemoryError', + 'Real', + 'ReentrantLock', + 'Ref', + 'Regex', + 'RegexMatch', + 'RoundingMode', + 'SegmentationFault', + 'Set', + 'Signed', + 'Some', + 'StackOverflowError', + 'StepRange', + 'StepRangeLen', + 'StridedArray', + 'StridedMatrix', + 'StridedVecOrMat', + 'StridedVector', + 'String', + 'StringIndexError', + 'SubArray', + 'SubString', + 'SubstitutionString', + 'Symbol', + 'SystemError', + 'Task', + 'TaskFailedException', + 'Text', + 'TextDisplay', + 'Timer', + 'Tuple', + 'Type', + 'TypeError', + 'TypeVar', + 'UInt', + 'UInt128', + 'UInt16', + 'UInt32', + 'UInt64', + 'UInt8', + 'UndefInitializer', + 'UndefKeywordError', + 'UndefRefError', + 'UndefVarError', + 'Union', + 'UnionAll', + 'UnitRange', + 'Unsigned', + 'Val', + 'Vararg', + 'VecElement', + 'VecOrMat', + 'Vector', + 'VersionNumber', + 'WeakKeyDict', + 'WeakRef', +) + +# Generated with the following in Julia v1.6.0-rc1 +''' +#!/usr/bin/env julia + +import REPL.REPLCompletions +res = String["true", "false"] +for compl in filter!(x -> isa(x, REPLCompletions.ModuleCompletion) && (x.parent === Base || x.parent === Core), + REPLCompletions.completions("", 0)[1]) + try + v = eval(Symbol(compl.mod)) + if !(v isa Function || v isa Type || v isa TypeVar || v isa Module || v isa Colon) + push!(res, compl.mod) + end + catch e + end +end +sort!(unique!(res)) +foreach(x -> println("\'", x, "\',"), res) +''' +LITERAL_LIST = ( + 'ARGS', + 'C_NULL', + 'DEPOT_PATH', + 'ENDIAN_BOM', + 'ENV', + 'Inf', + 'Inf16', + 'Inf32', + 'Inf64', + 'InsertionSort', + 'LOAD_PATH', + 'MergeSort', + 'NaN', + 'NaN16', + 'NaN32', + 'NaN64', + 'PROGRAM_FILE', + 'QuickSort', + 'RoundDown', + 'RoundFromZero', + 'RoundNearest', + 'RoundNearestTiesAway', + 'RoundNearestTiesUp', + 'RoundToZero', + 'RoundUp', + 'VERSION', + 'devnull', + 'false', + 'im', + 'missing', + 'nothing', + 'pi', + 'stderr', + 'stdin', + 'stdout', + 'true', + 'undef', + 'π', + 'ℯ', +) diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 45bbde26..a1d5cb5d 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -235,7 +235,7 @@ LEXERS = { 'JsonLdLexer': ('pygments.lexers.data', 'JSON-LD', ('jsonld', 'json-ld'), ('*.jsonld',), ('application/ld+json',)), 'JsonLexer': ('pygments.lexers.data', 'JSON', ('json', 'json-object'), ('*.json', 'Pipfile.lock'), ('application/json', 'application/json-object')), 'JspLexer': ('pygments.lexers.templates', 'Java Server Page', ('jsp',), ('*.jsp',), ('application/x-jsp',)), - 'JuliaConsoleLexer': ('pygments.lexers.julia', 'Julia console', ('jlcon',), (), ()), + 'JuliaConsoleLexer': ('pygments.lexers.julia', 'Julia console', ('jlcon', 'julia-repl'), (), ()), 'JuliaLexer': ('pygments.lexers.julia', 'Julia', ('julia', 'jl'), ('*.jl',), ('text/x-julia', 'application/x-julia')), 'JuttleLexer': ('pygments.lexers.javascript', 'Juttle', ('juttle',), ('*.juttle',), ('application/juttle', 'application/x-juttle', 'text/x-juttle', 'text/juttle')), 'KalLexer': ('pygments.lexers.javascript', 'Kal', ('kal',), ('*.kal',), ('text/kal', 'application/kal')), diff --git a/pygments/lexers/julia.py b/pygments/lexers/julia.py index be8c1333..390d5d71 100644 --- a/pygments/lexers/julia.py +++ b/pygments/lexers/julia.py @@ -15,12 +15,16 @@ from pygments.lexer import Lexer, RegexLexer, bygroups, do_insertions, \ from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Generic from pygments.util import shebang_matches +from pygments.lexers._julia_builtins import OPERATORS_LIST, DOTTED_OPERATORS_LIST, \ + KEYWORD_LIST, BUILTIN_LIST, LITERAL_LIST __all__ = ['JuliaLexer', 'JuliaConsoleLexer'] +# see https://docs.julialang.org/en/v1/manual/variables/#Allowed-Variable-Names allowed_variable = \ - '(?:[a-zA-Z_\u00A1-\U0010ffff]|%s)(?:[a-zA-Z_0-9\u00A1-\U0010ffff])*!*' - + '(?:[a-zA-Z_\u00A1-\U0010ffff][a-zA-Z_0-9!\u00A1-\U0010ffff]*)' +# see https://github.com/JuliaLang/julia/blob/master/src/flisp/julia_opsuffs.h +operator_suffixes = r'[²³¹ʰʲʳʷʸˡˢˣᴬᴮᴰᴱᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾᴿᵀᵁᵂᵃᵇᵈᵉᵍᵏᵐᵒᵖᵗᵘᵛᵝᵞᵟᵠᵡᵢᵣᵤᵥᵦᵧᵨᵩᵪᶜᶠᶥᶦᶫᶰᶸᶻᶿ′″‴‵‶‷⁗⁰ⁱ⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾ⁿ₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎ₐₑₒₓₕₖₗₘₙₚₛₜⱼⱽ]*' class JuliaLexer(RegexLexer): """ @@ -42,21 +46,35 @@ class JuliaLexer(RegexLexer): (r'[^\S\n]+', Text), (r'#=', Comment.Multiline, "blockcomment"), (r'#.*$', Comment), - (r'[\[\]{}(),;]', Punctuation), + (r'[\[\](),;]', Punctuation), + + # symbols + # intercept range expressions first + (r'(' + allowed_variable + r')(\s*)(:)(' + allowed_variable + ')', + bygroups(Name, Text, Operator, Name)), + # then match :name which does not follow closing brackets, digits, or the + # ::, <:, and :> operators + (r'(?<![\]):<>\d.])(:' + allowed_variable + ')', String.Symbol), + + # type assertions - excludes expressions like ::typeof(sin) and ::avec[1] + (r'(?<=::)(\s*)(' + allowed_variable + r')\b(?![(\[])', bygroups(Text, Keyword.Type)), + # type comparisons + # - MyType <: A or MyType >: A + ('(' + allowed_variable + r')(\s*)([<>]:)(\s*)(' + allowed_variable + r')\b(?![(\[])', + bygroups(Keyword.Type, Text, Operator, Text, Keyword.Type)), + # - <: B or >: B + (r'([<>]:)(\s*)(' + allowed_variable + r')\b(?![(\[])', + bygroups(Operator, Text, Keyword.Type)), + # - A <: or A >: + (r'\b(' + allowed_variable + r')(\s*)([<>]:)', + bygroups(Keyword.Type, Text, Operator)), - # keywords - (r'in\b', Keyword.Pseudo), - (r'isa\b', Keyword.Pseudo), - (r'(true|false)\b', Keyword.Constant), - (r'(local|global|const)\b', Keyword.Declaration), - (words([ - 'function', 'type', 'typealias', 'abstract', 'immutable', - 'baremodule', 'begin', 'bitstype', 'break', 'catch', 'ccall', - 'continue', 'do', 'else', 'elseif', 'end', 'export', 'finally', - 'for', 'if', 'import', 'importall', 'let', 'macro', 'module', - 'mutable', 'primitive', 'quote', 'return', 'struct', 'try', - 'using', 'while'], - suffix=r'\b'), Keyword), + # operators + # Suffixes aren't actually allowed on all operators, but we'll ignore that + # since those cases are invalid Julia code. + (words([*OPERATORS_LIST, *DOTTED_OPERATORS_LIST], suffix=operator_suffixes), Operator), + (words(['.' + o for o in DOTTED_OPERATORS_LIST], suffix=operator_suffixes), Operator), + (words(['...', '..']), Operator), # NOTE # Patterns below work only for definition sites and thus hardly reliable. @@ -64,160 +82,67 @@ class JuliaLexer(RegexLexer): # functions # (r'(function)(\s+)(' + allowed_variable + ')', # bygroups(Keyword, Text, Name.Function)), - # - # types - # (r'(type|typealias|abstract|immutable)(\s+)(' + allowed_variable + ')', - # bygroups(Keyword, Text, Name.Class)), - - # type names - (words([ - 'ANY', 'ASCIIString', 'AbstractArray', 'AbstractChannel', - 'AbstractFloat', 'AbstractMatrix', 'AbstractRNG', - 'AbstractSparseArray', 'AbstractSparseMatrix', - 'AbstractSparseVector', 'AbstractString', 'AbstractVecOrMat', - 'AbstractVector', 'Any', 'ArgumentError', 'Array', - 'AssertionError', 'Associative', 'Base64DecodePipe', - 'Base64EncodePipe', 'Bidiagonal', 'BigFloat', 'BigInt', - 'BitArray', 'BitMatrix', 'BitVector', 'Bool', 'BoundsError', - 'Box', 'BufferStream', 'CapturedException', 'CartesianIndex', - 'CartesianRange', 'Cchar', 'Cdouble', 'Cfloat', 'Channel', - 'Char', 'Cint', 'Cintmax_t', 'Clong', 'Clonglong', - 'ClusterManager', 'Cmd', 'Coff_t', 'Colon', 'Complex', - 'Complex128', 'Complex32', 'Complex64', 'CompositeException', - 'Condition', 'Cptrdiff_t', 'Cshort', 'Csize_t', 'Cssize_t', - 'Cstring', 'Cuchar', 'Cuint', 'Cuintmax_t', 'Culong', - 'Culonglong', 'Cushort', 'Cwchar_t', 'Cwstring', 'DataType', - 'Date', 'DateTime', 'DenseArray', 'DenseMatrix', - 'DenseVecOrMat', 'DenseVector', 'Diagonal', 'Dict', - 'DimensionMismatch', 'Dims', 'DirectIndexString', 'Display', - 'DivideError', 'DomainError', 'EOFError', 'EachLine', 'Enum', - 'Enumerate', 'ErrorException', 'Exception', 'Expr', - 'Factorization', 'FileMonitor', 'FileOffset', 'Filter', - 'Float16', 'Float32', 'Float64', 'FloatRange', 'Function', - 'GenSym', 'GlobalRef', 'GotoNode', 'HTML', 'Hermitian', 'IO', - 'IOBuffer', 'IOStream', 'IPv4', 'IPv6', 'InexactError', - 'InitError', 'Int', 'Int128', 'Int16', 'Int32', 'Int64', 'Int8', - 'IntSet', 'Integer', 'InterruptException', 'IntrinsicFunction', - 'InvalidStateException', 'Irrational', 'KeyError', 'LabelNode', - 'LambdaStaticData', 'LinSpace', 'LineNumberNode', 'LoadError', - 'LocalProcess', 'LowerTriangular', 'MIME', 'Matrix', - 'MersenneTwister', 'Method', 'MethodError', 'MethodTable', - 'Module', 'NTuple', 'NewvarNode', 'NullException', 'Nullable', - 'Number', 'ObjectIdDict', 'OrdinalRange', 'OutOfMemoryError', - 'OverflowError', 'Pair', 'ParseError', 'PartialQuickSort', - 'Pipe', 'PollingFileWatcher', 'ProcessExitedException', - 'ProcessGroup', 'Ptr', 'QuoteNode', 'RandomDevice', 'Range', - 'Rational', 'RawFD', 'ReadOnlyMemoryError', 'Real', - 'ReentrantLock', 'Ref', 'Regex', 'RegexMatch', - 'RemoteException', 'RemoteRef', 'RepString', 'RevString', - 'RopeString', 'RoundingMode', 'SegmentationFault', - 'SerializationState', 'Set', 'SharedArray', 'SharedMatrix', - 'SharedVector', 'Signed', 'SimpleVector', 'SparseMatrixCSC', - 'StackOverflowError', 'StatStruct', 'StepRange', 'StridedArray', - 'StridedMatrix', 'StridedVecOrMat', 'StridedVector', 'SubArray', - 'SubString', 'SymTridiagonal', 'Symbol', 'SymbolNode', - 'Symmetric', 'SystemError', 'TCPSocket', 'Task', 'Text', - 'TextDisplay', 'Timer', 'TopNode', 'Tridiagonal', 'Tuple', - 'Type', 'TypeConstructor', 'TypeError', 'TypeName', 'TypeVar', - 'UDPSocket', 'UInt', 'UInt128', 'UInt16', 'UInt32', 'UInt64', - 'UInt8', 'UTF16String', 'UTF32String', 'UTF8String', - 'UndefRefError', 'UndefVarError', 'UnicodeError', 'UniformScaling', - 'Union', 'UnitRange', 'Unsigned', 'UpperTriangular', 'Val', - 'Vararg', 'VecOrMat', 'Vector', 'VersionNumber', 'Void', 'WString', - 'WeakKeyDict', 'WeakRef', 'WorkerConfig', 'Zip'], suffix=r'\b'), - Keyword.Type), - - # builtins - (words([ - 'ARGS', 'CPU_CORES', 'C_NULL', 'DevNull', 'ENDIAN_BOM', - 'ENV', 'I', 'Inf', 'Inf16', 'Inf32', 'Inf64', - 'InsertionSort', 'JULIA_HOME', 'LOAD_PATH', 'MergeSort', - 'NaN', 'NaN16', 'NaN32', 'NaN64', 'OS_NAME', - 'QuickSort', 'RoundDown', 'RoundFromZero', 'RoundNearest', - 'RoundNearestTiesAway', 'RoundNearestTiesUp', - 'RoundToZero', 'RoundUp', 'STDERR', 'STDIN', 'STDOUT', - 'VERSION', 'WORD_SIZE', 'catalan', 'e', 'eu', - 'eulergamma', 'golden', 'im', 'nothing', 'pi', 'γ', 'π', 'φ'], - suffix=r'\b'), Name.Builtin), - - # operators - # see: https://github.com/JuliaLang/julia/blob/master/src/julia-parser.scm - (words(( - # prec-assignment - '=', ':=', '+=', '-=', '*=', '/=', '//=', './/=', '.*=', './=', - '\\=', '.\\=', '^=', '.^=', '÷=', '.÷=', '%=', '.%=', '|=', '&=', - '$=', '=>', '<<=', '>>=', '>>>=', '~', '.+=', '.-=', - # prec-conditional - '?', - # prec-arrow - '--', '-->', - # prec-lazy-or - '||', - # prec-lazy-and - '&&', - # prec-comparison - '>', '<', '>=', '≥', '<=', '≤', '==', '===', '≡', '!=', '≠', - '!==', '≢', '.>', '.<', '.>=', '.≥', '.<=', '.≤', '.==', '.!=', - '.≠', '.=', '.!', '<:', '>:', '∈', '∉', '∋', '∌', '⊆', - '⊈', '⊂', - '⊄', '⊊', - # prec-pipe - '|>', '<|', - # prec-colon - ':', - # prec-plus - '.+', '.-', '|', '∪', '$', - # prec-bitshift - '<<', '>>', '>>>', '.<<', '.>>', '.>>>', - # prec-times - '*', '/', './', '÷', '.÷', '%', '⋅', '.%', '.*', '\\', '.\\', '&', '∩', - # prec-rational - '//', './/', - # prec-power - '^', '.^', - # prec-decl - '::', - # prec-dot - '.', - # unary op - '+', '-', '!', '√', '∛', '∜', - )), Operator), # chars (r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,3}|\\u[a-fA-F0-9]{1,4}|" r"\\U[a-fA-F0-9]{1,6}|[^\\\'\n])'", String.Char), # try to match trailing transpose - (r'(?<=[.\w)\]])\'+', Operator), - - # strings - (r'"""', String, 'tqstring'), - (r'"', String, 'string'), + (r'(?<=[.\w)\]])(\'' + operator_suffixes + ')+', Operator), + # raw strings + (r'(raw)(""")', bygroups(String.Affix, String), 'tqrawstring'), + (r'(raw)(")', bygroups(String.Affix, String), 'rawstring'), # regular expressions - (r'r"""', String.Regex, 'tqregex'), - (r'r"', String.Regex, 'regex'), + (r'(r)(""")', bygroups(String.Affix, String.Regex), 'tqregex'), + (r'(r)(")', bygroups(String.Affix, String.Regex), 'regex'), + # other strings + (r'(' + allowed_variable + ')?(""")', bygroups(String.Affix, String), 'tqstring'), + (r'(' + allowed_variable + ')?(")', bygroups(String.Affix, String), 'string'), # backticks - (r'`', String.Backtick, 'command'), + (r'(' + allowed_variable + ')?(```)', bygroups(String.Affix, String.Backtick), 'tqcommand'), + (r'(' + allowed_variable + ')?(`)', bygroups(String.Affix, String.Backtick), 'command'), + + # type names + # - names that begin a curly expression + ('(' + allowed_variable + r')(\{)', + bygroups(Keyword.Type, Punctuation), 'curly'), + # - names as part of bare 'where' + (r'(where)(\s+)(' + allowed_variable + ')', + bygroups(Keyword, Text, Keyword.Type)), + # - curly expressions in general + (r'(\{)', Punctuation, 'curly'), + # - names as part of type declaration + (r'(abstract[ \t]+type|primitive[ \t]+type|mutable[ \t]+struct|struct)([\s()]+)(' + + allowed_variable + r')', bygroups(Keyword, Text, Keyword.Type)), + + # macros + (r'@' + allowed_variable, Name.Decorator), + (words([*OPERATORS_LIST, '..', '.', *DOTTED_OPERATORS_LIST], + prefix='@', suffix=operator_suffixes), Name.Decorator), + + # keywords + (words(KEYWORD_LIST, suffix=r'\b'), Keyword), + # builtin types + (words(BUILTIN_LIST, suffix=r'\b'), Keyword.Type), + # builtin literals + (words(LITERAL_LIST, suffix=r'\b'), Name.Builtin), # names (allowed_variable, Name), - (r'@' + allowed_variable, Name.Decorator), # numbers - (r'(\d+(_\d+)+\.\d*|\d*\.\d+(_\d+)+)([eEf][+-]?[0-9]+)?', Number.Float), - (r'(\d+\.\d*|\d*\.\d+)([eEf][+-]?[0-9]+)?', Number.Float), - (r'\d+(_\d+)+[eEf][+-]?[0-9]+', Number.Float), - (r'\d+[eEf][+-]?[0-9]+', Number.Float), - (r'0b[01]+(_[01]+)+', Number.Bin), - (r'0b[01]+', Number.Bin), - (r'0o[0-7]+(_[0-7]+)+', Number.Oct), - (r'0o[0-7]+', Number.Oct), - (r'0x[a-fA-F0-9]+(_[a-fA-F0-9]+)+', Number.Hex), - (r'0x[a-fA-F0-9]+', Number.Hex), - (r'\d+(_\d+)+', Number.Integer), - (r'\d+', Number.Integer) + (r'(\d+((_\d+)+)?\.(?!\.)(\d+((_\d+)+)?)?|\.\d+((_\d+)+)?)([eEf][+-]?[0-9]+)?', Number.Float), + (r'\d+((_\d+)+)?[eEf][+-]?[0-9]+', Number.Float), + (r'0x[a-fA-F0-9]+((_[a-fA-F0-9]+)+)?(\.([a-fA-F0-9]+((_[a-fA-F0-9]+)+)?)?)?p[+-]?\d+', Number.Float), + (r'0b[01]+((_[01]+)+)?', Number.Bin), + (r'0o[0-7]+((_[0-7]+)+)?', Number.Oct), + (r'0x[a-fA-F0-9]+((_[a-fA-F0-9]+)+)?', Number.Hex), + (r'\d+((_\d+)+)?', Number.Integer), + + # single dot operator matched last to permit e.g. ".1" as a float + (words(['.']), Operator), ], "blockcomment": [ @@ -227,53 +152,80 @@ class JuliaLexer(RegexLexer): (r'[=#]', Comment.Multiline), ], - 'string': [ + 'curly': [ + (r'\{', Punctuation, '#push'), + (r'\}', Punctuation, '#pop'), + (allowed_variable, Keyword.Type), + include('root'), + ], + + 'tqrawstring': [ + (r'"""', String, '#pop'), + (r'([^"]|"[^"][^"])+', String), + ], + 'rawstring': [ (r'"', String, '#pop'), - # FIXME: This escape pattern is not perfect. - (r'\\([\\"\'$nrbtfav]|(x|u|U)[a-fA-F0-9]+|\d+)', String.Escape), - # Interpolation is defined as "$" followed by the shortest full - # expression, which is something we can't parse. - # Include the most common cases here: $word, and $(paren'd expr). + (r'\\"', String.Escape), + (r'([^"\\]|\\[^"])+', String), + ], + + # Interpolation is defined as "$" followed by the shortest full expression, which is + # something we can't parse. + # Include the most common cases here: $word, and $(paren'd expr). + 'interp': [ (r'\$' + allowed_variable, String.Interpol), - # (r'\$[a-zA-Z_]+', String.Interpol), (r'(\$)(\()', bygroups(String.Interpol, Punctuation), 'in-intp'), + ], + 'in-intp': [ + (r'\(', Punctuation, '#push'), + (r'\)', Punctuation, '#pop'), + include('root'), + ], + + 'string': [ + (r'(")(' + allowed_variable + r'|\d+)?', bygroups(String, String.Affix), '#pop'), + # FIXME: This escape pattern is not perfect. + (r'\\([\\"\'$nrbtfav]|(x|u|U)[a-fA-F0-9]+|\d+)', String.Escape), + include('interp'), # @printf and @sprintf formats (r'%[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]', String.Interpol), - (r'.|\s', String), + (r'[^"$%\\]+', String), + (r'.', String), ], - 'tqstring': [ - (r'"""', String, '#pop'), + (r'(""")(' + allowed_variable + r'|\d+)?', bygroups(String, String.Affix), '#pop'), (r'\\([\\"\'$nrbtfav]|(x|u|U)[a-fA-F0-9]+|\d+)', String.Escape), - (r'\$' + allowed_variable, String.Interpol), - (r'(\$)(\()', bygroups(String.Interpol, Punctuation), 'in-intp'), - (r'.|\s', String), + include('interp'), + (r'[^"$%\\]+', String), + (r'.', String), ], 'regex': [ - (r'"', String.Regex, '#pop'), + (r'(")([imsxa]*)?', bygroups(String.Regex, String.Affix), '#pop'), (r'\\"', String.Regex), - (r'.|\s', String.Regex), + (r'[^\\"]+', String.Regex), ], 'tqregex': [ - (r'"""', String.Regex, '#pop'), - (r'.|\s', String.Regex), + (r'(""")([imsxa]*)?', bygroups(String.Regex, String.Affix), '#pop'), + (r'[^"]+', String.Regex), ], 'command': [ - (r'`', String.Backtick, '#pop'), - (r'\$' + allowed_variable, String.Interpol), - (r'(\$)(\()', bygroups(String.Interpol, Punctuation), 'in-intp'), - (r'.|\s', String.Backtick) + (r'(`)(' + allowed_variable + r'|\d+)?', bygroups(String.Backtick, String.Affix), '#pop'), + (r'\\[`$]', String.Escape), + include('interp'), + (r'[^\\`$]+', String.Backtick), + (r'.', String.Backtick), + ], + 'tqcommand': [ + (r'(```)(' + allowed_variable + r'|\d+)?', bygroups(String.Backtick, String.Affix), '#pop'), + (r'\\\$', String.Escape), + include('interp'), + (r'[^\\`$]+', String.Backtick), + (r'.', String.Backtick), ], - - 'in-intp': [ - (r'\(', Punctuation, '#push'), - (r'\)', Punctuation, '#pop'), - include('root'), - ] } def analyse_text(text): @@ -287,7 +239,7 @@ class JuliaConsoleLexer(Lexer): .. versionadded:: 1.6 """ name = 'Julia console' - aliases = ['jlcon'] + aliases = ['jlcon', 'julia-repl'] def get_tokens_unprocessed(self, text): jllexer = JuliaLexer(**self.options) diff --git a/tests/examplefiles/julia/string.jl b/tests/examplefiles/julia/string.jl index 67bf6c70..99b706fc 100644 --- a/tests/examplefiles/julia/string.jl +++ b/tests/examplefiles/julia/string.jl @@ -1,1031 +1,364 @@ -## core string functions ## - -length(s::String) = error("you must implement length(",typeof(s),")") -next(s::String, i::Int) = error("you must implement next(",typeof(s),",Int)") -next(s::DirectIndexString, i::Int) = (s[i],i+1) -next(s::String, i::Integer) = next(s,int(i)) - -## generic supplied functions ## - -start(s::String) = 1 -done(s::String,i) = (i > length(s)) -isempty(s::String) = done(s,start(s)) -ref(s::String, i::Int) = next(s,i)[1] -ref(s::String, i::Integer) = s[int(i)] -ref(s::String, x::Real) = s[iround(x)] -ref{T<:Integer}(s::String, r::Range1{T}) = s[int(first(r)):int(last(r))] - -symbol(s::String) = symbol(cstring(s)) -string(s::String) = s - -print(s::String) = for c=s; print(c); end -print(x...) = for i=x; print(i); end -println(args...) = print(args..., '\n') - -show(s::String) = print_quoted(s) - -(*)(s::String...) = strcat(s...) -(^)(s::String, r::Integer) = repeat(s,r) - -size(s::String) = (length(s),) -size(s::String, d::Integer) = d==1 ? length(s) : - error("in size: dimension ",d," out of range") - -strlen(s::DirectIndexString) = length(s) -function strlen(s::String) - i = start(s) - if done(s,i) - return 0 - end - n = 1 - while true - c, j = next(s,i) - if done(s,j) - return n - end - n += 1 - i = j - end -end - -isvalid(s::DirectIndexString, i::Integer) = (start(s) <= i <= length(s)) -function isvalid(s::String, i::Integer) - try - next(s,i) - true - catch - false - end -end - -prevind(s::DirectIndexString, i::Integer) = i-1 -thisind(s::DirectIndexString, i::Integer) = i -nextind(s::DirectIndexString, i::Integer) = i+1 - -prevind(s::String, i::Integer) = thisind(s,thisind(s,i)-1) - -function thisind(s::String, i::Integer) - for j = i:-1:1 - if isvalid(s,j) - return j - end - end - return 0 # out of range -end - -function nextind(s::String, i::Integer) - for j = i+1:length(s) - if isvalid(s,j) - return j - end - end - length(s)+1 # out of range -end - -ind2chr(s::DirectIndexString, i::Integer) = i -chr2ind(s::DirectIndexString, i::Integer) = i - -function ind2chr(s::String, i::Integer) - s[i] # throws error if invalid - j = 1 - k = start(s) - while true - c, l = next(s,k) - if i <= k - return j - end - j += 1 - k = l - end -end - -function chr2ind(s::String, i::Integer) - if i < 1 - return i - end - j = 1 - k = start(s) - while true - c, l = next(s,k) - if i == j - return k - end - j += 1 - k = l - end -end - -function strchr(s::String, c::Char, i::Integer) - i = nextind(s,i) - while !done(s,i) - d, j = next(s,i) - if c == d - return i - end - i = j - end - return 0 -end -strchr(s::String, c::Char) = strchr(s, c, start(s)) -contains(s::String, c::Char) = (strchr(s,c)!=0) - -function chars(s::String) - cx = Array(Char,strlen(s)) - i = 0 - for c in s - cx[i += 1] = c - end - return cx -end - -function cmp(a::String, b::String) - i = start(a) - j = start(b) - while !done(a,i) && !done(b,i) - c, i = next(a,i) - d, j = next(b,j) - if c != d - return c < d ? -1 : +1 +# This file is a part of Julia. License is MIT: https://julialang.org/license + +""" + StringIndexError(str, i) + +An error occurred when trying to access `str` at index `i` that is not valid. +""" +struct StringIndexError <: Exception + string::AbstractString + index::Integer +end +@noinline string_index_err(s::AbstractString, i::Integer) = + throw(StringIndexError(s, Int(i))) +function Base.showerror(io::IO, exc::StringIndexError) + s = exc.string + print(io, "StringIndexError: ", "invalid index [$(exc.index)]") + if firstindex(s) <= exc.index <= ncodeunits(s) + iprev = thisind(s, exc.index) + inext = nextind(s, iprev) + if inext <= ncodeunits(s) + print(io, ", valid nearby indices [$iprev]=>'$(s[iprev])', [$inext]=>'$(s[inext])'") + else + print(io, ", valid nearby index [$iprev]=>'$(s[iprev])'") end end - done(a,i) && !done(b,j) ? -1 : - !done(a,i) && done(b,j) ? +1 : 0 -end - -isequal(a::String, b::String) = cmp(a,b) == 0 -isless(a::String, b::String) = cmp(a,b) < 0 - -# faster comparisons for byte strings - -cmp(a::ByteString, b::ByteString) = lexcmp(a.data, b.data) -isequal(a::ByteString, b::ByteString) = length(a)==length(b) && cmp(a,b)==0 - -## character column width function ## - -charwidth(c::Char) = max(0,int(ccall(:wcwidth, Int32, (Char,), c))) -strwidth(s::String) = (w=0; for c in s; w += charwidth(c); end; w) -strwidth(s::ByteString) = ccall(:u8_strwidth, Int, (Ptr{Uint8},), s.data) -# TODO: implement and use u8_strnwidth that takes a length argument - -## generic string uses only length and next ## - -type GenericString <: String - string::String -end - -length(s::GenericString) = length(s.string) -next(s::GenericString, i::Int) = next(s.string, i) - -## plain old character arrays ## - -type CharString <: String - chars::Array{Char,1} - - CharString(a::Array{Char,1}) = new(a) - CharString(c::Char...) = new([ c[i] | i=1:length(c) ]) -end -CharString(x...) = CharString(map(char,x)...) - -next(s::CharString, i::Int) = (s.chars[i], i+1) -length(s::CharString) = length(s.chars) -strlen(s::CharString) = length(s) - -string(c::Char) = CharString(c) -string(c::Char, x::Char...) = CharString(c, x...) - -## substrings reference original strings ## - -type SubString <: String - string::String - offset::Int - length::Int - - SubString(s::String, i::Int, j::Int) = new(s, i-1, j-i+1) - SubString(s::SubString, i::Int, j::Int) = - new(s.string, i-1+s.offset, j-i+1) -end -SubString(s::String, i::Integer, j::Integer) = SubString(s, int(i), int(j)) - -function next(s::SubString, i::Int) - if i < 1 || i > s.length - error("string index out of bounds") - end - c, i = next(s.string, i+s.offset) - c, i-s.offset -end - -length(s::SubString) = s.length -# TODO: strlen(s::SubString) = ?? -# default implementation will work but it's slow -# can this be delegated efficiently somehow? -# that may require additional string interfaces - -function ref(s::String, r::Range1{Int}) - if first(r) < 1 || length(s) < last(r) - error("in substring slice: index out of range") - end - SubString(s, first(r), last(r)) -end - -## efficient representation of repeated strings ## - -type RepString <: String - string::String - repeat::Integer -end - -length(s::RepString) = length(s.string)*s.repeat -strlen(s::RepString) = strlen(s.string)*s.repeat - -function next(s::RepString, i::Int) - if i < 1 || i > length(s) - error("string index out of bounds") - end - j = mod1(i,length(s.string)) - c, k = next(s.string, j) - c, k-j+i -end - -function repeat(s::String, r::Integer) - r < 0 ? error("can't repeat a string ",r," times") : - r == 0 ? "" : - r == 1 ? s : - RepString(s,r) -end - -## reversed strings without data movement ## - -type RevString <: String - string::String -end - -length(s::RevString) = length(s.string) -strlen(s::RevString) = strlen(s.string) - -start(s::RevString) = (n=length(s); n-thisind(s.string,n)+1) -function next(s::RevString, i::Int) - n = length(s); j = n-i+1 - (s.string[j], n-thisind(s.string,j-1)+1) -end - -reverse(s::String) = RevString(s) -reverse(s::RevString) = s.string - -## ropes for efficient concatenation, etc. ## - -# Idea: instead of this standard binary tree structure, -# how about we keep an array of substrings, with an -# offset array. We can do binary search on the offset -# array so we get O(log(n)) indexing time still, but we -# can compute the offsets lazily and avoid all the -# futzing around while the string is being constructed. - -type RopeString <: String - head::String - tail::String - depth::Int32 - length::Int - - RopeString(h::RopeString, t::RopeString) = - depth(h.tail) + depth(t) < depth(h.head) ? - RopeString(h.head, RopeString(h.tail, t)) : - new(h, t, max(h.depth,t.depth)+1, length(h)+length(t)) - - RopeString(h::RopeString, t::String) = - depth(h.tail) < depth(h.head) ? - RopeString(h.head, RopeString(h.tail, t)) : - new(h, t, h.depth+1, length(h)+length(t)) - - RopeString(h::String, t::RopeString) = - depth(t.head) < depth(t.tail) ? - RopeString(RopeString(h, t.head), t.tail) : - new(h, t, t.depth+1, length(h)+length(t)) - - RopeString(h::String, t::String) = - new(h, t, 1, length(h)+length(t)) -end - -depth(s::String) = 0 -depth(s::RopeString) = s.depth - -function next(s::RopeString, i::Int) - if i <= length(s.head) - return next(s.head, i) - else - c, j = next(s.tail, i-length(s.head)) - return c, j+length(s.head) - end -end - -length(s::RopeString) = s.length -strlen(s::RopeString) = strlen(s.head) + strlen(s.tail) - -strcat() = "" -strcat(s::String) = s -strcat(x...) = strcat(map(string,x)...) -strcat(s::String, t::String...) = - (t = strcat(t...); isempty(s) ? t : isempty(t) ? s : RopeString(s, t)) - -print(s::RopeString) = print(s.head, s.tail) - -## transformed strings ## - -type TransformedString <: String - transform::Function - string::String end -length(s::TransformedString) = length(s.string) -strlen(s::TransformedString) = strlen(s.string) +const ByteArray = Union{Vector{UInt8},Vector{Int8}} -function next(s::TransformedString, i::Int) - c, j = next(s.string,i) - c = s.transform(c, i) - return c, j -end +@inline between(b::T, lo::T, hi::T) where {T<:Integer} = (lo ≤ b) & (b ≤ hi) -## uppercase and lowercase transformations ## +## constructors and conversions ## -uppercase(c::Char) = ccall(:towupper, Char, (Char,), c) -lowercase(c::Char) = ccall(:towlower, Char, (Char,), c) +# String constructor docstring from boot.jl, workaround for #16730 +# and the unavailability of @doc in boot.jl context. +""" + String(v::AbstractVector{UInt8}) -uppercase(s::String) = TransformedString((c,i)->uppercase(c), s) -lowercase(s::String) = TransformedString((c,i)->lowercase(c), s) +Create a new `String` object from a byte vector `v` containing UTF-8 encoded +characters. If `v` is `Vector{UInt8}` it will be truncated to zero length and +future modification of `v` cannot affect the contents of the resulting string. +To avoid truncation of `Vector{UInt8}` data, use `String(copy(v))`; for other +`AbstractVector` types, `String(v)` already makes a copy. -ucfirst(s::String) = TransformedString((c,i)->i==1 ? uppercase(c) : c, s) -lcfirst(s::String) = TransformedString((c,i)->i==1 ? lowercase(c) : c, s) +When possible, the memory of `v` will be used without copying when the `String` +object is created. This is guaranteed to be the case for byte vectors returned +by [`take!`](@ref) on a writable [`IOBuffer`](@ref) and by calls to +[`read(io, nb)`](@ref). This allows zero-copy conversion of I/O data to strings. +In other cases, `Vector{UInt8}` data may be copied, but `v` is truncated anyway +to guarantee consistent behavior. +""" +String(v::AbstractVector{UInt8}) = String(copyto!(StringVector(length(v)), v)) +String(v::Vector{UInt8}) = ccall(:jl_array_to_string, Ref{String}, (Any,), v) -const uc = uppercase -const lc = lowercase +""" + unsafe_string(p::Ptr{UInt8}, [length::Integer]) -## string map ## +Copy a string from the address of a C-style (NUL-terminated) string encoded as UTF-8. +(The pointer can be safely freed afterwards.) If `length` is specified +(the length of the data in bytes), the string does not have to be NUL-terminated. -function map(f::Function, s::String) - out = memio(length(s)) - for c in s - write(out, f(c)::Char) - end - takebuf_string(out) +This function is labeled "unsafe" because it will crash if `p` is not +a valid memory address to data of the requested length. +""" +function unsafe_string(p::Union{Ptr{UInt8},Ptr{Int8}}, len::Integer) + p == C_NULL && throw(ArgumentError("cannot convert NULL to string")) + ccall(:jl_pchar_to_string, Ref{String}, (Ptr{UInt8}, Int), p, len) end - -## conversion of general objects to strings ## - -string(x) = print_to_string(show, x) -cstring(x...) = print_to_string(print, x...) - -function cstring(p::Ptr{Uint8}) - p == C_NULL ? error("cannot convert NULL to string") : - ccall(:jl_cstr_to_string, Any, (Ptr{Uint8},), p)::ByteString +function unsafe_string(p::Union{Ptr{UInt8},Ptr{Int8}}) + p == C_NULL && throw(ArgumentError("cannot convert NULL to string")) + ccall(:jl_cstr_to_string, Ref{String}, (Ptr{UInt8},), p) end -## string promotion rules ## - -promote_rule(::Type{UTF8String} , ::Type{ASCIIString}) = UTF8String -promote_rule(::Type{UTF8String} , ::Type{CharString} ) = UTF8String -promote_rule(::Type{ASCIIString}, ::Type{CharString} ) = UTF8String +_string_n(n::Integer) = ccall(:jl_alloc_string, Ref{String}, (Csize_t,), n) -## printing literal quoted string data ## +""" + String(s::AbstractString) -# TODO: this is really the inverse of print_unbackslashed +Convert a string to a contiguous byte array representation encoded as UTF-8 bytes. +This representation is often appropriate for passing strings to C. +""" +String(s::AbstractString) = print_to_string(s) +@pure String(s::Symbol) = unsafe_string(unsafe_convert(Ptr{UInt8}, s)) -function print_quoted_literal(s::String) - print('"') - for c = s; c == '"' ? print("\\\"") : print(c); end - print('"') -end - -## string escaping & unescaping ## +unsafe_wrap(::Type{Vector{UInt8}}, s::String) = ccall(:jl_string_to_array, Ref{Vector{UInt8}}, (Any,), s) -escape_nul(s::String, i::Int) = - !done(s,i) && '0' <= next(s,i)[1] <= '7' ? L"\x00" : L"\0" +Vector{UInt8}(s::CodeUnits{UInt8,String}) = copyto!(Vector{UInt8}(undef, length(s)), s) +Vector{UInt8}(s::String) = Vector{UInt8}(codeunits(s)) +Array{UInt8}(s::String) = Vector{UInt8}(codeunits(s)) -is_hex_digit(c::Char) = '0'<=c<='9' || 'a'<=c<='f' || 'A'<=c<='F' -need_full_hex(s::String, i::Int) = !done(s,i) && is_hex_digit(next(s,i)[1]) +String(s::CodeUnits{UInt8,String}) = s.s -function print_escaped(s::String, esc::String) - i = start(s) - while !done(s,i) - c, j = next(s,i) - c == '\0' ? print(escape_nul(s,j)) : - c == '\e' ? print(L"\e") : - c == '\\' ? print("\\\\") : - contains(esc,c) ? print('\\', c) : - iswprint(c) ? print(c) : - 7 <= c <= 13 ? print('\\', "abtnvfr"[c-6]) : - c <= '\x7f' ? print(L"\x", hex(c, 2)) : - c <= '\uffff' ? print(L"\u", hex(c, need_full_hex(s,j) ? 4 : 2)) : - print(L"\U", hex(c, need_full_hex(s,j) ? 8 : 4)) - i = j - end -end +## low-level functions ## -escape_string(s::String) = print_to_string(length(s), print_escaped, s, "\"") -print_quoted(s::String) = (print('"'); print_escaped(s, "\"\$"); print('"')) -#" # work around syntax highlighting problem -quote_string(s::String) = print_to_string(length(s)+2, print_quoted, s) +pointer(s::String) = unsafe_convert(Ptr{UInt8}, s) +pointer(s::String, i::Integer) = pointer(s) + Int(i)::Int - 1 -# bare minimum unescaping function unescapes only given characters +@pure ncodeunits(s::String) = Core.sizeof(s) +codeunit(s::String) = UInt8 -function print_unescaped_chars(s::String, esc::String) - if !contains(esc,'\\') - esc = strcat("\\", esc) - end - i = start(s) - while !done(s,i) - c, i = next(s,i) - if c == '\\' && !done(s,i) && contains(esc,s[i]) - c, i = next(s,i) - end - print(c) - end +@inline function codeunit(s::String, i::Integer) + @boundscheck checkbounds(s, i) + b = GC.@preserve s unsafe_load(pointer(s, i)) + return b end -unescape_chars(s::String, esc::String) = - print_to_string(length(s), print_unescaped_chars, s, esc) +## comparison ## -# general unescaping of traditional C and Unicode escape sequences +_memcmp(a::Union{Ptr{UInt8},AbstractString}, b::Union{Ptr{UInt8},AbstractString}, len) = + ccall(:memcmp, Cint, (Ptr{UInt8}, Ptr{UInt8}, Csize_t), a, b, len % Csize_t) % Int -function print_unescaped(s::String) - i = start(s) - while !done(s,i) - c, i = next(s,i) - if !done(s,i) && c == '\\' - c, i = next(s,i) - if c == 'x' || c == 'u' || c == 'U' - n = k = 0 - m = c == 'x' ? 2 : - c == 'u' ? 4 : 8 - while (k+=1) <= m && !done(s,i) - c, j = next(s,i) - n = '0' <= c <= '9' ? n<<4 + c-'0' : - 'a' <= c <= 'f' ? n<<4 + c-'a'+10 : - 'A' <= c <= 'F' ? n<<4 + c-'A'+10 : break - i = j - end - if k == 1 - error("\\x used with no following hex digits") - end - if m == 2 # \x escape sequence - write(uint8(n)) - else - print(char(n)) - end - elseif '0' <= c <= '7' - k = 1 - n = c-'0' - while (k+=1) <= 3 && !done(s,i) - c, j = next(s,i) - n = '0' <= c <= '7' ? n<<3 + c-'0' : break - i = j - end - if n > 255 - error("octal escape sequence out of range") - end - write(uint8(n)) - else - print(c == 'a' ? '\a' : - c == 'b' ? '\b' : - c == 't' ? '\t' : - c == 'n' ? '\n' : - c == 'v' ? '\v' : - c == 'f' ? '\f' : - c == 'r' ? '\r' : - c == 'e' ? '\e' : c) - end - else - print(c) - end - end +function cmp(a::String, b::String) + al, bl = sizeof(a), sizeof(b) + c = _memcmp(a, b, min(al,bl)) + return c < 0 ? -1 : c > 0 ? +1 : cmp(al,bl) +end + +function ==(a::String, b::String) + pointer_from_objref(a) == pointer_from_objref(b) && return true + al = sizeof(a) + return al == sizeof(b) && 0 == _memcmp(a, b, al) +end + +typemin(::Type{String}) = "" +typemin(::String) = typemin(String) + +## thisind, nextind ## + +@propagate_inbounds thisind(s::String, i::Int) = _thisind_str(s, i) + +# s should be String or SubString{String} +@inline function _thisind_str(s, i::Int) + i == 0 && return 0 + n = ncodeunits(s) + i == n + 1 && return i + @boundscheck between(i, 1, n) || throw(BoundsError(s, i)) + @inbounds b = codeunit(s, i) + (b & 0xc0 == 0x80) & (i-1 > 0) || return i + @inbounds b = codeunit(s, i-1) + between(b, 0b11000000, 0b11110111) && return i-1 + (b & 0xc0 == 0x80) & (i-2 > 0) || return i + @inbounds b = codeunit(s, i-2) + between(b, 0b11100000, 0b11110111) && return i-2 + (b & 0xc0 == 0x80) & (i-3 > 0) || return i + @inbounds b = codeunit(s, i-3) + between(b, 0b11110000, 0b11110111) && return i-3 + return i +end + +@propagate_inbounds nextind(s::String, i::Int) = _nextind_str(s, i) + +# s should be String or SubString{String} +@inline function _nextind_str(s, i::Int) + i == 0 && return 1 + n = ncodeunits(s) + @boundscheck between(i, 1, n) || throw(BoundsError(s, i)) + @inbounds l = codeunit(s, i) + (l < 0x80) | (0xf8 ≤ l) && return i+1 + if l < 0xc0 + i′ = @inbounds thisind(s, i) + return i′ < i ? @inbounds(nextind(s, i′)) : i+1 + end + # first continuation byte + (i += 1) > n && return i + @inbounds b = codeunit(s, i) + b & 0xc0 ≠ 0x80 && return i + ((i += 1) > n) | (l < 0xe0) && return i + # second continuation byte + @inbounds b = codeunit(s, i) + b & 0xc0 ≠ 0x80 && return i + ((i += 1) > n) | (l < 0xf0) && return i + # third continuation byte + @inbounds b = codeunit(s, i) + ifelse(b & 0xc0 ≠ 0x80, i, i+1) end -unescape_string(s::String) = print_to_string(length(s), print_unescaped, s) - ## checking UTF-8 & ACSII validity ## -byte_string_classify(s::ByteString) = - ccall(:u8_isvalid, Int32, (Ptr{Uint8}, Int), s.data, length(s)) +byte_string_classify(s::Union{String,Vector{UInt8},FastContiguousSubArray{UInt8,1,Vector{UInt8}}}) = + ccall(:u8_isvalid, Int32, (Ptr{UInt8}, Int), s, sizeof(s)) # 0: neither valid ASCII nor UTF-8 # 1: valid ASCII # 2: valid UTF-8 -is_valid_ascii(s::ByteString) = byte_string_classify(s) == 1 -is_valid_utf8 (s::ByteString) = byte_string_classify(s) != 0 - -check_ascii(s::ByteString) = is_valid_ascii(s) ? s : error("invalid ASCII sequence") -check_utf8 (s::ByteString) = is_valid_utf8(s) ? s : error("invalid UTF-8 sequence") - -## string interpolation parsing ## - -function _jl_interp_parse(s::String, unescape::Function, printer::Function) - sx = {} - i = j = start(s) - while !done(s,j) - c, k = next(s,j) - if c == '$' - if !isempty(s[i:j-1]) - push(sx, unescape(s[i:j-1])) - end - ex, j = parseatom(s,k) - push(sx, ex) - i = j - elseif c == '\\' && !done(s,k) - if s[k] == '$' - if !isempty(s[i:j-1]) - push(sx, unescape(s[i:j-1])) - end - i = k - end - c, j = next(s,k) - else - j = k +isvalid(::Type{String}, s::Union{Vector{UInt8},FastContiguousSubArray{UInt8,1,Vector{UInt8}},String}) = byte_string_classify(s) ≠ 0 +isvalid(s::String) = isvalid(String, s) + +is_valid_continuation(c) = c & 0xc0 == 0x80 + +## required core functionality ## + +@inline function iterate(s::String, i::Int=firstindex(s)) + (i % UInt) - 1 < ncodeunits(s) || return nothing + b = @inbounds codeunit(s, i) + u = UInt32(b) << 24 + between(b, 0x80, 0xf7) || return reinterpret(Char, u), i+1 + return iterate_continued(s, i, u) +end + +function iterate_continued(s::String, i::Int, u::UInt32) + u < 0xc0000000 && (i += 1; @goto ret) + n = ncodeunits(s) + # first continuation byte + (i += 1) > n && @goto ret + @inbounds b = codeunit(s, i) + b & 0xc0 == 0x80 || @goto ret + u |= UInt32(b) << 16 + # second continuation byte + ((i += 1) > n) | (u < 0xe0000000) && @goto ret + @inbounds b = codeunit(s, i) + b & 0xc0 == 0x80 || @goto ret + u |= UInt32(b) << 8 + # third continuation byte + ((i += 1) > n) | (u < 0xf0000000) && @goto ret + @inbounds b = codeunit(s, i) + b & 0xc0 == 0x80 || @goto ret + u |= UInt32(b); i += 1 +@label ret + return reinterpret(Char, u), i +end + +@propagate_inbounds function getindex(s::String, i::Int) + b = codeunit(s, i) + u = UInt32(b) << 24 + between(b, 0x80, 0xf7) || return reinterpret(Char, u) + return getindex_continued(s, i, u) +end + +function getindex_continued(s::String, i::Int, u::UInt32) + if u < 0xc0000000 + # called from `getindex` which checks bounds + @inbounds isvalid(s, i) && @goto ret + string_index_err(s, i) + end + n = ncodeunits(s) + + (i += 1) > n && @goto ret + @inbounds b = codeunit(s, i) # cont byte 1 + b & 0xc0 == 0x80 || @goto ret + u |= UInt32(b) << 16 + + ((i += 1) > n) | (u < 0xe0000000) && @goto ret + @inbounds b = codeunit(s, i) # cont byte 2 + b & 0xc0 == 0x80 || @goto ret + u |= UInt32(b) << 8 + + ((i += 1) > n) | (u < 0xf0000000) && @goto ret + @inbounds b = codeunit(s, i) # cont byte 3 + b & 0xc0 == 0x80 || @goto ret + u |= UInt32(b) +@label ret + return reinterpret(Char, u) +end + +getindex(s::String, r::UnitRange{<:Integer}) = s[Int(first(r)):Int(last(r))] + +@inline function getindex(s::String, r::UnitRange{Int}) + isempty(r) && return "" + i, j = first(r), last(r) + @boundscheck begin + checkbounds(s, r) + @inbounds isvalid(s, i) || string_index_err(s, i) + @inbounds isvalid(s, j) || string_index_err(s, j) + end + j = nextind(s, j) - 1 + n = j - i + 1 + ss = _string_n(n) + GC.@preserve s ss unsafe_copyto!(pointer(ss), pointer(s, i), n) + return ss +end + +length(s::String) = length_continued(s, 1, ncodeunits(s), ncodeunits(s)) + +@inline function length(s::String, i::Int, j::Int) + @boundscheck begin + 0 < i ≤ ncodeunits(s)+1 || throw(BoundsError(s, i)) + 0 ≤ j < ncodeunits(s)+1 || throw(BoundsError(s, j)) + end + j < i && return 0 + @inbounds i, k = thisind(s, i), i + c = j - i + (i == k) + length_continued(s, i, j, c) +end + +@inline function length_continued(s::String, i::Int, n::Int, c::Int) + i < n || return c + @inbounds b = codeunit(s, i) + @inbounds while true + while true + (i += 1) ≤ n || return c + 0xc0 ≤ b ≤ 0xf7 && break + b = codeunit(s, i) end - end - if !isempty(s[i:]) - push(sx, unescape(s[i:j-1])) - end - length(sx) == 1 && isa(sx[1],ByteString) ? sx[1] : - expr(:call, :print_to_string, printer, sx...) -end - -_jl_interp_parse(s::String, u::Function) = _jl_interp_parse(s, u, print) -_jl_interp_parse(s::String) = _jl_interp_parse(s, x->check_utf8(unescape_string(x))) - -function _jl_interp_parse_bytes(s::String) - writer(x...) = for w=x; write(w); end - _jl_interp_parse(s, unescape_string, writer) -end - -## core string macros ## - -macro str(s); _jl_interp_parse(s); end -macro S_str(s); _jl_interp_parse(s); end -macro I_str(s); _jl_interp_parse(s, x->unescape_chars(x,"\"")); end -macro E_str(s); check_utf8(unescape_string(s)); end -macro B_str(s); _jl_interp_parse_bytes(s); end -macro b_str(s); ex = _jl_interp_parse_bytes(s); :(($ex).data); end - -## shell-like command parsing ## - -function _jl_shell_parse(s::String, interp::Bool) - - in_single_quotes = false - in_double_quotes = false - - args = {} - arg = {} - i = start(s) - j = i - - function update_arg(x) - if !isa(x,String) || !isempty(x) - push(arg, x) - end - end - function append_arg() - if isempty(arg); arg = {"",}; end - push(args, arg) - arg = {} - end - - while !done(s,j) - c, k = next(s,j) - if !in_single_quotes && !in_double_quotes && iswspace(c) - update_arg(s[i:j-1]) - append_arg() - j = k - while !done(s,j) - c, k = next(s,j) - if !iswspace(c) - i = j - break - end - j = k - end - elseif interp && !in_single_quotes && c == '$' - update_arg(s[i:j-1]); i = k; j = k - if done(s,k) - error("\$ right before end of command") - end - if iswspace(s[k]) - error("space not allowed right after \$") - end - ex, j = parseatom(s,j) - update_arg(ex); i = j - else - if !in_double_quotes && c == '\'' - in_single_quotes = !in_single_quotes - update_arg(s[i:j-1]); i = k - elseif !in_single_quotes && c == '"' - in_double_quotes = !in_double_quotes - update_arg(s[i:j-1]); i = k - elseif c == '\\' - if in_double_quotes - if done(s,k) - error("unterminated double quote") - end - if s[k] == '"' || s[k] == '$' - update_arg(s[i:j-1]); i = k - c, k = next(s,k) - end - elseif !in_single_quotes - if done(s,k) - error("dangling backslash") - end - update_arg(s[i:j-1]); i = k - c, k = next(s,k) - end - end - j = k - end - end - - if in_single_quotes; error("unterminated single quote"); end - if in_double_quotes; error("unterminated double quote"); end - - update_arg(s[i:]) - append_arg() - - if !interp - return args - end - - # construct an expression - exprs = {} - for arg in args - push(exprs, expr(:tuple, arg)) - end - expr(:tuple,exprs) -end -_jl_shell_parse(s::String) = _jl_shell_parse(s,true) - -function shell_split(s::String) - parsed = _jl_shell_parse(s,false) - args = String[] - for arg in parsed - push(args, strcat(arg...)) - end - args -end - -function print_shell_word(word::String) - if isempty(word) - print("''") - end - has_single = false - has_special = false - for c in word - if iswspace(c) || c=='\\' || c=='\'' || c=='"' || c=='$' - has_special = true - if c == '\'' - has_single = true - end + l = b + b = codeunit(s, i) # cont byte 1 + c -= (x = b & 0xc0 == 0x80) + x & (l ≥ 0xe0) || continue + + (i += 1) ≤ n || return c + b = codeunit(s, i) # cont byte 2 + c -= (x = b & 0xc0 == 0x80) + x & (l ≥ 0xf0) || continue + + (i += 1) ≤ n || return c + b = codeunit(s, i) # cont byte 3 + c -= (b & 0xc0 == 0x80) + end +end + +## overload methods for efficiency ## + +isvalid(s::String, i::Int) = checkbounds(Bool, s, i) && thisind(s, i) == i + +function isascii(s::String) + @inbounds for i = 1:ncodeunits(s) + codeunit(s, i) >= 0x80 && return false + end + return true +end + +""" + repeat(c::AbstractChar, r::Integer) -> String + +Repeat a character `r` times. This can equivalently be accomplished by calling +[`c^r`](@ref :^(::Union{AbstractString, AbstractChar}, ::Integer)). + +# Examples +```jldoctest +julia> repeat('A', 3) +"AAA" +``` +""" +repeat(c::AbstractChar, r::Integer) = repeat(Char(c), r) # fallback +function repeat(c::Char, r::Integer) + r == 0 && return "" + r < 0 && throw(ArgumentError("can't repeat a character $r times")) + u = bswap(reinterpret(UInt32, c)) + n = 4 - (leading_zeros(u | 0xff) >> 3) + s = _string_n(n*r) + p = pointer(s) + GC.@preserve s if n == 1 + ccall(:memset, Ptr{Cvoid}, (Ptr{UInt8}, Cint, Csize_t), p, u % UInt8, r) + elseif n == 2 + p16 = reinterpret(Ptr{UInt16}, p) + for i = 1:r + unsafe_store!(p16, u % UInt16, i) end - end - if !has_special - print(word) - elseif !has_single - print('\'', word, '\'') - else - print('"') - for c in word - if c == '"' || c == '$' - print('\\') - end - print(c) - end - print('"') - end -end - -function print_shell_escaped(cmd::String, args::String...) - print_shell_word(cmd) - for arg in args - print(' ') - print_shell_word(arg) - end -end - -shell_escape(cmd::String, args::String...) = - print_to_string(print_shell_escaped, cmd, args...) - -## interface to parser ## - -function parse(s::String, pos, greedy) - # returns (expr, end_pos). expr is () in case of parse error. - ex, pos = ccall(:jl_parse_string, Any, - (Ptr{Uint8}, Int32, Int32), - cstring(s), pos-1, greedy ? 1:0) - if isa(ex,Expr) && is(ex.head,:error) - throw(ParseError(ex.args[1])) - end - if ex == (); throw(ParseError("end of input")); end - ex, pos+1 # C is zero-based, Julia is 1-based -end - -parse(s::String) = parse(s, 1, true) -parse(s::String, pos) = parse(s, pos, true) -parseatom(s::String) = parse(s, 1, false) -parseatom(s::String, pos) = parse(s, pos, false) - -## miscellaneous string functions ## - -function lpad(s::String, n::Integer, p::String) - m = n - strlen(s) - if m <= 0; return s; end - l = strlen(p) - if l==1 - return p^m * s - end - q = div(m,l) - r = m - q*l - cstring(p^q*p[1:chr2ind(p,r)]*s) -end - -function rpad(s::String, n::Integer, p::String) - m = n - strlen(s) - if m <= 0; return s; end - l = strlen(p) - if l==1 - return s * p^m - end - q = div(m,l) - r = m - q*l - cstring(s*p^q*p[1:chr2ind(p,r)]) -end - -lpad(s, n::Integer, p) = lpad(string(s), n, string(p)) -rpad(s, n::Integer, p) = rpad(string(s), n, string(p)) - -lpad(s, n::Integer) = lpad(string(s), n, " ") -rpad(s, n::Integer) = rpad(string(s), n, " ") - -function split(s::String, delims, include_empty::Bool) - i = 1 - strs = String[] - len = length(s) - while true - tokstart = tokend = i - while !done(s,i) - (c,i) = next(s,i) - if contains(delims, c) - break - end - tokend = i - end - tok = s[tokstart:(tokend-1)] - if include_empty || !isempty(tok) - push(strs, tok) + elseif n == 3 + b1 = (u >> 0) % UInt8 + b2 = (u >> 8) % UInt8 + b3 = (u >> 16) % UInt8 + for i = 0:r-1 + unsafe_store!(p, b1, 3i + 1) + unsafe_store!(p, b2, 3i + 2) + unsafe_store!(p, b3, 3i + 3) end - if !((i <= len) || (i==len+1 && tokend!=i)) - break + elseif n == 4 + p32 = reinterpret(Ptr{UInt32}, p) + for i = 1:r + unsafe_store!(p32, u, i) end end - strs + return s end - -split(s::String) = split(s, (' ','\t','\n','\v','\f','\r'), false) -split(s::String, x) = split(s, x, true) -split(s::String, x::Char, incl::Bool) = split(s, (x,), incl) - -function print_joined(strings, delim, last) - i = start(strings) - if done(strings,i) - return - end - str, i = next(strings,i) - print(str) - while !done(strings,i) - str, i = next(strings,i) - print(done(strings,i) ? last : delim) - print(str) - end -end - -function print_joined(strings, delim) - i = start(strings) - while !done(strings,i) - str, i = next(strings,i) - print(str) - if !done(strings,i) - print(delim) - end - end -end -print_joined(strings) = print_joined(strings, "") - -join(args...) = print_to_string(print_joined, args...) - -chop(s::String) = s[1:thisind(s,length(s))-1] -chomp(s::String) = (i=thisind(s,length(s)); s[i]=='\n' ? s[1:i-1] : s) -chomp(s::ByteString) = s.data[end]==0x0a ? s[1:end-1] : s - -function lstrip(s::String) - i = start(s) - while !done(s,i) - c, j = next(s,i) - if !iswspace(c) - return s[i:end] - end - i = j - end - "" -end - -function rstrip(s::String) - r = reverse(s) - i = start(r) - while !done(r,i) - c, j = next(r,i) - if !iswspace(c) - return s[1:end-i+1] - end - i = j - end - "" -end - -strip(s::String) = lstrip(rstrip(s)) - -## string to integer functions ## - -function parse_int{T<:Integer}(::Type{T}, s::String, base::Integer) - if !(2 <= base <= 36); error("invalid base: ",base); end - i = start(s) - if done(s,i) - error("premature end of integer (in ",show_to_string(s),")") - end - c,i = next(s,i) - sgn = one(T) - if T <: Signed && c == '-' - sgn = -sgn - if done(s,i) - error("premature end of integer (in ",show_to_string(s),")") - end - c,i = next(s,i) - end - base = convert(T,base) - n::T = 0 - while true - d = '0' <= c <= '9' ? c-'0' : - 'A' <= c <= 'Z' ? c-'A'+10 : - 'a' <= c <= 'z' ? c-'a'+10 : typemax(Int) - if d >= base - error(show_to_string(c)," is not a valid digit (in ",show_to_string(s),")") - end - # TODO: overflow detection? - n = n*base + d - if done(s,i) - break - end - c,i = next(s,i) - end - return flipsign(n,sgn) -end - -parse_int(s::String, base::Integer) = parse_int(Int,s,base) -parse_int(T::Type, s::String) = parse_int(T,s,10) -parse_int(s::String) = parse_int(Int,s,10) - -parse_bin(T::Type, s::String) = parse_int(T,s,2) -parse_oct(T::Type, s::String) = parse_int(T,s,8) -parse_hex(T::Type, s::String) = parse_int(T,s,16) - -parse_bin(s::String) = parse_int(Int,s,2) -parse_oct(s::String) = parse_int(Int,s,8) -parse_hex(s::String) = parse_int(Int,s,16) - -integer (s::String) = int(s) -unsigned(s::String) = uint(s) -int (s::String) = parse_int(Int,s) -uint (s::String) = parse_int(Uint,s) -int8 (s::String) = parse_int(Int8,s) -uint8 (s::String) = parse_int(Uint8,s) -int16 (s::String) = parse_int(Int16,s) -uint16 (s::String) = parse_int(Uint16,s) -int32 (s::String) = parse_int(Int32,s) -uint32 (s::String) = parse_int(Uint32,s) -int64 (s::String) = parse_int(Int64,s) -uint64 (s::String) = parse_int(Uint64,s) - -## integer to string functions ## - -const _jl_dig_syms = "0123456789abcdefghijklmnopqrstuvwxyz".data - -function int2str(n::Union(Int64,Uint64), b::Integer, l::Int) - if b < 2 || b > 36; error("int2str: invalid base ", b); end - neg = n < 0 - n = unsigned(abs(n)) - b = convert(typeof(n), b) - ndig = ndigits(n, b) - sz = max(convert(Int, ndig), l) + neg - data = Array(Uint8, sz) - i = sz - if ispow2(b) - digmask = b-1 - shift = trailing_zeros(b) - while i > neg - ch = n & digmask - data[i] = _jl_dig_syms[int(ch)+1] - n >>= shift - i -= 1 - end - else - while i > neg - ch = n % b - data[i] = _jl_dig_syms[int(ch)+1] - n = div(n,b) - i -= 1 - end - end - if neg - data[1] = '-' - end - ASCIIString(data) -end -int2str(n::Integer, b::Integer) = int2str(n, b, 0) -int2str(n::Integer, b::Integer, l::Int) = int2str(int64(n), b, l) - -string(x::Signed) = dec(int64(x)) -cstring(x::Signed) = dec(int64(x)) - -## string to float functions ## - -function float64_isvalid(s::String, out::Array{Float64,1}) - s = cstring(s) - return (ccall(:jl_strtod, Int32, (Ptr{Uint8},Ptr{Float64}), s, out)==0) -end - -function float32_isvalid(s::String, out::Array{Float32,1}) - s = cstring(s) - return (ccall(:jl_strtof, Int32, (Ptr{Uint8},Ptr{Float32}), s, out)==0) -end - -begin - local tmp::Array{Float64,1} = Array(Float64,1) - local tmpf::Array{Float32,1} = Array(Float32,1) - global float64, float32 - function float64(s::String) - if !float64_isvalid(s, tmp) - throw(ArgumentError("float64(String): invalid number format")) - end - return tmp[1] - end - - function float32(s::String) - if !float32_isvalid(s, tmpf) - throw(ArgumentError("float32(String): invalid number format")) - end - return tmpf[1] - end -end - -float(x::String) = float64(x) -parse_float(x::String) = float64(x) -parse_float(::Type{Float64}, x::String) = float64(x) -parse_float(::Type{Float32}, x::String) = float32(x) - -# copying a byte string (generally not needed due to "immutability") - -strcpy{T<:ByteString}(s::T) = T(copy(s.data)) - -# lexicographically compare byte arrays (used by Latin-1 and UTF-8) - -function lexcmp(a::Array{Uint8,1}, b::Array{Uint8,1}) - c = ccall(:memcmp, Int32, (Ptr{Uint8}, Ptr{Uint8}, Uint), - a, b, min(length(a),length(b))) - c < 0 ? -1 : c > 0 ? +1 : cmp(length(a),length(b)) -end - -# find the index of the first occurrence of a byte value in a byte array - -function memchr(a::Array{Uint8,1}, b::Integer) - p = pointer(a) - q = ccall(:memchr, Ptr{Uint8}, (Ptr{Uint8}, Int32, Uint), p, b, length(a)) - q == C_NULL ? 0 : q - p + 1 -end - -# concatenate byte arrays into a single array - -memcat() = Array(Uint8,0) -memcat(a::Array{Uint8,1}) = copy(a) - -function memcat(arrays::Array{Uint8,1}...) - n = 0 - for a in arrays - n += length(a) - end - arr = Array(Uint8, n) - ptr = pointer(arr) - offset = 0 - for a in arrays - ccall(:memcpy, Ptr{Uint8}, (Ptr{Uint8}, Ptr{Uint8}, Uint), - ptr+offset, a, length(a)) - offset += length(a) - end - return arr -end - -# concatenate the data fields of byte strings - -memcat(s::ByteString) = memcat(s.data) -memcat(sx::ByteString...) = memcat(map(s->s.data, sx)...) diff --git a/tests/examplefiles/julia/string.jl.output b/tests/examplefiles/julia/string.jl.output index 1175b3b7..70010b51 100644 --- a/tests/examplefiles/julia/string.jl.output +++ b/tests/examplefiles/julia/string.jl.output @@ -1,735 +1,249 @@ -'## core string functions ##' Comment +'# This file is a part of Julia. License is MIT: https://julialang.org/license' Comment '\n' Text '\n' Text -'length' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'y' Literal.String -'o' Literal.String -'u' Literal.String -' ' Literal.String -'m' Literal.String -'u' Literal.String -'s' Literal.String -'t' Literal.String -' ' Literal.String -'i' Literal.String -'m' Literal.String -'p' Literal.String -'l' Literal.String -'e' Literal.String -'m' Literal.String -'e' Literal.String -'n' Literal.String -'t' Literal.String -' ' Literal.String -'l' Literal.String -'e' Literal.String -'n' Literal.String -'g' Literal.String -'t' Literal.String -'h' Literal.String -'(' Literal.String -'"' Literal.String -',' Punctuation -'typeof' Name -'(' Punctuation -'s' Name -')' Punctuation -',' Punctuation -'"' Literal.String -')' Literal.String -'"' Literal.String -')' Punctuation +'"""' Literal.String +'\n StringIndexError(str, i)\n\nAn error occurred when trying to access `str` at index `i` that is not valid.\n' Literal.String + +'"""' Literal.String '\n' Text -'next' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation +'struct' Keyword ' ' Text -'i' Name -'::' Operator -'Int' Keyword.Type -')' Punctuation +'StringIndexError' Keyword.Type ' ' Text -'=' Operator +'<:' Operator ' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'y' Literal.String -'o' Literal.String -'u' Literal.String -' ' Literal.String -'m' Literal.String -'u' Literal.String -'s' Literal.String -'t' Literal.String -' ' Literal.String -'i' Literal.String -'m' Literal.String -'p' Literal.String -'l' Literal.String -'e' Literal.String -'m' Literal.String -'e' Literal.String -'n' Literal.String -'t' Literal.String -' ' Literal.String -'n' Literal.String -'e' Literal.String -'x' Literal.String -'t' Literal.String -'(' Literal.String -'"' Literal.String -',' Punctuation -'typeof' Name -'(' Punctuation -'s' Name -')' Punctuation -',' Punctuation -'"' Literal.String -',' Literal.String -'I' Literal.String -'n' Literal.String -'t' Literal.String -')' Literal.String -'"' Literal.String -')' Punctuation +'Exception' Keyword.Type '\n' Text -'next' Name -'(' Punctuation -'s' Name -'::' Operator -'DirectIndexString' Keyword.Type -',' Punctuation -' ' Text -'i' Name +' ' Text +'string' Name '::' Operator -'Int' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'(' Punctuation -'s' Name -'[' Punctuation -'i' Name -']' Punctuation -',' Punctuation -'i' Name -'+' Operator -'1' Literal.Number.Integer -')' Punctuation +'AbstractString' Keyword.Type '\n' Text -'next' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'i' Name +' ' Text +'index' Name '::' Operator 'Integer' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'next' Name -'(' Punctuation -'s' Name -',' Punctuation -'int' Name -'(' Punctuation -'i' Name -')' Punctuation -')' Punctuation -'\n' Text - -'\n' Text - -'## generic supplied functions ##' Comment '\n' Text +'end' Keyword '\n' Text -'start' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation +'@noinline' Name.Decorator ' ' Text -'=' Operator -' ' Text -'1' Literal.Number.Integer -'\n' Text - -'done' Name +'string_index_err' Name '(' Punctuation 's' Name '::' Operator -'String' Name +'AbstractString' Keyword.Type ',' Punctuation -'i' Name -')' Punctuation -' ' Text -'=' Operator ' ' Text -'(' Punctuation 'i' Name -' ' Text -'>' Operator -' ' Text -'length' Name -'(' Punctuation -'s' Name -')' Punctuation -')' Punctuation -'\n' Text - -'isempty' Name -'(' Punctuation -'s' Name '::' Operator -'String' Name +'Integer' Keyword.Type ')' Punctuation ' ' Text '=' Operator -' ' Text -'done' Name -'(' Punctuation -'s' Name -',' Punctuation -'start' Name -'(' Punctuation -'s' Name -')' Punctuation -')' Punctuation '\n' Text -'ref' Name +' ' Text +'throw' Name +'(' Punctuation +'StringIndexError' Keyword.Type '(' Punctuation 's' Name -'::' Operator -'String' Name ',' Punctuation ' ' Text -'i' Name -'::' Operator 'Int' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'next' Name '(' Punctuation -'s' Name -',' Punctuation 'i' Name ')' Punctuation -'[' Punctuation -'1' Literal.Number.Integer -']' Punctuation -'\n' Text - -'ref' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'i' Name -'::' Operator -'Integer' Keyword.Type ')' Punctuation -' ' Text -'=' Operator -' ' Text -'s' Name -'[' Punctuation -'int' Name -'(' Punctuation -'i' Name ')' Punctuation -']' Punctuation '\n' Text -'ref' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'x' Name -'::' Operator -'Real' Keyword.Type -')' Punctuation -' ' Text -'=' Operator +'function' Keyword ' ' Text -'s' Name -'[' Punctuation -'iround' Name -'(' Punctuation -'x' Name -')' Punctuation -']' Punctuation -'\n' Text - -'ref' Name -'{' Punctuation -'T' Name -'<:' Operator -'Integer' Keyword.Type -'}' Punctuation +'Base' Name +'.' Operator +'showerror' Name '(' Punctuation -'s' Name +'io' Name '::' Operator -'String' Name +'IO' Keyword.Type ',' Punctuation ' ' Text -'r' Name +'exc' Name '::' Operator -'Range1' Name -'{' Punctuation -'T' Name -'}' Punctuation -')' Punctuation -' ' Text -'=' Operator -' ' Text -'s' Name -'[' Punctuation -'int' Name -'(' Punctuation -'first' Name -'(' Punctuation -'r' Name -')' Punctuation +'StringIndexError' Keyword.Type ')' Punctuation -':' Operator -'int' Name -'(' Punctuation -'last' Name -'(' Punctuation -'r' Name -')' Punctuation -')' Punctuation -']' Punctuation -'\n' Text - '\n' Text -'symbol' Name -'(' Punctuation +' ' Text 's' Name -'::' Operator -'String' Name -')' Punctuation ' ' Text '=' Operator ' ' Text -'symbol' Name -'(' Punctuation -'cstring' Name -'(' Punctuation -'s' Name -')' Punctuation -')' Punctuation -'\n' Text - +'exc' Name +'.' Operator 'string' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'s' Name -'\n' Text - '\n' Text +' ' Text 'print' Name '(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'for' Keyword -' ' Text -'c' Name -'=' Operator -'s' Name -';' Punctuation +'io' Name +',' Punctuation ' ' Text -'print' Name -'(' Punctuation -'c' Name -')' Punctuation -';' Punctuation +'"' Literal.String +'StringIndexError: ' Literal.String +'"' Literal.String +',' Punctuation ' ' Text -'end' Keyword -'\n' Text - -'print' Name +'"' Literal.String +'invalid index [' Literal.String +'$' Literal.String.Interpol '(' Punctuation -'x' Name -'.' Operator -'.' Operator +'exc' Name '.' Operator +'index' Name ')' Punctuation -' ' Text -'=' Operator -' ' Text -'for' Keyword -' ' Text -'i' Name -'=' Operator -'x' Name -';' Punctuation -' ' Text -'print' Name -'(' Punctuation -'i' Name +']' Literal.String +'"' Literal.String ')' Punctuation -';' Punctuation -' ' Text -'end' Keyword '\n' Text -'println' Name -'(' Punctuation -'args' Name -'.' Operator -'.' Operator -'.' Operator -')' Punctuation -' ' Text -'=' Operator -' ' Text -'print' Name -'(' Punctuation -'args' Name -'.' Operator -'.' Operator -'.' Operator -',' Punctuation +' ' Text +'if' Keyword ' ' Text -"'\\n'" Literal.String.Char -')' Punctuation -'\n' Text - -'\n' Text - -'show' Name +'firstindex' Name '(' Punctuation 's' Name -'::' Operator -'String' Name ')' Punctuation ' ' Text -'=' Operator +'<=' Operator ' ' Text -'print_quoted' Name -'(' Punctuation -'s' Name -')' Punctuation -'\n' Text - -'\n' Text - -'(' Punctuation -'*' Operator -')' Punctuation -'(' Punctuation -'s' Name -'::' Operator -'String' Name -'.' Operator +'exc' Name '.' Operator -'.' Operator -')' Punctuation +'index' Name ' ' Text -'=' Operator +'<=' Operator ' ' Text -'strcat' Name +'ncodeunits' Name '(' Punctuation 's' Name -'.' Operator -'.' Operator -'.' Operator ')' Punctuation '\n' Text -'(' Punctuation -'^' Operator -')' Punctuation -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'r' Name -'::' Operator -'Integer' Keyword.Type -')' Punctuation +' ' Text +'iprev' Name ' ' Text '=' Operator ' ' Text -'repeat' Name +'thisind' Name '(' Punctuation 's' Name ',' Punctuation -'r' Name +' ' Text +'exc' Name +'.' Operator +'index' Name ')' Punctuation '\n' Text -'\n' Text - -'size' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation +' ' Text +'inext' Name ' ' Text '=' Operator ' ' Text -'(' Punctuation -'length' Name +'nextind' Name '(' Punctuation 's' Name -')' Punctuation ',' Punctuation +' ' Text +'iprev' Name ')' Punctuation '\n' Text -'size' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'d' Name -'::' Operator -'Integer' Keyword.Type -')' Punctuation -' ' Text -'=' Operator +' ' Text +'if' Keyword ' ' Text -'d' Name -'==' Operator -'1' Literal.Number.Integer +'inext' Name ' ' Text -'?' Operator +'<=' Operator ' ' Text -'length' Name +'ncodeunits' Name '(' Punctuation 's' Name ')' Punctuation -' ' Text -':' Operator '\n' Text -' ' Text -'error' Name +' ' Text +'print' Name '(' Punctuation -'"' Literal.String -'i' Literal.String -'n' Literal.String -' ' Literal.String -'s' Literal.String -'i' Literal.String -'z' Literal.String -'e' Literal.String -':' Literal.String -' ' Literal.String -'d' Literal.String -'i' Literal.String -'m' Literal.String -'e' Literal.String -'n' Literal.String -'s' Literal.String -'i' Literal.String -'o' Literal.String -'n' Literal.String -' ' Literal.String -'"' Literal.String -',' Punctuation -'d' Name +'io' Name ',' Punctuation -'"' Literal.String -' ' Literal.String -'o' Literal.String -'u' Literal.String -'t' Literal.String -' ' Literal.String -'o' Literal.String -'f' Literal.String -' ' Literal.String -'r' Literal.String -'a' Literal.String -'n' Literal.String -'g' Literal.String -'e' Literal.String -'"' Literal.String -')' Punctuation -'\n' Text - -'\n' Text - -'strlen' Name -'(' Punctuation -'s' Name -'::' Operator -'DirectIndexString' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'length' Name -'(' Punctuation -'s' Name -')' Punctuation -'\n' Text - -'function' Keyword ' ' Text -'strlen' Name +'"' Literal.String +', valid nearby indices [' Literal.String +'$iprev' Literal.String.Interpol +"]=>'" Literal.String +'$' Literal.String.Interpol '(' Punctuation 's' Name -'::' Operator -'String' Name +'[' Punctuation +'iprev' Name +']' Punctuation ')' Punctuation -'\n' Text - -' ' Text -'i' Name -' ' Text -'=' Operator -' ' Text -'start' Name +"', [" Literal.String +'$inext' Literal.String.Interpol +"]=>'" Literal.String +'$' Literal.String.Interpol '(' Punctuation 's' Name +'[' Punctuation +'inext' Name +']' Punctuation ')' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'done' Name -'(' Punctuation -'s' Name -',' Punctuation -'i' Name +"'" Literal.String +'"' Literal.String ')' Punctuation '\n' Text ' ' Text -'return' Keyword -' ' Text -'0' Literal.Number.Integer -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'n' Name -' ' Text -'=' Operator -' ' Text -'1' Literal.Number.Integer -'\n' Text - -' ' Text -'while' Keyword -' ' Text -'true' Keyword.Constant +'else' Keyword '\n' Text -' ' Text -'c' Name -',' Punctuation -' ' Text -'j' Name -' ' Text -'=' Operator -' ' Text -'next' Name +' ' Text +'print' Name '(' Punctuation -'s' Name +'io' Name ',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword ' ' Text -'done' Name +'"' Literal.String +', valid nearby index [' Literal.String +'$iprev' Literal.String.Interpol +"]=>'" Literal.String +'$' Literal.String.Interpol '(' Punctuation 's' Name -',' Punctuation -'j' Name +'[' Punctuation +'iprev' Name +']' Punctuation +')' Punctuation +"'" Literal.String +'"' Literal.String ')' Punctuation -'\n' Text - -' ' Text -'return' Keyword -' ' Text -'n' Name '\n' Text ' ' Text 'end' Keyword '\n' Text -' ' Text -'n' Name -' ' Text -'+=' Operator -' ' Text -'1' Literal.Number.Integer -'\n' Text - -' ' Text -'i' Name -' ' Text -'=' Operator -' ' Text -'j' Name -'\n' Text - ' ' Text 'end' Keyword '\n' Text @@ -739,998 +253,313 @@ '\n' Text -'isvalid' Name -'(' Punctuation -'s' Name -'::' Operator -'DirectIndexString' Keyword.Type -',' Punctuation +'const' Keyword ' ' Text -'i' Name -'::' Operator -'Integer' Keyword.Type -')' Punctuation +'ByteArray' Name ' ' Text '=' Operator ' ' Text -'(' Punctuation -'start' Name -'(' Punctuation -'s' Name -')' Punctuation -' ' Text -'<=' Operator -' ' Text -'i' Name -' ' Text -'<=' Operator -' ' Text -'length' Name -'(' Punctuation -'s' Name -')' Punctuation -')' Punctuation -'\n' Text - -'function' Keyword -' ' Text -'isvalid' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'i' Name -'::' Operator -'Integer' Keyword.Type -')' Punctuation -'\n' Text - -' ' Text -'try' Keyword -'\n' Text - -' ' Text -'next' Name -'(' Punctuation -'s' Name +'Union' Keyword.Type +'{' Punctuation +'Vector' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation ',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'true' Keyword.Constant -'\n' Text - -' ' Text -'catch' Keyword -'\n' Text - -' ' Text -'false' Keyword.Constant -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -'end' Keyword +'Vector' Keyword.Type +'{' Punctuation +'Int8' Keyword.Type +'}' Punctuation +'}' Punctuation '\n' Text '\n' Text -'prevind' Name -'(' Punctuation -'s' Name -'::' Operator -'DirectIndexString' Keyword.Type -',' Punctuation +'@inline' Name.Decorator ' ' Text -'i' Name -'::' Operator -'Integer' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'i' Name -'-' Operator -'1' Literal.Number.Integer -'\n' Text - -'thisind' Name +'between' Name '(' Punctuation -'s' Name +'b' Name '::' Operator -'DirectIndexString' Keyword.Type +'T' Keyword.Type ',' Punctuation ' ' Text -'i' Name -'::' Operator -'Integer' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'i' Name -'\n' Text - -'nextind' Name -'(' Punctuation -'s' Name +'lo' Name '::' Operator -'DirectIndexString' Keyword.Type +'T' Keyword.Type ',' Punctuation ' ' Text -'i' Name +'hi' Name '::' Operator -'Integer' Keyword.Type +'T' Keyword.Type ')' Punctuation ' ' Text -'=' Operator -' ' Text -'i' Name -'+' Operator -'1' Literal.Number.Integer -'\n' Text - -'\n' Text - -'prevind' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation +'where' Keyword ' ' Text -'i' Name -'::' Operator +'{' Punctuation +'T' Keyword.Type +'<:' Operator 'Integer' Keyword.Type -')' Punctuation +'}' Punctuation ' ' Text '=' Operator ' ' Text -'thisind' Name '(' Punctuation -'s' Name -',' Punctuation -'thisind' Name -'(' Punctuation -'s' Name -',' Punctuation -'i' Name -')' Punctuation -'-' Operator -'1' Literal.Number.Integer -')' Punctuation -'\n' Text - -'\n' Text - -'function' Keyword +'lo' Name ' ' Text -'thisind' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation +'≤' Operator ' ' Text -'i' Name -'::' Operator -'Integer' Keyword.Type +'b' Name ')' Punctuation -'\n' Text - -' ' Text -'for' Keyword ' ' Text -'j' Name +'&' Operator ' ' Text -'=' Operator +'(' Punctuation +'b' Name ' ' Text -'i' Name -':' Operator -'-' Operator -'1' Literal.Number.Integer -':' Operator -'1' Literal.Number.Integer -'\n' Text - -' ' Text -'if' Keyword +'≤' Operator ' ' Text -'isvalid' Name -'(' Punctuation -'s' Name -',' Punctuation -'j' Name +'hi' Name ')' Punctuation '\n' Text -' ' Text -'return' Keyword -' ' Text -'j' Name '\n' Text -' ' Text -'end' Keyword +'## constructors and conversions ##' Comment '\n' Text -' ' Text -'end' Keyword '\n' Text -' ' Text -'return' Keyword -' ' Text -'0' Literal.Number.Integer -' ' Text -'# out of range' Comment +'# String constructor docstring from boot.jl, workaround for #16730' Comment '\n' Text -'end' Keyword +'# and the unavailability of @doc in boot.jl context.' Comment '\n' Text +'"""' Literal.String +'\n String(v::AbstractVector{UInt8})\n\nCreate a new `String` object from a byte vector `v` containing UTF-8 encoded\ncharacters. If `v` is `Vector{UInt8}` it will be truncated to zero length and\nfuture modification of `v` cannot affect the contents of the resulting string.\nTo avoid truncation of `Vector{UInt8}` data, use `String(copy(v))`; for other\n`AbstractVector` types, `String(v)` already makes a copy.\n\nWhen possible, the memory of `v` will be used without copying when the `String`\nobject is created. This is guaranteed to be the case for byte vectors returned\nby [`take!`](@ref) on a writable [`IOBuffer`](@ref) and by calls to\n[`read(io, nb)`](@ref). This allows zero-copy conversion of I/O data to strings.\nIn other cases, `Vector{UInt8}` data may be copied, but `v` is truncated anyway\nto guarantee consistent behavior.\n' Literal.String + +'"""' Literal.String '\n' Text -'function' Keyword -' ' Text -'nextind' Name +'String' Keyword.Type '(' Punctuation -'s' Name +'v' Name '::' Operator -'String' Name -',' Punctuation -' ' Text -'i' Name -'::' Operator -'Integer' Keyword.Type +'AbstractVector' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation ')' Punctuation -'\n' Text - -' ' Text -'for' Keyword -' ' Text -'j' Name ' ' Text '=' Operator ' ' Text -'i' Name -'+' Operator -'1' Literal.Number.Integer -':' Operator -'length' Name +'String' Keyword.Type '(' Punctuation -'s' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'isvalid' Name +'copyto!' Name +'(' Punctuation +'StringVector' Name '(' Punctuation -'s' Name -',' Punctuation -'j' Name -')' Punctuation -'\n' Text - -' ' Text -'return' Keyword -' ' Text -'j' Name -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text 'length' Name '(' Punctuation -'s' Name +'v' Name ')' Punctuation -'+' Operator -'1' Literal.Number.Integer -' ' Text -'# out of range' Comment -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'ind2chr' Name -'(' Punctuation -'s' Name -'::' Operator -'DirectIndexString' Keyword.Type -',' Punctuation -' ' Text -'i' Name -'::' Operator -'Integer' Keyword.Type ')' Punctuation -' ' Text -'=' Operator -' ' Text -'i' Name -'\n' Text - -'chr2ind' Name -'(' Punctuation -'s' Name -'::' Operator -'DirectIndexString' Keyword.Type ',' Punctuation ' ' Text -'i' Name -'::' Operator -'Integer' Keyword.Type +'v' Name +')' Punctuation ')' Punctuation -' ' Text -'=' Operator -' ' Text -'i' Name -'\n' Text - '\n' Text -'function' Keyword -' ' Text -'ind2chr' Name +'String' Keyword.Type '(' Punctuation -'s' Name +'v' Name '::' Operator -'String' Name -',' Punctuation -' ' Text -'i' Name -'::' Operator -'Integer' Keyword.Type +'Vector' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation ')' Punctuation -'\n' Text - -' ' Text -'s' Name -'[' Punctuation -'i' Name -']' Punctuation -' ' Text -'# throws error if invalid' Comment -'\n' Text - -' ' Text -'j' Name ' ' Text '=' Operator ' ' Text -'1' Literal.Number.Integer -'\n' Text - -' ' Text -'k' Name -' ' Text -'=' Operator -' ' Text -'start' Name +'ccall' Keyword '(' Punctuation -'s' Name -')' Punctuation -'\n' Text - -' ' Text -'while' Keyword -' ' Text -'true' Keyword.Constant -'\n' Text - -' ' Text -'c' Name +':jl_array_to_string' Literal.String.Symbol ',' Punctuation ' ' Text -'l' Name -' ' Text -'=' Operator -' ' Text -'next' Name -'(' Punctuation -'s' Name +'Ref' Keyword.Type +'{' Punctuation +'String' Keyword.Type +'}' Punctuation ',' Punctuation -'k' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'i' Name -' ' Text -'<=' Operator -' ' Text -'k' Name -'\n' Text - -' ' Text -'return' Keyword -' ' Text -'j' Name -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'j' Name -' ' Text -'+=' Operator -' ' Text -'1' Literal.Number.Integer -'\n' Text - -' ' Text -'k' Name ' ' Text -'=' Operator -' ' Text -'l' Name -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'function' Keyword -' ' Text -'chr2ind' Name '(' Punctuation -'s' Name -'::' Operator -'String' Name +'Any' Keyword.Type ',' Punctuation -' ' Text -'i' Name -'::' Operator -'Integer' Keyword.Type -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'i' Name -' ' Text -'<' Operator -' ' Text -'1' Literal.Number.Integer -'\n' Text - -' ' Text -'return' Keyword -' ' Text -'i' Name -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'j' Name -' ' Text -'=' Operator -' ' Text -'1' Literal.Number.Integer -'\n' Text - -' ' Text -'k' Name -' ' Text -'=' Operator -' ' Text -'start' Name -'(' Punctuation -'s' Name ')' Punctuation -'\n' Text - -' ' Text -'while' Keyword -' ' Text -'true' Keyword.Constant -'\n' Text - -' ' Text -'c' Name ',' Punctuation ' ' Text -'l' Name -' ' Text -'=' Operator -' ' Text -'next' Name -'(' Punctuation -'s' Name -',' Punctuation -'k' Name +'v' Name ')' Punctuation '\n' Text -' ' Text -'if' Keyword -' ' Text -'i' Name -' ' Text -'==' Operator -' ' Text -'j' Name -'\n' Text - -' ' Text -'return' Keyword -' ' Text -'k' Name -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'j' Name -' ' Text -'+=' Operator -' ' Text -'1' Literal.Number.Integer -'\n' Text - -' ' Text -'k' Name -' ' Text -'=' Operator -' ' Text -'l' Name -'\n' Text - -' ' Text -'end' Keyword '\n' Text -'end' Keyword -'\n' Text +'"""' Literal.String +'\n unsafe_string(p::Ptr{UInt8}, [length::Integer])\n\nCopy a string from the address of a C-style (NUL-terminated) string encoded as UTF-8.\n(The pointer can be safely freed afterwards.) If `length` is specified\n(the length of the data in bytes), the string does not have to be NUL-terminated.\n\nThis function is labeled ' Literal.String +'"' Literal.String +'unsafe' Literal.String +'"' Literal.String +' because it will crash if `p` is not\na valid memory address to data of the requested length.\n' Literal.String +'"""' Literal.String '\n' Text 'function' Keyword ' ' Text -'strchr' Name +'unsafe_string' Name '(' Punctuation -'s' Name +'p' Name '::' Operator -'String' Name +'Union' Keyword.Type +'{' Punctuation +'Ptr' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation ',' Punctuation -' ' Text -'c' Name -'::' Operator -'Char' Keyword.Type +'Ptr' Keyword.Type +'{' Punctuation +'Int8' Keyword.Type +'}' Punctuation +'}' Punctuation ',' Punctuation ' ' Text -'i' Name +'len' Name '::' Operator 'Integer' Keyword.Type ')' Punctuation '\n' Text ' ' Text -'i' Name -' ' Text -'=' Operator -' ' Text -'nextind' Name -'(' Punctuation -'s' Name -',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'while' Keyword -' ' Text -'!' Operator -'done' Name -'(' Punctuation -'s' Name -',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'d' Name -',' Punctuation -' ' Text -'j' Name -' ' Text -'=' Operator -' ' Text -'next' Name -'(' Punctuation -'s' Name -',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'c' Name +'p' Name ' ' Text '==' Operator ' ' Text -'d' Name -'\n' Text - -' ' Text -'return' Keyword -' ' Text -'i' Name -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'i' Name -' ' Text -'=' Operator -' ' Text -'j' Name -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'return' Keyword -' ' Text -'0' Literal.Number.Integer -'\n' Text - -'end' Keyword -'\n' Text - -'strchr' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'c' Name -'::' Operator -'Char' Keyword.Type -')' Punctuation +'C_NULL' Name.Builtin ' ' Text -'=' Operator +'&&' Operator ' ' Text -'strchr' Name +'throw' Name '(' Punctuation -'s' Name -',' Punctuation -' ' Text -'c' Name -',' Punctuation -' ' Text -'start' Name +'ArgumentError' Keyword.Type '(' Punctuation -'s' Name +'"' Literal.String +'cannot convert NULL to string' Literal.String +'"' Literal.String ')' Punctuation ')' Punctuation '\n' Text -'contains' Name +' ' Text +'ccall' Keyword '(' Punctuation -'s' Name -'::' Operator -'String' Name +':jl_pchar_to_string' Literal.String.Symbol ',' Punctuation ' ' Text -'c' Name -'::' Operator -'Char' Keyword.Type -')' Punctuation -' ' Text -'=' Operator +'Ref' Keyword.Type +'{' Punctuation +'String' Keyword.Type +'}' Punctuation +',' Punctuation ' ' Text '(' Punctuation -'strchr' Name -'(' Punctuation -'s' Name +'Ptr' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation ',' Punctuation -'c' Name -')' Punctuation -'!=' Operator -'0' Literal.Number.Integer -')' Punctuation -'\n' Text - -'\n' Text - -'function' Keyword ' ' Text -'chars' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name +'Int' Keyword.Type ')' Punctuation -'\n' Text - -' ' Text -'cx' Name -' ' Text -'=' Operator -' ' Text -'Array' Keyword.Type -'(' Punctuation -'Char' Keyword.Type ',' Punctuation -'strlen' Name -'(' Punctuation -'s' Name -')' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'i' Name -' ' Text -'=' Operator -' ' Text -'0' Literal.Number.Integer -'\n' Text - -' ' Text -'for' Keyword -' ' Text -'c' Name -' ' Text -'in' Keyword.Pseudo -' ' Text -'s' Name -'\n' Text - -' ' Text -'cx' Name -'[' Punctuation -'i' Name -' ' Text -'+=' Operator -' ' Text -'1' Literal.Number.Integer -']' Punctuation ' ' Text -'=' Operator -' ' Text -'c' Name -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'return' Keyword +'p' Name +',' Punctuation ' ' Text -'cx' Name +'len' Name +')' Punctuation '\n' Text 'end' Keyword '\n' Text -'\n' Text - 'function' Keyword ' ' Text -'cmp' Name +'unsafe_string' Name '(' Punctuation -'a' Name +'p' Name '::' Operator -'String' Name +'Union' Keyword.Type +'{' Punctuation +'Ptr' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation ',' Punctuation -' ' Text -'b' Name -'::' Operator -'String' Name -')' Punctuation -'\n' Text - -' ' Text -'i' Name -' ' Text -'=' Operator -' ' Text -'start' Name -'(' Punctuation -'a' Name +'Ptr' Keyword.Type +'{' Punctuation +'Int8' Keyword.Type +'}' Punctuation +'}' Punctuation ')' Punctuation '\n' Text ' ' Text -'j' Name -' ' Text -'=' Operator +'p' Name ' ' Text -'start' Name -'(' Punctuation -'b' Name -')' Punctuation -'\n' Text - -' ' Text -'while' Keyword +'==' Operator ' ' Text -'!' Operator -'done' Name -'(' Punctuation -'a' Name -',' Punctuation -'i' Name -')' Punctuation +'C_NULL' Name.Builtin ' ' Text '&&' Operator ' ' Text -'!' Operator -'done' Name +'throw' Name '(' Punctuation -'b' Name -',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'c' Name -',' Punctuation -' ' Text -'i' Name -' ' Text -'=' Operator -' ' Text -'next' Name +'ArgumentError' Keyword.Type '(' Punctuation -'a' Name -',' Punctuation -'i' Name +'"' Literal.String +'cannot convert NULL to string' Literal.String +'"' Literal.String ')' Punctuation -'\n' Text - -' ' Text -'d' Name -',' Punctuation -' ' Text -'j' Name -' ' Text -'=' Operator -' ' Text -'next' Name -'(' Punctuation -'b' Name -',' Punctuation -'j' Name ')' Punctuation '\n' Text -' ' Text -'if' Keyword -' ' Text -'c' Name -' ' Text -'!=' Operator -' ' Text -'d' Name -'\n' Text - -' ' Text -'return' Keyword -' ' Text -'c' Name -' ' Text -'<' Operator -' ' Text -'d' Name -' ' Text -'?' Operator -' ' Text -'-' Operator -'1' Literal.Number.Integer -' ' Text -':' Operator -' ' Text -'+' Operator -'1' Literal.Number.Integer -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - ' ' Text -'end' Keyword -'\n' Text - -' ' Text -'done' Name +'ccall' Keyword '(' Punctuation -'a' Name +':jl_cstr_to_string' Literal.String.Symbol ',' Punctuation -'i' Name -')' Punctuation -' ' Text -'&&' Operator ' ' Text -'!' Operator -'done' Name -'(' Punctuation -'b' Name +'Ref' Keyword.Type +'{' Punctuation +'String' Keyword.Type +'}' Punctuation ',' Punctuation -'j' Name -')' Punctuation -' ' Text -'?' Operator ' ' Text -'-' Operator -'1' Literal.Number.Integer -' ' Text -':' Operator -'\n' Text - -' ' Text -'!' Operator -'done' Name '(' Punctuation -'a' Name +'Ptr' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation ',' Punctuation -'i' Name ')' Punctuation -' ' Text -'&&' Operator -' ' Text -'done' Name -'(' Punctuation -'b' Name ',' Punctuation -'j' Name -')' Punctuation -' ' Text -'?' Operator -' ' Text -'+' Operator -'1' Literal.Number.Integer -' ' Text -':' Operator ' ' Text -'0' Literal.Number.Integer +'p' Name +')' Punctuation '\n' Text 'end' Keyword @@ -1738,1265 +567,391 @@ '\n' Text -'isequal' Name +'_string_n' Name '(' Punctuation -'a' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'b' Name +'n' Name '::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'cmp' Name -'(' Punctuation -'a' Name -',' Punctuation -'b' Name +'Integer' Keyword.Type ')' Punctuation ' ' Text -'==' Operator -' ' Text -'0' Literal.Number.Integer -'\n' Text - -'isless' Name -'(' Punctuation -'a' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'b' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text '=' Operator ' ' Text -'cmp' Name +'ccall' Keyword '(' Punctuation -'a' Name +':jl_alloc_string' Literal.String.Symbol ',' Punctuation -'b' Name -')' Punctuation ' ' Text -'<' Operator -' ' Text -'0' Literal.Number.Integer -'\n' Text - -'\n' Text - -'# faster comparisons for byte strings' Comment -'\n' Text - -'\n' Text - -'cmp' Name -'(' Punctuation -'a' Name -'::' Operator -'ByteString' Name +'Ref' Keyword.Type +'{' Punctuation +'String' Keyword.Type +'}' Punctuation ',' Punctuation ' ' Text -'b' Name -'::' Operator -'ByteString' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'lexcmp' Name '(' Punctuation -'a' Name -'.' Operator -'data' Name +'Csize_t' Keyword.Type ',' Punctuation -' ' Text -'b' Name -'.' Operator -'data' Name ')' Punctuation -'\n' Text - -'isequal' Name -'(' Punctuation -'a' Name -'::' Operator -'ByteString' Name ',' Punctuation ' ' Text -'b' Name -'::' Operator -'ByteString' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'length' Name -'(' Punctuation -'a' Name -')' Punctuation -'==' Operator -'length' Name -'(' Punctuation -'b' Name -')' Punctuation -' ' Text -'&&' Operator -' ' Text -'cmp' Name -'(' Punctuation -'a' Name -',' Punctuation -'b' Name +'n' Name ')' Punctuation -'==' Operator -'0' Literal.Number.Integer -'\n' Text - '\n' Text -'## character column width function ##' Comment '\n' Text -'\n' Text +'"""' Literal.String +'\n String(s::AbstractString)\n\nConvert a string to a contiguous byte array representation encoded as UTF-8 bytes.\nThis representation is often appropriate for passing strings to C.\n' Literal.String -'charwidth' Name -'(' Punctuation -'c' Name -'::' Operator -'Char' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'max' Name -'(' Punctuation -'0' Literal.Number.Integer -',' Punctuation -'int' Name -'(' Punctuation -'ccall' Keyword -'(' Punctuation -':' Operator -'wcwidth' Name -',' Punctuation -' ' Text -'Int32' Keyword.Type -',' Punctuation -' ' Text -'(' Punctuation -'Char' Keyword.Type -',' Punctuation -')' Punctuation -',' Punctuation -' ' Text -'c' Name -')' Punctuation -')' Punctuation -')' Punctuation +'"""' Literal.String '\n' Text -'strwidth' Name +'String' Keyword.Type '(' Punctuation 's' Name '::' Operator -'String' Name +'AbstractString' Keyword.Type ')' Punctuation ' ' Text '=' Operator ' ' Text +'print_to_string' Name '(' Punctuation -'w' Name -'=' Operator -'0' Literal.Number.Integer -';' Punctuation -' ' Text -'for' Keyword -' ' Text -'c' Name -' ' Text -'in' Keyword.Pseudo -' ' Text 's' Name -';' Punctuation -' ' Text -'w' Name -' ' Text -'+=' Operator -' ' Text -'charwidth' Name -'(' Punctuation -'c' Name -')' Punctuation -';' Punctuation -' ' Text -'end' Keyword -';' Punctuation -' ' Text -'w' Name ')' Punctuation '\n' Text -'strwidth' Name +'@pure' Name.Decorator +' ' Text +'String' Keyword.Type '(' Punctuation 's' Name '::' Operator -'ByteString' Name +'Symbol' Keyword.Type ')' Punctuation ' ' Text '=' Operator ' ' Text -'ccall' Keyword +'unsafe_string' Name '(' Punctuation -':' Operator -'u8_strwidth' Name -',' Punctuation -' ' Text -'Int' Keyword.Type -',' Punctuation -' ' Text +'unsafe_convert' Name '(' Punctuation 'Ptr' Keyword.Type '{' Punctuation -'Uint8' Name +'UInt8' Keyword.Type '}' Punctuation ',' Punctuation -')' Punctuation -',' Punctuation ' ' Text 's' Name -'.' Operator -'data' Name ')' Punctuation -'\n' Text - -'# TODO: implement and use u8_strnwidth that takes a length argument' Comment -'\n' Text - -'\n' Text - -'## generic string uses only length and next ##' Comment -'\n' Text - -'\n' Text - -'type' Keyword -' ' Text -'GenericString' Name -' ' Text -'<:' Operator -' ' Text -'String' Name -'\n' Text - -' ' Text -'string' Name -'::' Operator -'String' Name -'\n' Text - -'end' Keyword +')' Punctuation '\n' Text '\n' Text -'length' Name +'unsafe_wrap' Name '(' Punctuation +'::' Operator +'Type' Keyword.Type +'{' Punctuation +'Vector' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation +'}' Punctuation +',' Punctuation +' ' Text 's' Name '::' Operator -'GenericString' Name +'String' Keyword.Type ')' Punctuation ' ' Text '=' Operator ' ' Text -'length' Name -'(' Punctuation -'s' Name -'.' Operator -'string' Name -')' Punctuation -'\n' Text - -'next' Name +'ccall' Keyword '(' Punctuation -'s' Name -'::' Operator -'GenericString' Name +':jl_string_to_array' Literal.String.Symbol ',' Punctuation ' ' Text -'i' Name -'::' Operator -'Int' Keyword.Type -')' Punctuation -' ' Text -'=' Operator +'Ref' Keyword.Type +'{' Punctuation +'Vector' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation +'}' Punctuation +',' Punctuation ' ' Text -'next' Name '(' Punctuation -'s' Name -'.' Operator -'string' Name +'Any' Keyword.Type +',' Punctuation +')' Punctuation ',' Punctuation ' ' Text -'i' Name +'s' Name ')' Punctuation '\n' Text '\n' Text -'## plain old character arrays ##' Comment -'\n' Text - -'\n' Text - -'type' Keyword -' ' Text -'CharString' Name -' ' Text -'<:' Operator -' ' Text -'String' Name -'\n' Text - -' ' Text -'chars' Name -'::' Operator -'Array' Keyword.Type +'Vector' Keyword.Type '{' Punctuation -'Char' Keyword.Type -',' Punctuation -'1' Literal.Number.Integer +'UInt8' Keyword.Type '}' Punctuation -'\n' Text - -'\n' Text - -' ' Text -'CharString' Name '(' Punctuation -'a' Name +'s' Name '::' Operator -'Array' Keyword.Type +'CodeUnits' Keyword.Type '{' Punctuation -'Char' Keyword.Type +'UInt8' Keyword.Type ',' Punctuation -'1' Literal.Number.Integer +'String' Keyword.Type '}' Punctuation ')' Punctuation ' ' Text '=' Operator ' ' Text -'new' Name -'(' Punctuation -'a' Name -')' Punctuation -'\n' Text - -' ' Text -'CharString' Name +'copyto!' Name '(' Punctuation -'c' Name -'::' Operator -'Char' Keyword.Type -'.' Operator -'.' Operator -'.' Operator -')' Punctuation -' ' Text -'=' Operator -' ' Text -'new' Name +'Vector' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation '(' Punctuation -'[' Punctuation -' ' Text -'c' Name -'[' Punctuation -'i' Name -']' Punctuation -' ' Text -'|' Operator +'undef' Name.Builtin +',' Punctuation ' ' Text -'i' Name -'=' Operator -'1' Literal.Number.Integer -':' Operator 'length' Name '(' Punctuation -'c' Name -')' Punctuation -' ' Text -']' Punctuation -')' Punctuation -'\n' Text - -'end' Keyword -'\n' Text - -'CharString' Name -'(' Punctuation -'x' Name -'.' Operator -'.' Operator -'.' Operator -')' Punctuation -' ' Text -'=' Operator -' ' Text -'CharString' Name -'(' Punctuation -'map' Name -'(' Punctuation -'char' Name -',' Punctuation -'x' Name +'s' Name ')' Punctuation -'.' Operator -'.' Operator -'.' Operator ')' Punctuation -'\n' Text - -'\n' Text - -'next' Name -'(' Punctuation -'s' Name -'::' Operator -'CharString' Name ',' Punctuation ' ' Text -'i' Name -'::' Operator -'Int' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'(' Punctuation 's' Name -'.' Operator -'chars' Name -'[' Punctuation -'i' Name -']' Punctuation -',' Punctuation -' ' Text -'i' Name -'+' Operator -'1' Literal.Number.Integer ')' Punctuation '\n' Text -'length' Name +'Vector' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation '(' Punctuation 's' Name '::' Operator -'CharString' Name +'String' Keyword.Type ')' Punctuation ' ' Text '=' Operator ' ' Text -'length' Name +'Vector' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation +'(' Punctuation +'codeunits' Name '(' Punctuation 's' Name -'.' Operator -'chars' Name +')' Punctuation ')' Punctuation '\n' Text -'strlen' Name +'Array' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation '(' Punctuation 's' Name '::' Operator -'CharString' Name +'String' Keyword.Type ')' Punctuation -' ' Text +' ' Text '=' Operator ' ' Text -'length' Name +'Vector' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation +'(' Punctuation +'codeunits' Name '(' Punctuation 's' Name ')' Punctuation +')' Punctuation '\n' Text '\n' Text -'string' Name -'(' Punctuation -'c' Name -'::' Operator -'Char' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'CharString' Name -'(' Punctuation -'c' Name -')' Punctuation -'\n' Text - -'string' Name +'String' Keyword.Type '(' Punctuation -'c' Name +'s' Name '::' Operator -'Char' Keyword.Type +'CodeUnits' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type ',' Punctuation -' ' Text -'x' Name -'::' Operator -'Char' Keyword.Type -'.' Operator -'.' Operator -'.' Operator +'String' Keyword.Type +'}' Punctuation ')' Punctuation ' ' Text '=' Operator ' ' Text -'CharString' Name -'(' Punctuation -'c' Name -',' Punctuation -' ' Text -'x' Name -'.' Operator -'.' Operator +'s' Name '.' Operator -')' Punctuation -'\n' Text - -'\n' Text - -'## substrings reference original strings ##' Comment -'\n' Text - -'\n' Text - -'type' Keyword -' ' Text -'SubString' Keyword.Type -' ' Text -'<:' Operator -' ' Text -'String' Name -'\n' Text - -' ' Text -'string' Name -'::' Operator -'String' Name +'s' Name '\n' Text -' ' Text -'offset' Name -'::' Operator -'Int' Keyword.Type '\n' Text -' ' Text -'length' Name -'::' Operator -'Int' Keyword.Type +'## low-level functions ##' Comment '\n' Text '\n' Text -' ' Text -'SubString' Keyword.Type +'pointer' Name '(' Punctuation 's' Name '::' Operator -'String' Name -',' Punctuation -' ' Text -'i' Name -'::' Operator -'Int' Keyword.Type -',' Punctuation -' ' Text -'j' Name -'::' Operator -'Int' Keyword.Type +'String' Keyword.Type ')' Punctuation ' ' Text '=' Operator ' ' Text -'new' Name -'(' Punctuation -'s' Name -',' Punctuation -' ' Text -'i' Name -'-' Operator -'1' Literal.Number.Integer -',' Punctuation -' ' Text -'j' Name -'-' Operator -'i' Name -'+' Operator -'1' Literal.Number.Integer -')' Punctuation -'\n' Text - -' ' Text -'SubString' Keyword.Type -'(' Punctuation -'s' Name -'::' Operator -'SubString' Keyword.Type -',' Punctuation -' ' Text -'i' Name -'::' Operator -'Int' Keyword.Type -',' Punctuation -' ' Text -'j' Name -'::' Operator -'Int' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -'\n' Text - -' ' Text -'new' Name +'unsafe_convert' Name '(' Punctuation -'s' Name -'.' Operator -'string' Name +'Ptr' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation ',' Punctuation ' ' Text -'i' Name -'-' Operator -'1' Literal.Number.Integer -'+' Operator 's' Name -'.' Operator -'offset' Name -',' Punctuation -' ' Text -'j' Name -'-' Operator -'i' Name -'+' Operator -'1' Literal.Number.Integer ')' Punctuation '\n' Text -'end' Keyword -'\n' Text - -'SubString' Keyword.Type +'pointer' Name '(' Punctuation 's' Name '::' Operator -'String' Name +'String' Keyword.Type ',' Punctuation ' ' Text 'i' Name '::' Operator 'Integer' Keyword.Type -',' Punctuation -' ' Text -'j' Name -'::' Operator -'Integer' Keyword.Type ')' Punctuation ' ' Text '=' Operator ' ' Text -'SubString' Keyword.Type +'pointer' Name '(' Punctuation 's' Name -',' Punctuation -' ' Text -'int' Name -'(' Punctuation -'i' Name ')' Punctuation -',' Punctuation ' ' Text -'int' Name -'(' Punctuation -'j' Name -')' Punctuation -')' Punctuation -'\n' Text - -'\n' Text - -'function' Keyword -' ' Text -'next' Name -'(' Punctuation -'s' Name -'::' Operator -'SubString' Keyword.Type -',' Punctuation +'+' Operator ' ' Text -'i' Name -'::' Operator 'Int' Keyword.Type -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'i' Name -' ' Text -'<' Operator -' ' Text -'1' Literal.Number.Integer -' ' Text -'||' Operator -' ' Text -'i' Name -' ' Text -'>' Operator -' ' Text -'s' Name -'.' Operator -'length' Name -'\n' Text - -' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'s' Literal.String -'t' Literal.String -'r' Literal.String -'i' Literal.String -'n' Literal.String -'g' Literal.String -' ' Literal.String -'i' Literal.String -'n' Literal.String -'d' Literal.String -'e' Literal.String -'x' Literal.String -' ' Literal.String -'o' Literal.String -'u' Literal.String -'t' Literal.String -' ' Literal.String -'o' Literal.String -'f' Literal.String -' ' Literal.String -'b' Literal.String -'o' Literal.String -'u' Literal.String -'n' Literal.String -'d' Literal.String -'s' Literal.String -'"' Literal.String -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'c' Name -',' Punctuation -' ' Text -'i' Name -' ' Text -'=' Operator -' ' Text -'next' Name '(' Punctuation -'s' Name -'.' Operator -'string' Name -',' Punctuation -' ' Text -'i' Name -'+' Operator -'s' Name -'.' Operator -'offset' Name -')' Punctuation -'\n' Text - -' ' Text -'c' Name -',' Punctuation -' ' Text 'i' Name -'-' Operator -'s' Name -'.' Operator -'offset' Name -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'length' Name -'(' Punctuation -'s' Name -'::' Operator -'SubString' Keyword.Type ')' Punctuation -' ' Text -'=' Operator -' ' Text -'s' Name -'.' Operator -'length' Name -'\n' Text - -'# TODO: strlen(s::SubString) = ??' Comment -'\n' Text - -"# default implementation will work but it's slow" Comment -'\n' Text - -'# can this be delegated efficiently somehow?' Comment -'\n' Text - -'# that may require additional string interfaces' Comment -'\n' Text - -'\n' Text - -'function' Keyword -' ' Text -'ref' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'r' Name '::' Operator -'Range1' Name -'{' Punctuation 'Int' Keyword.Type -'}' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword ' ' Text -'first' Name -'(' Punctuation -'r' Name -')' Punctuation -' ' Text -'<' Operator +'-' Operator ' ' Text '1' Literal.Number.Integer -' ' Text -'||' Operator -' ' Text -'length' Name -'(' Punctuation -'s' Name -')' Punctuation -' ' Text -'<' Operator -' ' Text -'last' Name -'(' Punctuation -'r' Name -')' Punctuation -'\n' Text - -' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'i' Literal.String -'n' Literal.String -' ' Literal.String -'s' Literal.String -'u' Literal.String -'b' Literal.String -'s' Literal.String -'t' Literal.String -'r' Literal.String -'i' Literal.String -'n' Literal.String -'g' Literal.String -' ' Literal.String -'s' Literal.String -'l' Literal.String -'i' Literal.String -'c' Literal.String -'e' Literal.String -':' Literal.String -' ' Literal.String -'i' Literal.String -'n' Literal.String -'d' Literal.String -'e' Literal.String -'x' Literal.String -' ' Literal.String -'o' Literal.String -'u' Literal.String -'t' Literal.String -' ' Literal.String -'o' Literal.String -'f' Literal.String -' ' Literal.String -'r' Literal.String -'a' Literal.String -'n' Literal.String -'g' Literal.String -'e' Literal.String -'"' Literal.String -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'SubString' Keyword.Type -'(' Punctuation -'s' Name -',' Punctuation -' ' Text -'first' Name -'(' Punctuation -'r' Name -')' Punctuation -',' Punctuation -' ' Text -'last' Name -'(' Punctuation -'r' Name -')' Punctuation -')' Punctuation -'\n' Text - -'end' Keyword -'\n' Text - '\n' Text -'## efficient representation of repeated strings ##' Comment '\n' Text -'\n' Text - -'type' Keyword -' ' Text -'RepString' Keyword.Type -' ' Text -'<:' Operator +'@pure' Name.Decorator ' ' Text -'String' Name -'\n' Text - -' ' Text -'string' Name -'::' Operator -'String' Name -'\n' Text - -' ' Text -'repeat' Name -'::' Operator -'Integer' Keyword.Type -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'length' Name +'ncodeunits' Name '(' Punctuation 's' Name '::' Operator -'RepString' Keyword.Type +'String' Keyword.Type ')' Punctuation ' ' Text '=' Operator ' ' Text -'length' Name +'Core' Name +'.' Operator +'sizeof' Name '(' Punctuation 's' Name -'.' Operator -'string' Name ')' Punctuation -'*' Operator -'s' Name -'.' Operator -'repeat' Name '\n' Text -'strlen' Name +'codeunit' Name '(' Punctuation 's' Name '::' Operator -'RepString' Keyword.Type +'String' Keyword.Type ')' Punctuation ' ' Text '=' Operator ' ' Text -'strlen' Name -'(' Punctuation -'s' Name -'.' Operator -'string' Name -')' Punctuation -'*' Operator -'s' Name -'.' Operator -'repeat' Name +'UInt8' Keyword.Type '\n' Text '\n' Text +'@inline' Name.Decorator +' ' Text 'function' Keyword ' ' Text -'next' Name +'codeunit' Name '(' Punctuation 's' Name '::' Operator -'RepString' Keyword.Type +'String' Keyword.Type ',' Punctuation ' ' Text 'i' Name '::' Operator -'Int' Keyword.Type +'Integer' Keyword.Type ')' Punctuation '\n' Text ' ' Text -'if' Keyword -' ' Text -'i' Name -' ' Text -'<' Operator -' ' Text -'1' Literal.Number.Integer +'@boundscheck' Name.Decorator ' ' Text -'||' Operator -' ' Text -'i' Name -' ' Text -'>' Operator -' ' Text -'length' Name +'checkbounds' Name '(' Punctuation 's' Name -')' Punctuation -'\n' Text - -' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'s' Literal.String -'t' Literal.String -'r' Literal.String -'i' Literal.String -'n' Literal.String -'g' Literal.String -' ' Literal.String -'i' Literal.String -'n' Literal.String -'d' Literal.String -'e' Literal.String -'x' Literal.String -' ' Literal.String -'o' Literal.String -'u' Literal.String -'t' Literal.String -' ' Literal.String -'o' Literal.String -'f' Literal.String -' ' Literal.String -'b' Literal.String -'o' Literal.String -'u' Literal.String -'n' Literal.String -'d' Literal.String -'s' Literal.String -'"' Literal.String -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'j' Name -' ' Text -'=' Operator +',' Punctuation ' ' Text -'mod1' Name -'(' Punctuation 'i' Name -',' Punctuation -'length' Name -'(' Punctuation -'s' Name -'.' Operator -'string' Name -')' Punctuation ')' Punctuation '\n' Text ' ' Text -'c' Name -',' Punctuation -' ' Text -'k' Name +'b' Name ' ' Text '=' Operator ' ' Text -'next' Name -'(' Punctuation -'s' Name +'GC' Name '.' Operator -'string' Name -',' Punctuation -' ' Text -'j' Name -')' Punctuation -'\n' Text - -' ' Text -'c' Name -',' Punctuation +'@preserve' Name.Decorator ' ' Text -'k' Name -'-' Operator -'j' Name -'+' Operator -'i' Name -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'function' Keyword +'s' Name ' ' Text -'repeat' Name +'unsafe_load' Name +'(' Punctuation +'pointer' Name '(' Punctuation 's' Name -'::' Operator -'String' Name ',' Punctuation ' ' Text -'r' Name -'::' Operator -'Integer' Keyword.Type +'i' Name ')' Punctuation -'\n' Text - -' ' Text -'r' Name -' ' Text -'<' Operator -' ' Text -'0' Literal.Number.Integer -' ' Text -'?' Operator -' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'c' Literal.String -'a' Literal.String -'n' Literal.String -"'" Literal.String -'t' Literal.String -' ' Literal.String -'r' Literal.String -'e' Literal.String -'p' Literal.String -'e' Literal.String -'a' Literal.String -'t' Literal.String -' ' Literal.String -'a' Literal.String -' ' Literal.String -'s' Literal.String -'t' Literal.String -'r' Literal.String -'i' Literal.String -'n' Literal.String -'g' Literal.String -' ' Literal.String -'"' Literal.String -',' Punctuation -'r' Name -',' Punctuation -'"' Literal.String -' ' Literal.String -'t' Literal.String -'i' Literal.String -'m' Literal.String -'e' Literal.String -'s' Literal.String -'"' Literal.String ')' Punctuation -' ' Text -':' Operator -'\n' Text - -' ' Text -'r' Name -' ' Text -'==' Operator -' ' Text -'0' Literal.Number.Integer -' ' Text -'?' Operator -' ' Text -'"' Literal.String -'"' Literal.String -' ' Text -':' Operator '\n' Text ' ' Text -'r' Name -' ' Text -'==' Operator -' ' Text -'1' Literal.Number.Integer -' ' Text -'?' Operator +'return' Keyword ' ' Text -'s' Name -' ' Text -':' Operator -'\n' Text - -' ' Text -'RepString' Keyword.Type -'(' Punctuation -'s' Name -',' Punctuation -'r' Name -')' Punctuation +'b' Name '\n' Text 'end' Keyword @@ -3004,575 +959,182 @@ '\n' Text -'## reversed strings without data movement ##' Comment -'\n' Text - -'\n' Text - -'type' Keyword -' ' Text -'RevString' Keyword.Type -' ' Text -'<:' Operator -' ' Text -'String' Name -'\n' Text - -' ' Text -'string' Name -'::' Operator -'String' Name +'## comparison ##' Comment '\n' Text -'end' Keyword '\n' Text -'\n' Text - -'length' Name +'_memcmp' Name '(' Punctuation -'s' Name +'a' Name '::' Operator -'RevString' Keyword.Type -')' Punctuation -' ' Text -'=' Operator +'Union' Keyword.Type +'{' Punctuation +'Ptr' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation +',' Punctuation +'AbstractString' Keyword.Type +'}' Punctuation +',' Punctuation ' ' Text -'length' Name -'(' Punctuation -'s' Name -'.' Operator -'string' Name -')' Punctuation -'\n' Text - -'strlen' Name -'(' Punctuation -'s' Name +'b' Name '::' Operator -'RevString' Keyword.Type +'Union' Keyword.Type +'{' Punctuation +'Ptr' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation +',' Punctuation +'AbstractString' Keyword.Type +'}' Punctuation +',' Punctuation +' ' Text +'len' Name ')' Punctuation ' ' Text '=' Operator -' ' Text -'strlen' Name -'(' Punctuation -'s' Name -'.' Operator -'string' Name -')' Punctuation '\n' Text -'\n' Text - -'start' Name -'(' Punctuation -'s' Name -'::' Operator -'RevString' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'(' Punctuation -'n' Name -'=' Operator -'length' Name +' ' Text +'ccall' Keyword '(' Punctuation -'s' Name -')' Punctuation -';' Punctuation +':memcmp' Literal.String.Symbol +',' Punctuation ' ' Text -'n' Name -'-' Operator -'thisind' Name -'(' Punctuation -'s' Name -'.' Operator -'string' Name +'Cint' Keyword.Type ',' Punctuation -'n' Name -')' Punctuation -'+' Operator -'1' Literal.Number.Integer -')' Punctuation -'\n' Text - -'function' Keyword ' ' Text -'next' Name '(' Punctuation -'s' Name -'::' Operator -'RevString' Keyword.Type +'Ptr' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation ',' Punctuation ' ' Text -'i' Name -'::' Operator -'Int' Keyword.Type -')' Punctuation -'\n' Text - -' ' Text -'n' Name -' ' Text -'=' Operator +'Ptr' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation +',' Punctuation ' ' Text -'length' Name -'(' Punctuation -'s' Name +'Csize_t' Keyword.Type ')' Punctuation -';' Punctuation -' ' Text -'j' Name -' ' Text -'=' Operator -' ' Text -'n' Name -'-' Operator -'i' Name -'+' Operator -'1' Literal.Number.Integer -'\n' Text - -' ' Text -'(' Punctuation -'s' Name -'.' Operator -'string' Name -'[' Punctuation -'j' Name -']' Punctuation ',' Punctuation ' ' Text -'n' Name -'-' Operator -'thisind' Name -'(' Punctuation -'s' Name -'.' Operator -'string' Name +'a' Name ',' Punctuation -'j' Name -'-' Operator -'1' Literal.Number.Integer -')' Punctuation -'+' Operator -'1' Literal.Number.Integer -')' Punctuation -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'reverse' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation ' ' Text -'=' Operator -' ' Text -'RevString' Keyword.Type -'(' Punctuation -'s' Name -')' Punctuation -'\n' Text - -'reverse' Name -'(' Punctuation -'s' Name -'::' Operator -'RevString' Keyword.Type -')' Punctuation +'b' Name +',' Punctuation ' ' Text -'=' Operator +'len' Name ' ' Text -'s' Name -'.' Operator -'string' Name -'\n' Text - -'\n' Text - -'## ropes for efficient concatenation, etc. ##' Comment -'\n' Text - -'\n' Text - -'# Idea: instead of this standard binary tree structure,' Comment -'\n' Text - -'# how about we keep an array of substrings, with an' Comment -'\n' Text - -'# offset array. We can do binary search on the offset' Comment -'\n' Text - -'# array so we get O(log(n)) indexing time still, but we' Comment -'\n' Text - -'# can compute the offsets lazily and avoid all the' Comment -'\n' Text - -'# futzing around while the string is being constructed.' Comment -'\n' Text - -'\n' Text - -'type' Keyword +'%' Operator ' ' Text -'RopeString' Keyword.Type +'Csize_t' Keyword.Type +')' Punctuation ' ' Text -'<:' Operator +'%' Operator ' ' Text -'String' Name -'\n' Text - -' ' Text -'head' Name -'::' Operator -'String' Name -'\n' Text - -' ' Text -'tail' Name -'::' Operator -'String' Name -'\n' Text - -' ' Text -'depth' Name -'::' Operator -'Int32' Keyword.Type -'\n' Text - -' ' Text -'length' Name -'::' Operator 'Int' Keyword.Type '\n' Text '\n' Text -' ' Text -'RopeString' Keyword.Type +'function' Keyword +' ' Text +'cmp' Name '(' Punctuation -'h' Name +'a' Name '::' Operator -'RopeString' Keyword.Type +'String' Keyword.Type ',' Punctuation ' ' Text -'t' Name +'b' Name '::' Operator -'RopeString' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -'\n' Text - -' ' Text -'depth' Name -'(' Punctuation -'h' Name -'.' Operator -'tail' Name +'String' Keyword.Type ')' Punctuation -' ' Text -'+' Operator -' ' Text -'depth' Name -'(' Punctuation -'t' Name -')' Punctuation -' ' Text -'<' Operator -' ' Text -'depth' Name -'(' Punctuation -'h' Name -'.' Operator -'head' Name -')' Punctuation -' ' Text -'?' Operator '\n' Text -' ' Text -'RopeString' Keyword.Type -'(' Punctuation -'h' Name -'.' Operator -'head' Name -',' Punctuation -' ' Text -'RopeString' Keyword.Type -'(' Punctuation -'h' Name -'.' Operator -'tail' Name +' ' Text +'al' Name ',' Punctuation ' ' Text -'t' Name -')' Punctuation -')' Punctuation +'bl' Name ' ' Text -':' Operator -'\n' Text - -' ' Text -'new' Name -'(' Punctuation -'h' Name -',' Punctuation -' ' Text -'t' Name -',' Punctuation +'=' Operator ' ' Text -'max' Name +'sizeof' Name '(' Punctuation -'h' Name -'.' Operator -'depth' Name -',' Punctuation -'t' Name -'.' Operator -'depth' Name +'a' Name ')' Punctuation -'+' Operator -'1' Literal.Number.Integer ',' Punctuation ' ' Text -'length' Name -'(' Punctuation -'h' Name -')' Punctuation -'+' Operator -'length' Name +'sizeof' Name '(' Punctuation -'t' Name -')' Punctuation +'b' Name ')' Punctuation '\n' Text -'\n' Text - ' ' Text -'RopeString' Keyword.Type -'(' Punctuation -'h' Name -'::' Operator -'RopeString' Keyword.Type -',' Punctuation -' ' Text -'t' Name -'::' Operator -'String' Name -')' Punctuation +'c' Name ' ' Text '=' Operator -'\n' Text - -' ' Text -'depth' Name -'(' Punctuation -'h' Name -'.' Operator -'tail' Name -')' Punctuation ' ' Text -'<' Operator -' ' Text -'depth' Name -'(' Punctuation -'h' Name -'.' Operator -'head' Name -')' Punctuation -' ' Text -'?' Operator -'\n' Text - -' ' Text -'RopeString' Keyword.Type +'_memcmp' Name '(' Punctuation -'h' Name -'.' Operator -'head' Name +'a' Name ',' Punctuation ' ' Text -'RopeString' Keyword.Type -'(' Punctuation -'h' Name -'.' Operator -'tail' Name +'b' Name ',' Punctuation ' ' Text -'t' Name -')' Punctuation -')' Punctuation -' ' Text -':' Operator -'\n' Text - -' ' Text -'new' Name +'min' Name '(' Punctuation -'h' Name -',' Punctuation -' ' Text -'t' Name +'al' Name ',' Punctuation -' ' Text -'h' Name -'.' Operator -'depth' Name -'+' Operator -'1' Literal.Number.Integer -',' Punctuation -' ' Text -'length' Name -'(' Punctuation -'h' Name +'bl' Name ')' Punctuation -'+' Operator -'length' Name -'(' Punctuation -'t' Name ')' Punctuation -')' Punctuation -'\n' Text - '\n' Text ' ' Text -'RopeString' Keyword.Type -'(' Punctuation -'h' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'t' Name -'::' Operator -'RopeString' Keyword.Type -')' Punctuation +'return' Keyword ' ' Text -'=' Operator -'\n' Text - -' ' Text -'depth' Name -'(' Punctuation -'t' Name -'.' Operator -'head' Name -')' Punctuation +'c' Name ' ' Text '<' Operator ' ' Text -'depth' Name -'(' Punctuation -'t' Name -'.' Operator -'tail' Name -')' Punctuation +'0' Literal.Number.Integer ' ' Text '?' Operator -'\n' Text - -' ' Text -'RopeString' Keyword.Type -'(' Punctuation -'RopeString' Keyword.Type -'(' Punctuation -'h' Name -',' Punctuation -' ' Text -'t' Name -'.' Operator -'head' Name -')' Punctuation -',' Punctuation ' ' Text -'t' Name -'.' Operator -'tail' Name -')' Punctuation +'-' Operator +'1' Literal.Number.Integer ' ' Text ':' Operator -'\n' Text - -' ' Text -'new' Name -'(' Punctuation -'h' Name -',' Punctuation -' ' Text -'t' Name -',' Punctuation ' ' Text -'t' Name -'.' Operator -'depth' Name -'+' Operator -'1' Literal.Number.Integer -',' Punctuation -' ' Text -'length' Name -'(' Punctuation -'h' Name -')' Punctuation -'+' Operator -'length' Name -'(' Punctuation -'t' Name -')' Punctuation -')' Punctuation -'\n' Text - -'\n' Text - -' ' Text -'RopeString' Keyword.Type -'(' Punctuation -'h' Name -'::' Operator -'String' Name -',' Punctuation +'c' Name ' ' Text -'t' Name -'::' Operator -'String' Name -')' Punctuation +'>' Operator ' ' Text -'=' Operator -'\n' Text - -' ' Text -'new' Name -'(' Punctuation -'h' Name -',' Punctuation +'0' Literal.Number.Integer ' ' Text -'t' Name -',' Punctuation +'?' Operator ' ' Text +'+' Operator '1' Literal.Number.Integer -',' Punctuation ' ' Text -'length' Name -'(' Punctuation -'h' Name -')' Punctuation -'+' Operator -'length' Name +':' Operator +' ' Text +'cmp' Name '(' Punctuation -'t' Name -')' Punctuation +'al' Name +',' Punctuation +'bl' Name ')' Punctuation '\n' Text @@ -3581,1466 +1143,472 @@ '\n' Text -'depth' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'0' Literal.Number.Integer -'\n' Text - -'depth' Name -'(' Punctuation -'s' Name -'::' Operator -'RopeString' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'s' Name -'.' Operator -'depth' Name -'\n' Text - -'\n' Text - 'function' Keyword ' ' Text -'next' Name +'==' Operator '(' Punctuation -'s' Name +'a' Name '::' Operator -'RopeString' Keyword.Type +'String' Keyword.Type ',' Punctuation ' ' Text -'i' Name +'b' Name '::' Operator -'Int' Keyword.Type +'String' Keyword.Type ')' Punctuation '\n' Text ' ' Text -'if' Keyword -' ' Text -'i' Name -' ' Text -'<=' Operator -' ' Text -'length' Name +'pointer_from_objref' Name '(' Punctuation -'s' Name -'.' Operator -'head' Name +'a' Name ')' Punctuation -'\n' Text - -' ' Text -'return' Keyword ' ' Text -'next' Name -'(' Punctuation -'s' Name -'.' Operator -'head' Name -',' Punctuation +'==' Operator ' ' Text -'i' Name +'pointer_from_objref' Name +'(' Punctuation +'b' Name ')' Punctuation -'\n' Text - -' ' Text -'else' Keyword -'\n' Text - -' ' Text -'c' Name -',' Punctuation -' ' Text -'j' Name ' ' Text -'=' Operator -' ' Text -'next' Name -'(' Punctuation -'s' Name -'.' Operator -'tail' Name -',' Punctuation +'&&' Operator ' ' Text -'i' Name -'-' Operator -'length' Name -'(' Punctuation -'s' Name -'.' Operator -'head' Name -')' Punctuation -')' Punctuation -'\n' Text - -' ' Text 'return' Keyword ' ' Text -'c' Name -',' Punctuation -' ' Text -'j' Name -'+' Operator -'length' Name -'(' Punctuation -'s' Name -'.' Operator -'head' Name -')' Punctuation +'true' Name.Builtin '\n' Text ' ' Text -'end' Keyword -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'length' Name -'(' Punctuation -'s' Name -'::' Operator -'RopeString' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'s' Name -'.' Operator -'length' Name -'\n' Text - -'strlen' Name -'(' Punctuation -'s' Name -'::' Operator -'RopeString' Keyword.Type -')' Punctuation +'al' Name ' ' Text '=' Operator ' ' Text -'strlen' Name +'sizeof' Name '(' Punctuation -'s' Name -'.' Operator -'head' Name -')' Punctuation -' ' Text -'+' Operator -' ' Text -'strlen' Name -'(' Punctuation -'s' Name -'.' Operator -'tail' Name -')' Punctuation -'\n' Text - -'\n' Text - -'strcat' Name -'(' Punctuation -')' Punctuation -' ' Text -'=' Operator -' ' Text -'"' Literal.String -'"' Literal.String -'\n' Text - -'strcat' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'s' Name -'\n' Text - -'strcat' Name -'(' Punctuation -'x' Name -'.' Operator -'.' Operator -'.' Operator -')' Punctuation -' ' Text -'=' Operator -' ' Text -'strcat' Name -'(' Punctuation -'map' Name -'(' Punctuation -'string' Name -',' Punctuation -'x' Name -')' Punctuation -'.' Operator -'.' Operator -'.' Operator -')' Punctuation -'\n' Text - -'strcat' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'t' Name -'::' Operator -'String' Name -'.' Operator -'.' Operator -'.' Operator +'a' Name ')' Punctuation -' ' Text -'=' Operator '\n' Text ' ' Text -'(' Punctuation -'t' Name -' ' Text -'=' Operator -' ' Text -'strcat' Name -'(' Punctuation -'t' Name -'.' Operator -'.' Operator -'.' Operator -')' Punctuation -';' Punctuation -' ' Text -'isempty' Name -'(' Punctuation -'s' Name -')' Punctuation -' ' Text -'?' Operator +'return' Keyword ' ' Text -'t' Name +'al' Name ' ' Text -':' Operator +'==' Operator ' ' Text -'isempty' Name +'sizeof' Name '(' Punctuation -'t' Name +'b' Name ')' Punctuation ' ' Text -'?' Operator +'&&' Operator ' ' Text -'s' Name +'0' Literal.Number.Integer ' ' Text -':' Operator +'==' Operator ' ' Text -'RopeString' Keyword.Type +'_memcmp' Name '(' Punctuation -'s' Name +'a' Name ',' Punctuation ' ' Text -'t' Name -')' Punctuation -')' Punctuation -'\n' Text - -'\n' Text - -'print' Name -'(' Punctuation -'s' Name -'::' Operator -'RopeString' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'print' Name -'(' Punctuation -'s' Name -'.' Operator -'head' Name +'b' Name ',' Punctuation ' ' Text -'s' Name -'.' Operator -'tail' Name +'al' Name ')' Punctuation '\n' Text -'\n' Text - -'## transformed strings ##' Comment -'\n' Text - -'\n' Text - -'type' Keyword -' ' Text -'TransformedString' Name -' ' Text -'<:' Operator -' ' Text -'String' Name -'\n' Text - -' ' Text -'transform' Name -'::' Operator -'Function' Keyword.Type -'\n' Text - -' ' Text -'string' Name -'::' Operator -'String' Name -'\n' Text - 'end' Keyword '\n' Text '\n' Text -'length' Name +'typemin' Name '(' Punctuation -'s' Name '::' Operator -'TransformedString' Name +'Type' Keyword.Type +'{' Punctuation +'String' Keyword.Type +'}' Punctuation ')' Punctuation ' ' Text '=' Operator ' ' Text -'length' Name -'(' Punctuation -'s' Name -'.' Operator -'string' Name -')' Punctuation +'"' Literal.String +'"' Literal.String '\n' Text -'strlen' Name +'typemin' Name '(' Punctuation -'s' Name '::' Operator -'TransformedString' Name +'String' Keyword.Type ')' Punctuation ' ' Text '=' Operator ' ' Text -'strlen' Name +'typemin' Name '(' Punctuation -'s' Name -'.' Operator -'string' Name +'String' Keyword.Type ')' Punctuation '\n' Text '\n' Text -'function' Keyword +'## thisind, nextind ##' Comment +'\n' Text + +'\n' Text + +'@propagate_inbounds' Name.Decorator ' ' Text -'next' Name +'thisind' Name '(' Punctuation 's' Name '::' Operator -'TransformedString' Name +'String' Keyword.Type ',' Punctuation ' ' Text 'i' Name '::' Operator 'Int' Keyword.Type ')' Punctuation -'\n' Text - -' ' Text -'c' Name -',' Punctuation -' ' Text -'j' Name ' ' Text '=' Operator ' ' Text -'next' Name +'_thisind_str' Name '(' Punctuation 's' Name -'.' Operator -'string' Name -',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'c' Name -' ' Text -'=' Operator -' ' Text -'s' Name -'.' Operator -'transform' Name -'(' Punctuation -'c' Name ',' Punctuation ' ' Text 'i' Name ')' Punctuation '\n' Text -' ' Text -'return' Keyword -' ' Text -'c' Name -',' Punctuation -' ' Text -'j' Name -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'## uppercase and lowercase transformations ##' Comment '\n' Text +'# s should be String or SubString{String}' Comment '\n' Text -'uppercase' Name -'(' Punctuation -'c' Name -'::' Operator -'Char' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'ccall' Keyword -'(' Punctuation -':' Operator -'towupper' Name -',' Punctuation +'@inline' Name.Decorator ' ' Text -'Char' Keyword.Type -',' Punctuation +'function' Keyword ' ' Text +'_thisind_str' Name '(' Punctuation -'Char' Keyword.Type -',' Punctuation -')' Punctuation +'s' Name ',' Punctuation ' ' Text -'c' Name +'i' Name +'::' Operator +'Int' Keyword.Type ')' Punctuation '\n' Text -'lowercase' Name -'(' Punctuation -'c' Name -'::' Operator -'Char' Keyword.Type -')' Punctuation +' ' Text +'i' Name ' ' Text -'=' Operator +'==' Operator ' ' Text -'ccall' Keyword -'(' Punctuation -':' Operator -'towlower' Name -',' Punctuation +'0' Literal.Number.Integer ' ' Text -'Char' Keyword.Type -',' Punctuation +'&&' Operator ' ' Text -'(' Punctuation -'Char' Keyword.Type -',' Punctuation -')' Punctuation -',' Punctuation +'return' Keyword ' ' Text -'c' Name -')' Punctuation -'\n' Text - +'0' Literal.Number.Integer '\n' Text -'uppercase' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation +' ' Text +'n' Name ' ' Text '=' Operator ' ' Text -'TransformedString' Name -'(' Punctuation -'(' Punctuation -'c' Name -',' Punctuation -'i' Name -')' Punctuation -'-' Operator -'>' Operator -'uppercase' Name +'ncodeunits' Name '(' Punctuation -'c' Name -')' Punctuation -',' Punctuation -' ' Text 's' Name ')' Punctuation '\n' Text -'lowercase' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'TransformedString' Name -'(' Punctuation -'(' Punctuation -'c' Name -',' Punctuation +' ' Text 'i' Name -')' Punctuation -'-' Operator -'>' Operator -'lowercase' Name -'(' Punctuation -'c' Name -')' Punctuation -',' Punctuation -' ' Text -'s' Name -')' Punctuation -'\n' Text - -'\n' Text - -'ucfirst' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation ' ' Text -'=' Operator -' ' Text -'TransformedString' Name -'(' Punctuation -'(' Punctuation -'c' Name -',' Punctuation -'i' Name -')' Punctuation -'-' Operator -'>' Operator -'i' Name '==' Operator -'1' Literal.Number.Integer ' ' Text -'?' Operator +'n' Name ' ' Text -'uppercase' Name -'(' Punctuation -'c' Name -')' Punctuation +'+' Operator ' ' Text -':' Operator +'1' Literal.Number.Integer ' ' Text -'c' Name -',' Punctuation +'&&' Operator ' ' Text -'s' Name -')' Punctuation +'return' Keyword +' ' Text +'i' Name '\n' Text -'lcfirst' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator +' ' Text +'@boundscheck' Name.Decorator ' ' Text -'TransformedString' Name +'between' Name '(' Punctuation -'(' Punctuation -'c' Name -',' Punctuation 'i' Name -')' Punctuation -'-' Operator -'>' Operator -'i' Name -'==' Operator -'1' Literal.Number.Integer -' ' Text -'?' Operator -' ' Text -'lowercase' Name -'(' Punctuation -'c' Name -')' Punctuation -' ' Text -':' Operator -' ' Text -'c' Name ',' Punctuation ' ' Text -'s' Name -')' Punctuation -'\n' Text - -'\n' Text - -'const' Keyword.Declaration -' ' Text -'uc' Name -' ' Text -'=' Operator -' ' Text -'uppercase' Name -'\n' Text - -'const' Keyword.Declaration -' ' Text -'lc' Name -' ' Text -'=' Operator -' ' Text -'lowercase' Name -'\n' Text - -'\n' Text - -'## string map ##' Comment -'\n' Text - -'\n' Text - -'function' Keyword -' ' Text -'map' Name -'(' Punctuation -'f' Name -'::' Operator -'Function' Keyword.Type +'1' Literal.Number.Integer ',' Punctuation ' ' Text -'s' Name -'::' Operator -'String' Name +'n' Name ')' Punctuation -'\n' Text - -' ' Text -'out' Name ' ' Text -'=' Operator +'||' Operator ' ' Text -'memio' Name +'throw' Name '(' Punctuation -'length' Name +'BoundsError' Keyword.Type '(' Punctuation 's' Name -')' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'for' Keyword -' ' Text -'c' Name -' ' Text -'in' Keyword.Pseudo -' ' Text -'s' Name -'\n' Text - -' ' Text -'write' Name -'(' Punctuation -'out' Name ',' Punctuation ' ' Text -'f' Name -'(' Punctuation -'c' Name +'i' Name ')' Punctuation -'::' Operator -'Char' Keyword.Type ')' Punctuation '\n' Text ' ' Text -'end' Keyword -'\n' Text - -' ' Text -'takebuf_string' Name -'(' Punctuation -'out' Name -')' Punctuation -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'## conversion of general objects to strings ##' Comment -'\n' Text - -'\n' Text - -'string' Name -'(' Punctuation -'x' Name -')' Punctuation +'@inbounds' Name.Decorator ' ' Text -'=' Operator -' ' Text -'print_to_string' Name -'(' Punctuation -'show' Name -',' Punctuation -' ' Text -'x' Name -')' Punctuation -'\n' Text - -'cstring' Name -'(' Punctuation -'x' Name -'.' Operator -'.' Operator -'.' Operator -')' Punctuation +'b' Name ' ' Text '=' Operator ' ' Text -'print_to_string' Name +'codeunit' Name '(' Punctuation -'print' Name +'s' Name ',' Punctuation ' ' Text -'x' Name -'.' Operator -'.' Operator -'.' Operator -')' Punctuation -'\n' Text - -'\n' Text - -'function' Keyword -' ' Text -'cstring' Name -'(' Punctuation -'p' Name -'::' Operator -'Ptr' Keyword.Type -'{' Punctuation -'Uint8' Name -'}' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'p' Name -' ' Text -'==' Operator -' ' Text -'C_NULL' Name.Builtin -' ' Text -'?' Operator -' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'c' Literal.String -'a' Literal.String -'n' Literal.String -'n' Literal.String -'o' Literal.String -'t' Literal.String -' ' Literal.String -'c' Literal.String -'o' Literal.String -'n' Literal.String -'v' Literal.String -'e' Literal.String -'r' Literal.String -'t' Literal.String -' ' Literal.String -'N' Literal.String -'U' Literal.String -'L' Literal.String -'L' Literal.String -' ' Literal.String -'t' Literal.String -'o' Literal.String -' ' Literal.String -'s' Literal.String -'t' Literal.String -'r' Literal.String -'i' Literal.String -'n' Literal.String -'g' Literal.String -'"' Literal.String +'i' Name ')' Punctuation -' ' Text -':' Operator '\n' Text ' ' Text -'ccall' Keyword -'(' Punctuation -':' Operator -'jl_cstr_to_string' Name -',' Punctuation -' ' Text -'Any' Keyword.Type -',' Punctuation -' ' Text -'(' Punctuation -'Ptr' Keyword.Type -'{' Punctuation -'Uint8' Name -'}' Punctuation -',' Punctuation -')' Punctuation -',' Punctuation -' ' Text -'p' Name -')' Punctuation -'::' Operator -'ByteString' Name -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'## string promotion rules ##' Comment -'\n' Text - -'\n' Text - -'promote_rule' Name '(' Punctuation -'::' Operator -'Type' Keyword.Type -'{' Punctuation -'UTF8String' Keyword.Type -'}' Punctuation -' ' Text -',' Punctuation -' ' Text -'::' Operator -'Type' Keyword.Type -'{' Punctuation -'ASCIIString' Keyword.Type -'}' Punctuation -')' Punctuation -' ' Text -'=' Operator +'b' Name ' ' Text -'UTF8String' Keyword.Type -'\n' Text - -'promote_rule' Name -'(' Punctuation -'::' Operator -'Type' Keyword.Type -'{' Punctuation -'UTF8String' Keyword.Type -'}' Punctuation +'&' Operator ' ' Text -',' Punctuation +'0xc0' Literal.Number.Hex ' ' Text -'::' Operator -'Type' Keyword.Type -'{' Punctuation -'CharString' Name -'}' Punctuation +'==' Operator ' ' Text +'0x80' Literal.Number.Hex ')' Punctuation ' ' Text -'=' Operator +'&' Operator ' ' Text -'UTF8String' Keyword.Type -'\n' Text - -'promote_rule' Name '(' Punctuation -'::' Operator -'Type' Keyword.Type -'{' Punctuation -'ASCIIString' Keyword.Type -'}' Punctuation -',' Punctuation +'i' Name +'-' Operator +'1' Literal.Number.Integer ' ' Text -'::' Operator -'Type' Keyword.Type -'{' Punctuation -'CharString' Name -'}' Punctuation +'>' Operator ' ' Text +'0' Literal.Number.Integer ')' Punctuation ' ' Text -'=' Operator +'||' Operator ' ' Text -'UTF8String' Keyword.Type -'\n' Text - -'\n' Text - -'## printing literal quoted string data ##' Comment -'\n' Text - -'\n' Text - -'# TODO: this is really the inverse of print_unbackslashed' Comment -'\n' Text - -'\n' Text - -'function' Keyword +'return' Keyword ' ' Text -'print_quoted_literal' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -'\n' Text - -' ' Text -'print' Name -'(' Punctuation -'\'"\'' Literal.String.Char -')' Punctuation +'i' Name '\n' Text ' ' Text -'for' Keyword +'@inbounds' Name.Decorator ' ' Text -'c' Name +'b' Name ' ' Text '=' Operator ' ' Text -'s' Name -';' Punctuation -' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -'\'"\'' Literal.String.Char -' ' Text -'?' Operator -' ' Text -'print' Name -'(' Punctuation -'"' Literal.String -'\\\\' Literal.String.Escape -'\\"' Literal.String.Escape -'"' Literal.String -')' Punctuation -' ' Text -':' Operator -' ' Text -'print' Name -'(' Punctuation -'c' Name -')' Punctuation -';' Punctuation -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'print' Name -'(' Punctuation -'\'"\'' Literal.String.Char -')' Punctuation -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'## string escaping & unescaping ##' Comment -'\n' Text - -'\n' Text - -'escape_nul' Name +'codeunit' Name '(' Punctuation 's' Name -'::' Operator -'String' Name ',' Punctuation ' ' Text 'i' Name -'::' Operator -'Int' Keyword.Type +'-' Operator +'1' Literal.Number.Integer ')' Punctuation -' ' Text -'=' Operator '\n' Text ' ' Text -'!' Operator -'done' Name +'between' Name '(' Punctuation -'s' Name +'b' Name ',' Punctuation -'i' Name +' ' Text +'0b11000000' Literal.Number.Bin +',' Punctuation +' ' Text +'0b11110111' Literal.Number.Bin ')' Punctuation ' ' Text '&&' Operator ' ' Text -"'0'" Literal.String.Char -' ' Text -'<=' Operator +'return' Keyword ' ' Text -'next' Name -'(' Punctuation -'s' Name -',' Punctuation 'i' Name -')' Punctuation -'[' Punctuation +'-' Operator '1' Literal.Number.Integer -']' Punctuation -' ' Text -'<=' Operator -' ' Text -"'7'" Literal.String.Char -' ' Text -'?' Operator -' ' Text -'L' Name -'"' Literal.String -'\\x00' Literal.String.Escape -'"' Literal.String -' ' Text -':' Operator -' ' Text -'L' Name -'"' Literal.String -'\\0' Literal.String.Escape -'"' Literal.String '\n' Text -'\n' Text - -'is_hex_digit' Name +' ' Text '(' Punctuation -'c' Name -'::' Operator -'Char' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -"'0'" Literal.String.Char -'<=' Operator -'c' Name -'<=' Operator -"'9'" Literal.String.Char -' ' Text -'||' Operator -' ' Text -"'a'" Literal.String.Char -'<=' Operator -'c' Name -'<=' Operator -"'f'" Literal.String.Char -' ' Text -'||' Operator +'b' Name ' ' Text -"'A'" Literal.String.Char -'<=' Operator -'c' Name -'<=' Operator -"'F'" Literal.String.Char -'\n' Text - -'need_full_hex' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation +'&' Operator ' ' Text -'i' Name -'::' Operator -'Int' Keyword.Type -')' Punctuation +'0xc0' Literal.Number.Hex ' ' Text -'=' Operator +'==' Operator ' ' Text -'!' Operator -'done' Name -'(' Punctuation -'s' Name -',' Punctuation -'i' Name +'0x80' Literal.Number.Hex ')' Punctuation ' ' Text -'&&' Operator +'&' Operator ' ' Text -'is_hex_digit' Name -'(' Punctuation -'next' Name '(' Punctuation -'s' Name -',' Punctuation 'i' Name -')' Punctuation -'[' Punctuation -'1' Literal.Number.Integer -']' Punctuation -')' Punctuation -'\n' Text - -'\n' Text - -'function' Keyword +'-' Operator +'2' Literal.Number.Integer ' ' Text -'print_escaped' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation +'>' Operator ' ' Text -'esc' Name -'::' Operator -'String' Name +'0' Literal.Number.Integer ')' Punctuation -'\n' Text - -' ' Text -'i' Name ' ' Text -'=' Operator +'||' Operator ' ' Text -'start' Name -'(' Punctuation -'s' Name -')' Punctuation -'\n' Text - -' ' Text -'while' Keyword +'return' Keyword ' ' Text -'!' Operator -'done' Name -'(' Punctuation -'s' Name -',' Punctuation 'i' Name -')' Punctuation '\n' Text -' ' Text -'c' Name -',' Punctuation +' ' Text +'@inbounds' Name.Decorator ' ' Text -'j' Name +'b' Name ' ' Text '=' Operator ' ' Text -'next' Name +'codeunit' Name '(' Punctuation 's' Name ',' Punctuation +' ' Text 'i' Name +'-' Operator +'2' Literal.Number.Integer ')' Punctuation '\n' Text -' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -"'\\0'" Literal.String.Char -' ' Text -'?' Operator -' ' Text -'print' Name -'(' Punctuation -'escape_nul' Name +' ' Text +'between' Name '(' Punctuation -'s' Name +'b' Name ',' Punctuation -'j' Name -')' Punctuation -')' Punctuation ' ' Text -':' Operator -'\n' Text - -' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -"'\\e'" Literal.String.Char -' ' Text -'?' Operator +'0b11100000' Literal.Number.Bin +',' Punctuation ' ' Text -'print' Name -'(' Punctuation -'L' Name -'"' Literal.String -'\\' Literal.String -'e' Literal.String -'"' Literal.String +'0b11110111' Literal.Number.Bin ')' Punctuation ' ' Text -':' Operator -'\n' Text - -' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -"'\\\\'" Literal.String.Char -' ' Text -'?' Operator +'&&' Operator ' ' Text -'print' Name -'(' Punctuation -'"' Literal.String -'\\\\' Literal.String.Escape -'\\\\' Literal.String.Escape -'"' Literal.String -')' Punctuation +'return' Keyword ' ' Text -':' Operator +'i' Name +'-' Operator +'2' Literal.Number.Integer '\n' Text -' ' Text -'contains' Name +' ' Text '(' Punctuation -'esc' Name -',' Punctuation -'c' Name -')' Punctuation -' ' Text -'?' Operator +'b' Name ' ' Text -'print' Name -'(' Punctuation -"'\\\\'" Literal.String.Char -',' Punctuation +'&' Operator ' ' Text -'c' Name -')' Punctuation +'0xc0' Literal.Number.Hex ' ' Text -':' Operator -'\n' Text - -' ' Text -'iswprint' Name -'(' Punctuation -'c' Name -')' Punctuation -' ' Text -'?' Operator +'==' Operator ' ' Text -'print' Name -'(' Punctuation -'c' Name +'0x80' Literal.Number.Hex ')' Punctuation ' ' Text -':' Operator -'\n' Text - -' ' Text -'7' Literal.Number.Integer -' ' Text -'<=' Operator -' ' Text -'c' Name -' ' Text -'<=' Operator -' ' Text -'13' Literal.Number.Integer -' ' Text -'?' Operator +'&' Operator ' ' Text -'print' Name '(' Punctuation -"'\\\\'" Literal.String.Char -',' Punctuation -' ' Text -'"' Literal.String -'a' Literal.String -'b' Literal.String -'t' Literal.String -'n' Literal.String -'v' Literal.String -'f' Literal.String -'r' Literal.String -'"' Literal.String -'[' Punctuation -'c' Name +'i' Name '-' Operator -'6' Literal.Number.Integer -']' Punctuation -')' Punctuation -' ' Text -':' Operator -'\n' Text - -' ' Text -'c' Name -' ' Text -'<=' Operator +'3' Literal.Number.Integer ' ' Text -"'\\x7f'" Literal.String.Char -' ' Text -'?' Operator +'>' Operator ' ' Text -'print' Name -'(' Punctuation -'L' Name -'"' Literal.String -'\\' Literal.String -'x' Literal.String -'"' Literal.String -',' Punctuation +'0' Literal.Number.Integer +')' Punctuation ' ' Text -'hex' Name -'(' Punctuation -'c' Name -',' Punctuation +'||' Operator ' ' Text -'2' Literal.Number.Integer -')' Punctuation -')' Punctuation +'return' Keyword ' ' Text -':' Operator +'i' Name '\n' Text -' ' Text -'c' Name -' ' Text -'<=' Operator -' ' Text -"'\\uffff'" Literal.String.Char -' ' Text -'?' Operator +' ' Text +'@inbounds' Name.Decorator ' ' Text -'print' Name -'(' Punctuation -'L' Name -'"' Literal.String -'\\' Literal.String -'u' Literal.String -'"' Literal.String -',' Punctuation +'b' Name ' ' Text -'hex' Name -'(' Punctuation -'c' Name -',' Punctuation +'=' Operator ' ' Text -'need_full_hex' Name +'codeunit' Name '(' Punctuation 's' Name ',' Punctuation -'j' Name -')' Punctuation -' ' Text -'?' Operator -' ' Text -'4' Literal.Number.Integer -' ' Text -':' Operator ' ' Text -'2' Literal.Number.Integer -')' Punctuation +'i' Name +'-' Operator +'3' Literal.Number.Integer ')' Punctuation -' ' Text -':' Operator '\n' Text -' ' Text -'print' Name +' ' Text +'between' Name '(' Punctuation -'L' Name -'"' Literal.String -'\\' Literal.String -'U' Literal.String -'"' Literal.String +'b' Name ',' Punctuation ' ' Text -'hex' Name -'(' Punctuation -'c' Name +'0b11110000' Literal.Number.Bin ',' Punctuation ' ' Text -'need_full_hex' Name -'(' Punctuation -'s' Name -',' Punctuation -'j' Name +'0b11110111' Literal.Number.Bin ')' Punctuation ' ' Text -'?' Operator -' ' Text -'8' Literal.Number.Integer +'&&' Operator ' ' Text -':' Operator +'return' Keyword ' ' Text -'4' Literal.Number.Integer -')' Punctuation -')' Punctuation -'\n' Text - -' ' Text 'i' Name -' ' Text -'=' Operator -' ' Text -'j' Name +'-' Operator +'3' Literal.Number.Integer '\n' Text ' ' Text -'end' Keyword +'return' Keyword +' ' Text +'i' Name '\n' Text 'end' Keyword @@ -5048,1051 +1616,413 @@ '\n' Text -'escape_string' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'print_to_string' Name -'(' Punctuation -'length' Name -'(' Punctuation -'s' Name -')' Punctuation -',' Punctuation -' ' Text -'print_escaped' Name -',' Punctuation -' ' Text -'s' Name -',' Punctuation +'@propagate_inbounds' Name.Decorator ' ' Text -'"' Literal.String -'\\"' Literal.String.Escape -'"' Literal.String -')' Punctuation -'\n' Text - -'print_quoted' Name +'nextind' Name '(' Punctuation 's' Name '::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'(' Punctuation -'print' Name -'(' Punctuation -'\'"\'' Literal.String.Char -')' Punctuation -';' Punctuation -' ' Text -'print_escaped' Name -'(' Punctuation -'s' Name +'String' Keyword.Type ',' Punctuation ' ' Text -'"' Literal.String -'\\"' Literal.String.Escape -'\\$' Literal.String.Escape -'"' Literal.String -')' Punctuation -';' Punctuation -' ' Text -'print' Name -'(' Punctuation -'\'"\'' Literal.String.Char -')' Punctuation -')' Punctuation -'\n' Text - -'#" # work around syntax highlighting problem' Comment -'\n' Text - -'quote_string' Name -'(' Punctuation -'s' Name +'i' Name '::' Operator -'String' Name +'Int' Keyword.Type ')' Punctuation ' ' Text '=' Operator ' ' Text -'print_to_string' Name -'(' Punctuation -'length' Name +'_nextind_str' Name '(' Punctuation 's' Name -')' Punctuation -'+' Operator -'2' Literal.Number.Integer -',' Punctuation -' ' Text -'print_quoted' Name ',' Punctuation ' ' Text -'s' Name +'i' Name ')' Punctuation '\n' Text '\n' Text -'# bare minimum unescaping function unescapes only given characters' Comment -'\n' Text - +'# s should be String or SubString{String}' Comment '\n' Text +'@inline' Name.Decorator +' ' Text 'function' Keyword ' ' Text -'print_unescaped_chars' Name +'_nextind_str' Name '(' Punctuation 's' Name -'::' Operator -'String' Name ',' Punctuation ' ' Text -'esc' Name +'i' Name '::' Operator -'String' Name +'Int' Keyword.Type ')' Punctuation '\n' Text ' ' Text -'if' Keyword +'i' Name ' ' Text -'!' Operator -'contains' Name -'(' Punctuation -'esc' Name -',' Punctuation -"'\\\\'" Literal.String.Char -')' Punctuation -'\n' Text - -' ' Text -'esc' Name +'==' Operator ' ' Text -'=' Operator +'0' Literal.Number.Integer ' ' Text -'strcat' Name -'(' Punctuation -'"' Literal.String -'\\\\' Literal.String.Escape -'"' Literal.String -',' Punctuation +'&&' Operator ' ' Text -'esc' Name -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword +'return' Keyword +' ' Text +'1' Literal.Number.Integer '\n' Text ' ' Text -'i' Name +'n' Name ' ' Text '=' Operator ' ' Text -'start' Name +'ncodeunits' Name '(' Punctuation 's' Name ')' Punctuation '\n' Text ' ' Text -'while' Keyword +'@boundscheck' Name.Decorator ' ' Text -'!' Operator -'done' Name +'between' Name '(' Punctuation -'s' Name -',' Punctuation 'i' Name -')' Punctuation -'\n' Text - -' ' Text -'c' Name ',' Punctuation ' ' Text -'i' Name -' ' Text -'=' Operator -' ' Text -'next' Name -'(' Punctuation -'s' Name +'1' Literal.Number.Integer ',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'c' Name -' ' Text -'==' Operator ' ' Text -"'\\\\'" Literal.String.Char +'n' Name +')' Punctuation ' ' Text -'&&' Operator +'||' Operator ' ' Text -'!' Operator -'done' Name +'throw' Name +'(' Punctuation +'BoundsError' Keyword.Type '(' Punctuation 's' Name ',' Punctuation -'i' Name -')' Punctuation ' ' Text -'&&' Operator -' ' Text -'contains' Name -'(' Punctuation -'esc' Name -',' Punctuation -'s' Name -'[' Punctuation 'i' Name -']' Punctuation +')' Punctuation ')' Punctuation '\n' Text -' ' Text -'c' Name -',' Punctuation +' ' Text +'@inbounds' Name.Decorator ' ' Text -'i' Name +'l' Name ' ' Text '=' Operator ' ' Text -'next' Name +'codeunit' Name '(' Punctuation 's' Name ',' Punctuation +' ' Text 'i' Name ')' Punctuation '\n' Text -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'print' Name -'(' Punctuation -'c' Name -')' Punctuation -'\n' Text - ' ' Text -'end' Keyword -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'unescape_chars' Name '(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation +'l' Name ' ' Text -'esc' Name -'::' Operator -'String' Name -')' Punctuation +'<' Operator ' ' Text -'=' Operator -'\n' Text - -' ' Text -'print_to_string' Name -'(' Punctuation -'length' Name -'(' Punctuation -'s' Name +'0x80' Literal.Number.Hex ')' Punctuation -',' Punctuation ' ' Text -'print_unescaped_chars' Name -',' Punctuation +'|' Operator ' ' Text -'s' Name -',' Punctuation +'(' Punctuation +'0xf8' Literal.Number.Hex ' ' Text -'esc' Name -')' Punctuation -'\n' Text - -'\n' Text - -'# general unescaping of traditional C and Unicode escape sequences' Comment -'\n' Text - -'\n' Text - -'function' Keyword +'≤' Operator ' ' Text -'print_unescaped' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name +'l' Name ')' Punctuation -'\n' Text - -' ' Text -'i' Name ' ' Text -'=' Operator +'&&' Operator ' ' Text -'start' Name -'(' Punctuation -'s' Name -')' Punctuation +'return' Keyword +' ' Text +'i' Name +'+' Operator +'1' Literal.Number.Integer '\n' Text ' ' Text -'while' Keyword +'if' Keyword ' ' Text -'!' Operator -'done' Name -'(' Punctuation -'s' Name -',' Punctuation -'i' Name -')' Punctuation +'l' Name +' ' Text +'<' Operator +' ' Text +'0xc0' Literal.Number.Hex '\n' Text ' ' Text -'c' Name -',' Punctuation -' ' Text -'i' Name +'i′' Name ' ' Text '=' Operator ' ' Text -'next' Name +'@inbounds' Name.Decorator +' ' Text +'thisind' Name '(' Punctuation 's' Name ',' Punctuation +' ' Text 'i' Name ')' Punctuation '\n' Text ' ' Text -'if' Keyword -' ' Text -'!' Operator -'done' Name -'(' Punctuation -'s' Name -',' Punctuation -'i' Name -')' Punctuation -' ' Text -'&&' Operator +'return' Keyword ' ' Text -'c' Name +'i′' Name ' ' Text -'==' Operator -' ' Text -"'\\\\'" Literal.String.Char -'\n' Text - -' ' Text -'c' Name -',' Punctuation +'<' Operator ' ' Text 'i' Name ' ' Text -'=' Operator +'?' Operator ' ' Text -'next' Name +'@inbounds' Name.Decorator +'(' Punctuation +'nextind' Name '(' Punctuation 's' Name ',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -"'x'" Literal.String.Char -' ' Text -'||' Operator -' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -"'u'" Literal.String.Char -' ' Text -'||' Operator ' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -"'U'" Literal.String.Char -'\n' Text - -' ' Text -'n' Name -' ' Text -'=' Operator -' ' Text -'k' Name +'i′' Name +')' Punctuation +')' Punctuation ' ' Text -'=' Operator +':' Operator ' ' Text -'0' Literal.Number.Integer +'i' Name +'+' Operator +'1' Literal.Number.Integer '\n' Text -' ' Text -'m' Name -' ' Text -'=' Operator -' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -"'x'" Literal.String.Char -' ' Text -'?' Operator -' ' Text -'2' Literal.Number.Integer -' ' Text -':' Operator +' ' Text +'end' Keyword '\n' Text -' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -"'u'" Literal.String.Char -' ' Text -'?' Operator -' ' Text -'4' Literal.Number.Integer -' ' Text -':' Operator -' ' Text -'8' Literal.Number.Integer +' ' Text +'# first continuation byte' Comment '\n' Text -' ' Text -'while' Keyword -' ' Text +' ' Text '(' Punctuation -'k' Name +'i' Name +' ' Text '+=' Operator +' ' Text '1' Literal.Number.Integer ')' Punctuation ' ' Text -'<=' Operator +'>' Operator ' ' Text -'m' Name +'n' Name ' ' Text '&&' Operator ' ' Text -'!' Operator -'done' Name -'(' Punctuation -'s' Name -',' Punctuation +'return' Keyword +' ' Text 'i' Name -')' Punctuation '\n' Text -' ' Text -'c' Name -',' Punctuation +' ' Text +'@inbounds' Name.Decorator ' ' Text -'j' Name +'b' Name ' ' Text '=' Operator ' ' Text -'next' Name +'codeunit' Name '(' Punctuation 's' Name ',' Punctuation +' ' Text 'i' Name ')' Punctuation '\n' Text -' ' Text -'n' Name -' ' Text -'=' Operator -' ' Text -"'0'" Literal.String.Char -' ' Text -'<=' Operator -' ' Text -'c' Name -' ' Text -'<=' Operator -' ' Text -"'9'" Literal.String.Char -' ' Text -'?' Operator -' ' Text -'n' Name -'<<' Operator -'4' Literal.Number.Integer -' ' Text -'+' Operator -' ' Text -'c' Name -'-' Operator -"'0'" Literal.String.Char -' ' Text -':' Operator -'\n' Text - -' ' Text -"'a'" Literal.String.Char -' ' Text -'<=' Operator -' ' Text -'c' Name -' ' Text -'<=' Operator -' ' Text -"'f'" Literal.String.Char -' ' Text -'?' Operator -' ' Text -'n' Name -'<<' Operator -'4' Literal.Number.Integer -' ' Text -'+' Operator -' ' Text -'c' Name -'-' Operator -"'a'" Literal.String.Char -'+' Operator -'10' Literal.Number.Integer -' ' Text -':' Operator -'\n' Text - -' ' Text -"'A'" Literal.String.Char -' ' Text -'<=' Operator +' ' Text +'b' Name ' ' Text -'c' Name +'&' Operator ' ' Text -'<=' Operator +'0xc0' Literal.Number.Hex ' ' Text -"'F'" Literal.String.Char +'≠' Operator ' ' Text -'?' Operator +'0x80' Literal.Number.Hex ' ' Text -'n' Name -'<<' Operator -'4' Literal.Number.Integer -' ' Text -'+' Operator -' ' Text -'c' Name -'-' Operator -"'A'" Literal.String.Char -'+' Operator -'10' Literal.Number.Integer +'&&' Operator ' ' Text -':' Operator +'return' Keyword ' ' Text -'break' Keyword -'\n' Text - -' ' Text 'i' Name -' ' Text -'=' Operator -' ' Text -'j' Name '\n' Text -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'k' Name +' ' Text +'(' Punctuation +'(' Punctuation +'i' Name ' ' Text -'==' Operator +'+=' Operator ' ' Text '1' Literal.Number.Integer -'\n' Text - -' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'\\\\' Literal.String.Escape -'x' Literal.String -' ' Literal.String -'u' Literal.String -'s' Literal.String -'e' Literal.String -'d' Literal.String -' ' Literal.String -'w' Literal.String -'i' Literal.String -'t' Literal.String -'h' Literal.String -' ' Literal.String -'n' Literal.String -'o' Literal.String -' ' Literal.String -'f' Literal.String -'o' Literal.String -'l' Literal.String -'l' Literal.String -'o' Literal.String -'w' Literal.String -'i' Literal.String -'n' Literal.String -'g' Literal.String -' ' Literal.String -'h' Literal.String -'e' Literal.String -'x' Literal.String -' ' Literal.String -'d' Literal.String -'i' Literal.String -'g' Literal.String -'i' Literal.String -'t' Literal.String -'s' Literal.String -'"' Literal.String ')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'m' Name -' ' Text -'==' Operator ' ' Text -'2' Literal.Number.Integer +'>' Operator ' ' Text -'# \\x escape sequence' Comment -'\n' Text - -' ' Text -'write' Name -'(' Punctuation -'uint8' Name -'(' Punctuation -'n' Name -')' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'else' Keyword -'\n' Text - -' ' Text -'print' Name -'(' Punctuation -'char' Name -'(' Punctuation 'n' Name ')' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'elseif' Keyword -' ' Text -"'0'" Literal.String.Char -' ' Text -'<=' Operator -' ' Text -'c' Name -' ' Text -'<=' Operator -' ' Text -"'7'" Literal.String.Char -'\n' Text - -' ' Text -'k' Name -' ' Text -'=' Operator ' ' Text -'1' Literal.Number.Integer -'\n' Text - -' ' Text -'n' Name -' ' Text -'=' Operator -' ' Text -'c' Name -'-' Operator -"'0'" Literal.String.Char -'\n' Text - -' ' Text -'while' Keyword +'|' Operator ' ' Text '(' Punctuation -'k' Name -'+=' Operator -'1' Literal.Number.Integer -')' Punctuation +'l' Name ' ' Text -'<=' Operator +'<' Operator ' ' Text -'3' Literal.Number.Integer +'0xe0' Literal.Number.Hex +')' Punctuation ' ' Text '&&' Operator ' ' Text -'!' Operator -'done' Name -'(' Punctuation -'s' Name -',' Punctuation +'return' Keyword +' ' Text 'i' Name -')' Punctuation '\n' Text -' ' Text -'c' Name -',' Punctuation +' ' Text +'# second continuation byte' Comment +'\n' Text + +' ' Text +'@inbounds' Name.Decorator ' ' Text -'j' Name +'b' Name ' ' Text '=' Operator ' ' Text -'next' Name +'codeunit' Name '(' Punctuation 's' Name ',' Punctuation +' ' Text 'i' Name ')' Punctuation '\n' Text -' ' Text -'n' Name -' ' Text -'=' Operator -' ' Text -"'0'" Literal.String.Char -' ' Text -'<=' Operator -' ' Text -'c' Name -' ' Text -'<=' Operator +' ' Text +'b' Name ' ' Text -"'7'" Literal.String.Char +'&' Operator ' ' Text -'?' Operator +'0xc0' Literal.Number.Hex ' ' Text -'n' Name -'<<' Operator -'3' Literal.Number.Integer +'≠' Operator ' ' Text -'+' Operator +'0x80' Literal.Number.Hex ' ' Text -'c' Name -'-' Operator -"'0'" Literal.String.Char +'&&' Operator ' ' Text -':' Operator +'return' Keyword ' ' Text -'break' Keyword +'i' Name '\n' Text -' ' Text +' ' Text +'(' Punctuation +'(' Punctuation 'i' Name ' ' Text -'=' Operator -' ' Text -'j' Name -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'if' Keyword +'+=' Operator ' ' Text -'n' Name +'1' Literal.Number.Integer +')' Punctuation ' ' Text '>' Operator ' ' Text -'255' Literal.Number.Integer -'\n' Text - -' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'o' Literal.String -'c' Literal.String -'t' Literal.String -'a' Literal.String -'l' Literal.String -' ' Literal.String -'e' Literal.String -'s' Literal.String -'c' Literal.String -'a' Literal.String -'p' Literal.String -'e' Literal.String -' ' Literal.String -'s' Literal.String -'e' Literal.String -'q' Literal.String -'u' Literal.String -'e' Literal.String -'n' Literal.String -'c' Literal.String -'e' Literal.String -' ' Literal.String -'o' Literal.String -'u' Literal.String -'t' Literal.String -' ' Literal.String -'o' Literal.String -'f' Literal.String -' ' Literal.String -'r' Literal.String -'a' Literal.String -'n' Literal.String -'g' Literal.String -'e' Literal.String -'"' Literal.String -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'write' Name -'(' Punctuation -'uint8' Name -'(' Punctuation 'n' Name ')' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'else' Keyword -'\n' Text - -' ' Text -'print' Name -'(' Punctuation -'c' Name -' ' Text -'==' Operator -' ' Text -"'a'" Literal.String.Char -' ' Text -'?' Operator -' ' Text -"'\\a'" Literal.String.Char -' ' Text -':' Operator -'\n' Text - -' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -"'b'" Literal.String.Char -' ' Text -'?' Operator -' ' Text -"'\\b'" Literal.String.Char -' ' Text -':' Operator -'\n' Text - -' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -"'t'" Literal.String.Char -' ' Text -'?' Operator -' ' Text -"'\\t'" Literal.String.Char -' ' Text -':' Operator -'\n' Text - -' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -"'n'" Literal.String.Char -' ' Text -'?' Operator -' ' Text -"'\\n'" Literal.String.Char -' ' Text -':' Operator -'\n' Text - -' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -"'v'" Literal.String.Char ' ' Text -'?' Operator -' ' Text -"'\\v'" Literal.String.Char +'|' Operator ' ' Text -':' Operator -'\n' Text - -' ' Text -'c' Name +'(' Punctuation +'l' Name ' ' Text -'==' Operator +'<' Operator ' ' Text -"'f'" Literal.String.Char +'0xf0' Literal.Number.Hex +')' Punctuation ' ' Text -'?' Operator +'&&' Operator ' ' Text -"'\\f'" Literal.String.Char +'return' Keyword ' ' Text -':' Operator +'i' Name '\n' Text -' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -"'r'" Literal.String.Char -' ' Text -'?' Operator -' ' Text -"'\\r'" Literal.String.Char -' ' Text -':' Operator +' ' Text +'# third continuation byte' Comment '\n' Text -' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -"'e'" Literal.String.Char -' ' Text -'?' Operator +' ' Text +'@inbounds' Name.Decorator ' ' Text -"'\\e'" Literal.String.Char +'b' Name ' ' Text -':' Operator +'=' Operator ' ' Text -'c' Name -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'else' Keyword -'\n' Text - -' ' Text -'print' Name +'codeunit' Name '(' Punctuation -'c' Name +'s' Name +',' Punctuation +' ' Text +'i' Name ')' Punctuation '\n' Text -' ' Text -'end' Keyword -'\n' Text - ' ' Text -'end' Keyword -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'unescape_string' Name +'ifelse' Name '(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation +'b' Name ' ' Text -'=' Operator +'&' Operator ' ' Text -'print_to_string' Name -'(' Punctuation -'length' Name -'(' Punctuation -'s' Name -')' Punctuation +'0xc0' Literal.Number.Hex +' ' Text +'≠' Operator +' ' Text +'0x80' Literal.Number.Hex ',' Punctuation ' ' Text -'print_unescaped' Name +'i' Name ',' Punctuation ' ' Text -'s' Name +'i' Name +'+' Operator +'1' Literal.Number.Integer ')' Punctuation '\n' Text +'end' Keyword +'\n' Text + '\n' Text '## checking UTF-8 & ACSII validity ##' Comment @@ -6104,7 +2034,27 @@ '(' Punctuation 's' Name '::' Operator -'ByteString' Name +'Union' Keyword.Type +'{' Punctuation +'String' Keyword.Type +',' Punctuation +'Vector' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation +',' Punctuation +'FastContiguousSubArray' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +',' Punctuation +'1' Literal.Number.Integer +',' Punctuation +'Vector' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation +'}' Punctuation +'}' Punctuation ')' Punctuation ' ' Text '=' Operator @@ -6113,8 +2063,7 @@ ' ' Text 'ccall' Keyword '(' Punctuation -':' Operator -'u8_isvalid' Name +':u8_isvalid' Literal.String.Symbol ',' Punctuation ' ' Text 'Int32' Keyword.Type @@ -6123,7 +2072,7 @@ '(' Punctuation 'Ptr' Keyword.Type '{' Punctuation -'Uint8' Name +'UInt8' Keyword.Type '}' Punctuation ',' Punctuation ' ' Text @@ -6132,11 +2081,9 @@ ',' Punctuation ' ' Text 's' Name -'.' Operator -'data' Name ',' Punctuation ' ' Text -'length' Name +'sizeof' Name '(' Punctuation 's' Name ')' Punctuation @@ -6157,31 +2104,38 @@ '\n' Text -'is_valid_ascii' Name +'isvalid' Name '(' Punctuation -'s' Name '::' Operator -'ByteString' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'byte_string_classify' Name -'(' Punctuation -'s' Name -')' Punctuation -' ' Text -'==' Operator -' ' Text -'1' Literal.Number.Integer -'\n' Text - -'is_valid_utf8' Name +'Type' Keyword.Type +'{' Punctuation +'String' Keyword.Type +'}' Punctuation +',' Punctuation ' ' Text -'(' Punctuation 's' Name '::' Operator -'ByteString' Name +'Union' Keyword.Type +'{' Punctuation +'Vector' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation +',' Punctuation +'FastContiguousSubArray' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +',' Punctuation +'1' Literal.Number.Integer +',' Punctuation +'Vector' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation +'}' Punctuation +',' Punctuation +'String' Keyword.Type +'}' Punctuation ')' Punctuation ' ' Text '=' Operator @@ -6191,486 +2145,178 @@ 's' Name ')' Punctuation ' ' Text -'!=' Operator +'≠' Operator ' ' Text '0' Literal.Number.Integer '\n' Text -'\n' Text - -'check_ascii' Name +'isvalid' Name '(' Punctuation 's' Name '::' Operator -'ByteString' Name +'String' Keyword.Type ')' Punctuation ' ' Text '=' Operator ' ' Text -'is_valid_ascii' Name +'isvalid' Name '(' Punctuation -'s' Name -')' Punctuation -' ' Text -'?' Operator +'String' Keyword.Type +',' Punctuation ' ' Text 's' Name -' ' Text -':' Operator -' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'i' Literal.String -'n' Literal.String -'v' Literal.String -'a' Literal.String -'l' Literal.String -'i' Literal.String -'d' Literal.String -' ' Literal.String -'A' Literal.String -'S' Literal.String -'C' Literal.String -'I' Literal.String -'I' Literal.String -' ' Literal.String -'s' Literal.String -'e' Literal.String -'q' Literal.String -'u' Literal.String -'e' Literal.String -'n' Literal.String -'c' Literal.String -'e' Literal.String -'"' Literal.String ')' Punctuation '\n' Text -'check_utf8' Name -' ' Text +'\n' Text + +'is_valid_continuation' Name '(' Punctuation -'s' Name -'::' Operator -'ByteString' Name +'c' Name ')' Punctuation ' ' Text '=' Operator ' ' Text -'is_valid_utf8' Name -'(' Punctuation -'s' Name -')' Punctuation -' ' Text -'?' Operator +'c' Name ' ' Text -'s' Name +'&' Operator ' ' Text -':' Operator +'0xc0' Literal.Number.Hex ' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'i' Literal.String -'n' Literal.String -'v' Literal.String -'a' Literal.String -'l' Literal.String -'i' Literal.String -'d' Literal.String -' ' Literal.String -'U' Literal.String -'T' Literal.String -'F' Literal.String -'-' Literal.String -'8' Literal.String -' ' Literal.String -'s' Literal.String -'e' Literal.String -'q' Literal.String -'u' Literal.String -'e' Literal.String -'n' Literal.String -'c' Literal.String -'e' Literal.String -'"' Literal.String -')' Punctuation +'==' Operator +' ' Text +'0x80' Literal.Number.Hex '\n' Text '\n' Text -'## string interpolation parsing ##' Comment +'## required core functionality ##' Comment '\n' Text '\n' Text +'@inline' Name.Decorator +' ' Text 'function' Keyword ' ' Text -'_jl_interp_parse' Name +'iterate' Name '(' Punctuation 's' Name '::' Operator -'String' Name +'String' Keyword.Type ',' Punctuation ' ' Text -'unescape' Name -'::' Operator -'Function' Keyword.Type -',' Punctuation -' ' Text -'printer' Name -'::' Operator -'Function' Keyword.Type -')' Punctuation -'\n' Text - -' ' Text -'sx' Name -' ' Text -'=' Operator -' ' Text -'{' Punctuation -'}' Punctuation -'\n' Text - -' ' Text 'i' Name -' ' Text -'=' Operator -' ' Text -'j' Name -' ' Text +'::' Operator +'Int' Keyword.Type '=' Operator -' ' Text -'start' Name +'firstindex' Name '(' Punctuation 's' Name ')' Punctuation +')' Punctuation '\n' Text ' ' Text -'while' Keyword -' ' Text -'!' Operator -'done' Name '(' Punctuation -'s' Name -',' Punctuation -'j' Name -')' Punctuation -'\n' Text - -' ' Text -'c' Name -',' Punctuation -' ' Text -'k' Name +'i' Name ' ' Text -'=' Operator +'%' Operator ' ' Text -'next' Name -'(' Punctuation -'s' Name -',' Punctuation -'j' Name +'UInt' Keyword.Type ')' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'c' Name ' ' Text -'==' Operator -' ' Text -"'$'" Literal.String.Char -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'!' Operator -'isempty' Name -'(' Punctuation -'s' Name -'[' Punctuation -'i' Name -':' Operator -'j' Name '-' Operator -'1' Literal.Number.Integer -']' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'push' Name -'(' Punctuation -'sx' Name -',' Punctuation ' ' Text -'unescape' Name -'(' Punctuation -'s' Name -'[' Punctuation -'i' Name -':' Operator -'j' Name -'-' Operator '1' Literal.Number.Integer -']' Punctuation -')' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'ex' Name -',' Punctuation ' ' Text -'j' Name -' ' Text -'=' Operator +'<' Operator ' ' Text -'parseatom' Name +'ncodeunits' Name '(' Punctuation 's' Name -',' Punctuation -'k' Name ')' Punctuation -'\n' Text - -' ' Text -'push' Name -'(' Punctuation -'sx' Name -',' Punctuation ' ' Text -'ex' Name -')' Punctuation -'\n' Text - -' ' Text -'i' Name +'||' Operator ' ' Text -'=' Operator +'return' Keyword ' ' Text -'j' Name +'nothing' Name.Builtin '\n' Text -' ' Text -'elseif' Keyword -' ' Text -'c' Name -' ' Text -'==' Operator +' ' Text +'b' Name ' ' Text -"'\\\\'" Literal.String.Char +'=' Operator ' ' Text -'&&' Operator +'@inbounds' Name.Decorator ' ' Text -'!' Operator -'done' Name +'codeunit' Name '(' Punctuation 's' Name ',' Punctuation -'k' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'s' Name -'[' Punctuation -'k' Name -']' Punctuation -' ' Text -'==' Operator -' ' Text -"'$'" Literal.String.Char -'\n' Text - -' ' Text -'if' Keyword ' ' Text -'!' Operator -'isempty' Name -'(' Punctuation -'s' Name -'[' Punctuation 'i' Name -':' Operator -'j' Name -'-' Operator -'1' Literal.Number.Integer -']' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'push' Name -'(' Punctuation -'sx' Name -',' Punctuation -' ' Text -'unescape' Name -'(' Punctuation -'s' Name -'[' Punctuation -'i' Name -':' Operator -'j' Name -'-' Operator -'1' Literal.Number.Integer -']' Punctuation -')' Punctuation ')' Punctuation '\n' Text -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'i' Name -' ' Text -'=' Operator -' ' Text -'k' Name -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'c' Name -',' Punctuation -' ' Text -'j' Name +' ' Text +'u' Name ' ' Text '=' Operator ' ' Text -'next' Name +'UInt32' Keyword.Type '(' Punctuation -'s' Name -',' Punctuation -'k' Name +'b' Name ')' Punctuation -'\n' Text - -' ' Text -'else' Keyword -'\n' Text - -' ' Text -'j' Name ' ' Text -'=' Operator +'<<' Operator ' ' Text -'k' Name -'\n' Text - -' ' Text -'end' Keyword +'24' Literal.Number.Integer '\n' Text ' ' Text -'end' Keyword -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'!' Operator -'isempty' Name -'(' Punctuation -'s' Name -'[' Punctuation -'i' Name -':' Operator -']' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'push' Name +'between' Name '(' Punctuation -'sx' Name +'b' Name ',' Punctuation ' ' Text -'unescape' Name -'(' Punctuation -'s' Name -'[' Punctuation -'i' Name -':' Operator -'j' Name -'-' Operator -'1' Literal.Number.Integer -']' Punctuation -')' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'length' Name -'(' Punctuation -'sx' Name -')' Punctuation +'0x80' Literal.Number.Hex +',' Punctuation ' ' Text -'==' Operator +'0xf7' Literal.Number.Hex +')' Punctuation ' ' Text -'1' Literal.Number.Integer +'||' Operator ' ' Text -'&&' Operator +'return' Keyword ' ' Text -'isa' Keyword.Pseudo +'reinterpret' Name '(' Punctuation -'sx' Name -'[' Punctuation -'1' Literal.Number.Integer -']' Punctuation +'Char' Keyword.Type ',' Punctuation -'ByteString' Name -')' Punctuation ' ' Text -'?' Operator +'u' Name +')' Punctuation +',' Punctuation ' ' Text -'sx' Name -'[' Punctuation +'i' Name +'+' Operator '1' Literal.Number.Integer -']' Punctuation -' ' Text -':' Operator '\n' Text -' ' Text -'expr' Name -'(' Punctuation -':' Operator -'call' Name -',' Punctuation +' ' Text +'return' Keyword ' ' Text -':' Operator -'print_to_string' Name +'iterate_continued' Name +'(' Punctuation +'s' Name ',' Punctuation ' ' Text -'printer' Name +'i' Name ',' Punctuation ' ' Text -'sx' Name -'.' Operator -'.' Operator -'.' Operator +'u' Name ')' Punctuation '\n' Text @@ -6679,1393 +2325,481 @@ '\n' Text -'_jl_interp_parse' Name +'function' Keyword +' ' Text +'iterate_continued' Name '(' Punctuation 's' Name '::' Operator -'String' Name +'String' Keyword.Type ',' Punctuation ' ' Text -'u' Name +'i' Name '::' Operator -'Function' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'_jl_interp_parse' Name -'(' Punctuation -'s' Name +'Int' Keyword.Type ',' Punctuation ' ' Text 'u' Name -',' Punctuation -' ' Text -'print' Name +'::' Operator +'UInt32' Keyword.Type ')' Punctuation '\n' Text -'_jl_interp_parse' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation +' ' Text +'u' Name ' ' Text -'=' Operator +'<' Operator ' ' Text -'_jl_interp_parse' Name -'(' Punctuation -'s' Name -',' Punctuation +'0xc0000000' Literal.Number.Hex ' ' Text -'x' Name -'-' Operator -'>' Operator -'check_utf8' Name -'(' Punctuation -'unescape_string' Name -'(' Punctuation -'x' Name -')' Punctuation -')' Punctuation -')' Punctuation -'\n' Text - -'\n' Text - -'function' Keyword +'&&' Operator ' ' Text -'_jl_interp_parse_bytes' Name '(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -'\n' Text - -' ' Text -'writer' Name -'(' Punctuation -'x' Name -'.' Operator -'.' Operator -'.' Operator -')' Punctuation -' ' Text -'=' Operator +'i' Name ' ' Text -'for' Keyword +'+=' Operator ' ' Text -'w' Name -'=' Operator -'x' Name +'1' Literal.Number.Integer ';' Punctuation ' ' Text -'write' Name -'(' Punctuation -'w' Name -')' Punctuation -';' Punctuation +'@goto' Name.Decorator ' ' Text -'end' Keyword +'ret' Name +')' Punctuation '\n' Text ' ' Text -'_jl_interp_parse' Name -'(' Punctuation -'s' Name -',' Punctuation -' ' Text -'unescape_string' Name -',' Punctuation +'n' Name ' ' Text -'writer' Name -')' Punctuation -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'## core string macros ##' Comment -'\n' Text - -'\n' Text - -'macro' Keyword -' ' Text -'str' Name -'(' Punctuation -'s' Name -')' Punctuation -';' Punctuation +'=' Operator ' ' Text -'_jl_interp_parse' Name +'ncodeunits' Name '(' Punctuation 's' Name ')' Punctuation -';' Punctuation -' ' Text -'end' Keyword '\n' Text -'macro' Keyword -' ' Text -'S_str' Name -'(' Punctuation -'s' Name -')' Punctuation -';' Punctuation -' ' Text -'_jl_interp_parse' Name -'(' Punctuation -'s' Name -')' Punctuation -';' Punctuation -' ' Text -'end' Keyword +' ' Text +'# first continuation byte' Comment '\n' Text -'macro' Keyword -' ' Text -'I_str' Name -'(' Punctuation -'s' Name -')' Punctuation -';' Punctuation -' ' Text -'_jl_interp_parse' Name -'(' Punctuation -'s' Name -',' Punctuation -' ' Text -'x' Name -'-' Operator -'>' Operator -'unescape_chars' Name +' ' Text '(' Punctuation -'x' Name -',' Punctuation -'"' Literal.String -'\\"' Literal.String.Escape -'"' Literal.String -')' Punctuation -')' Punctuation -';' Punctuation +'i' Name ' ' Text -'end' Keyword -'\n' Text - -'macro' Keyword +'+=' Operator ' ' Text -'E_str' Name -'(' Punctuation -'s' Name +'1' Literal.Number.Integer ')' Punctuation -';' Punctuation ' ' Text -'check_utf8' Name -'(' Punctuation -'unescape_string' Name -'(' Punctuation -'s' Name -')' Punctuation -')' Punctuation -';' Punctuation +'>' Operator ' ' Text -'end' Keyword -'\n' Text - -'macro' Keyword +'n' Name ' ' Text -'B_str' Name -'(' Punctuation -'s' Name -')' Punctuation -';' Punctuation +'&&' Operator ' ' Text -'_jl_interp_parse_bytes' Name -'(' Punctuation -'s' Name -')' Punctuation -';' Punctuation +'@goto' Name.Decorator ' ' Text -'end' Keyword +'ret' Name '\n' Text -'macro' Keyword -' ' Text -'b_str' Name -'(' Punctuation -'s' Name -')' Punctuation -';' Punctuation +' ' Text +'@inbounds' Name.Decorator ' ' Text -'ex' Name +'b' Name ' ' Text '=' Operator ' ' Text -'_jl_interp_parse_bytes' Name -'(' Punctuation -'s' Name -')' Punctuation -';' Punctuation -' ' Text -':' Operator -'(' Punctuation -'(' Punctuation -'$' Operator -'ex' Name -')' Punctuation -'.' Operator -'data' Name -')' Punctuation -';' Punctuation -' ' Text -'end' Keyword -'\n' Text - -'\n' Text - -'## shell-like command parsing ##' Comment -'\n' Text - -'\n' Text - -'function' Keyword -' ' Text -'_jl_shell_parse' Name +'codeunit' Name '(' Punctuation 's' Name -'::' Operator -'String' Name ',' Punctuation ' ' Text -'interp' Name -'::' Operator -'Bool' Keyword.Type +'i' Name ')' Punctuation '\n' Text -'\n' Text - ' ' Text -'in_single_quotes' Name -' ' Text -'=' Operator +'b' Name ' ' Text -'false' Keyword.Constant -'\n' Text - -' ' Text -'in_double_quotes' Name +'&' Operator ' ' Text -'=' Operator +'0xc0' Literal.Number.Hex ' ' Text -'false' Keyword.Constant -'\n' Text - -'\n' Text - -' ' Text -'args' Name +'==' Operator ' ' Text -'=' Operator +'0x80' Literal.Number.Hex ' ' Text -'{' Punctuation -'}' Punctuation -'\n' Text - -' ' Text -'arg' Name +'||' Operator ' ' Text -'=' Operator +'@goto' Name.Decorator ' ' Text -'{' Punctuation -'}' Punctuation +'ret' Name '\n' Text ' ' Text -'i' Name +'u' Name ' ' Text -'=' Operator +'|=' Operator ' ' Text -'start' Name +'UInt32' Keyword.Type '(' Punctuation -'s' Name +'b' Name ')' Punctuation -'\n' Text - -' ' Text -'j' Name ' ' Text -'=' Operator +'<<' Operator ' ' Text -'i' Name +'16' Literal.Number.Integer '\n' Text +' ' Text +'# second continuation byte' Comment '\n' Text ' ' Text -'function' Keyword -' ' Text -'update_arg' Name '(' Punctuation -'x' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'!' Operator -'isa' Keyword.Pseudo '(' Punctuation -'x' Name -',' Punctuation -'String' Name -')' Punctuation -' ' Text -'||' Operator +'i' Name ' ' Text -'!' Operator -'isempty' Name -'(' Punctuation -'x' Name -')' Punctuation -'\n' Text - -' ' Text -'push' Name -'(' Punctuation -'arg' Name -',' Punctuation +'+=' Operator ' ' Text -'x' Name +'1' Literal.Number.Integer ')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'function' Keyword ' ' Text -'append_arg' Name -'(' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword +'>' Operator ' ' Text -'isempty' Name -'(' Punctuation -'arg' Name +'n' Name ')' Punctuation -';' Punctuation -' ' Text -'arg' Name -' ' Text -'=' Operator ' ' Text -'{' Punctuation -'"' Literal.String -'"' Literal.String -',' Punctuation -'}' Punctuation -';' Punctuation +'|' Operator ' ' Text -'end' Keyword -'\n' Text - -' ' Text -'push' Name '(' Punctuation -'args' Name -',' Punctuation +'u' Name ' ' Text -'arg' Name +'<' Operator +' ' Text +'0xe0000000' Literal.Number.Hex ')' Punctuation -'\n' Text - -' ' Text -'arg' Name ' ' Text -'=' Operator +'&&' Operator ' ' Text -'{' Punctuation -'}' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -'\n' Text - -' ' Text -'while' Keyword +'@goto' Name.Decorator ' ' Text -'!' Operator -'done' Name -'(' Punctuation -'s' Name -',' Punctuation -'j' Name -')' Punctuation +'ret' Name '\n' Text -' ' Text -'c' Name -',' Punctuation +' ' Text +'@inbounds' Name.Decorator ' ' Text -'k' Name +'b' Name ' ' Text '=' Operator ' ' Text -'next' Name +'codeunit' Name '(' Punctuation 's' Name ',' Punctuation -'j' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword ' ' Text -'!' Operator -'in_single_quotes' Name -' ' Text -'&&' Operator -' ' Text -'!' Operator -'in_double_quotes' Name -' ' Text -'&&' Operator -' ' Text -'iswspace' Name -'(' Punctuation -'c' Name -')' Punctuation -'\n' Text - -' ' Text -'update_arg' Name -'(' Punctuation -'s' Name -'[' Punctuation 'i' Name -':' Operator -'j' Name -'-' Operator -'1' Literal.Number.Integer -']' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'append_arg' Name -'(' Punctuation ')' Punctuation '\n' Text -' ' Text -'j' Name +' ' Text +'b' Name ' ' Text -'=' Operator +'&' Operator ' ' Text -'k' Name -'\n' Text - -' ' Text -'while' Keyword +'0xc0' Literal.Number.Hex ' ' Text -'!' Operator -'done' Name -'(' Punctuation -'s' Name -',' Punctuation -'j' Name -')' Punctuation -'\n' Text - -' ' Text -'c' Name -',' Punctuation +'==' Operator ' ' Text -'k' Name +'0x80' Literal.Number.Hex ' ' Text -'=' Operator +'||' Operator ' ' Text -'next' Name -'(' Punctuation -'s' Name -',' Punctuation -'j' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword +'@goto' Name.Decorator ' ' Text -'!' Operator -'iswspace' Name -'(' Punctuation -'c' Name -')' Punctuation +'ret' Name '\n' Text -' ' Text -'i' Name +' ' Text +'u' Name ' ' Text -'=' Operator +'|=' Operator ' ' Text -'j' Name -'\n' Text - -' ' Text -'break' Keyword -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'j' Name +'UInt32' Keyword.Type +'(' Punctuation +'b' Name +')' Punctuation ' ' Text -'=' Operator +'<<' Operator ' ' Text -'k' Name -'\n' Text - -' ' Text -'end' Keyword +'8' Literal.Number.Integer '\n' Text -' ' Text -'elseif' Keyword -' ' Text -'interp' Name -' ' Text -'&&' Operator -' ' Text -'!' Operator -'in_single_quotes' Name -' ' Text -'&&' Operator -' ' Text -'c' Name -' ' Text -'==' Operator -' ' Text -"'$'" Literal.String.Char +' ' Text +'# third continuation byte' Comment '\n' Text -' ' Text -'update_arg' Name +' ' Text +'(' Punctuation '(' Punctuation -'s' Name -'[' Punctuation 'i' Name -':' Operator -'j' Name -'-' Operator +' ' Text +'+=' Operator +' ' Text '1' Literal.Number.Integer -']' Punctuation ')' Punctuation -';' Punctuation ' ' Text -'i' Name -' ' Text -'=' Operator +'>' Operator ' ' Text -'k' Name -';' Punctuation +'n' Name +')' Punctuation ' ' Text -'j' Name +'|' Operator ' ' Text -'=' Operator +'(' Punctuation +'u' Name ' ' Text -'k' Name -'\n' Text - -' ' Text -'if' Keyword +'<' Operator ' ' Text -'done' Name -'(' Punctuation -'s' Name -',' Punctuation -'k' Name +'0xf0000000' Literal.Number.Hex ')' Punctuation -'\n' Text - -' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'\\$' Literal.String.Escape -' ' Literal.String -'r' Literal.String -'i' Literal.String -'g' Literal.String -'h' Literal.String -'t' Literal.String -' ' Literal.String -'b' Literal.String -'e' Literal.String -'f' Literal.String -'o' Literal.String -'r' Literal.String -'e' Literal.String -' ' Literal.String -'e' Literal.String -'n' Literal.String -'d' Literal.String -' ' Literal.String -'o' Literal.String -'f' Literal.String -' ' Literal.String -'c' Literal.String -'o' Literal.String -'m' Literal.String -'m' Literal.String -'a' Literal.String -'n' Literal.String -'d' Literal.String -'"' Literal.String -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'if' Keyword ' ' Text -'iswspace' Name -'(' Punctuation -'s' Name -'[' Punctuation -'k' Name -']' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'s' Literal.String -'p' Literal.String -'a' Literal.String -'c' Literal.String -'e' Literal.String -' ' Literal.String -'n' Literal.String -'o' Literal.String -'t' Literal.String -' ' Literal.String -'a' Literal.String -'l' Literal.String -'l' Literal.String -'o' Literal.String -'w' Literal.String -'e' Literal.String -'d' Literal.String -' ' Literal.String -'r' Literal.String -'i' Literal.String -'g' Literal.String -'h' Literal.String -'t' Literal.String -' ' Literal.String -'a' Literal.String -'f' Literal.String -'t' Literal.String -'e' Literal.String -'r' Literal.String -' ' Literal.String -'\\$' Literal.String.Escape -'"' Literal.String -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword +'&&' Operator +' ' Text +'@goto' Name.Decorator +' ' Text +'ret' Name '\n' Text -' ' Text -'ex' Name -',' Punctuation +' ' Text +'@inbounds' Name.Decorator ' ' Text -'j' Name +'b' Name ' ' Text '=' Operator ' ' Text -'parseatom' Name +'codeunit' Name '(' Punctuation 's' Name ',' Punctuation -'j' Name -')' Punctuation -'\n' Text - -' ' Text -'update_arg' Name -'(' Punctuation -'ex' Name -')' Punctuation -';' Punctuation ' ' Text 'i' Name -' ' Text -'=' Operator -' ' Text -'j' Name -'\n' Text - -' ' Text -'else' Keyword +')' Punctuation '\n' Text -' ' Text -'if' Keyword -' ' Text -'!' Operator -'in_double_quotes' Name +' ' Text +'b' Name ' ' Text -'&&' Operator +'&' Operator ' ' Text -'c' Name +'0xc0' Literal.Number.Hex ' ' Text '==' Operator ' ' Text -"'\\''" Literal.String.Char -'\n' Text - -' ' Text -'in_single_quotes' Name -' ' Text -'=' Operator -' ' Text -'!' Operator -'in_single_quotes' Name -'\n' Text - -' ' Text -'update_arg' Name -'(' Punctuation -'s' Name -'[' Punctuation -'i' Name -':' Operator -'j' Name -'-' Operator -'1' Literal.Number.Integer -']' Punctuation -')' Punctuation -';' Punctuation -' ' Text -'i' Name +'0x80' Literal.Number.Hex ' ' Text -'=' Operator -' ' Text -'k' Name -'\n' Text - -' ' Text -'elseif' Keyword -' ' Text -'!' Operator -'in_single_quotes' Name -' ' Text -'&&' Operator -' ' Text -'c' Name +'||' Operator ' ' Text -'==' Operator +'@goto' Name.Decorator ' ' Text -'\'"\'' Literal.String.Char +'ret' Name '\n' Text -' ' Text -'in_double_quotes' Name +' ' Text +'u' Name ' ' Text -'=' Operator +'|=' Operator ' ' Text -'!' Operator -'in_double_quotes' Name -'\n' Text - -' ' Text -'update_arg' Name +'UInt32' Keyword.Type '(' Punctuation -'s' Name -'[' Punctuation -'i' Name -':' Operator -'j' Name -'-' Operator -'1' Literal.Number.Integer -']' Punctuation +'b' Name ')' Punctuation ';' Punctuation ' ' Text 'i' Name ' ' Text -'=' Operator -' ' Text -'k' Name -'\n' Text - -' ' Text -'elseif' Keyword -' ' Text -'c' Name -' ' Text -'==' Operator +'+=' Operator ' ' Text -"'\\\\'" Literal.String.Char +'1' Literal.Number.Integer '\n' Text -' ' Text -'if' Keyword +'@label' Name.Decorator ' ' Text -'in_double_quotes' Name +'ret' Name '\n' Text -' ' Text -'if' Keyword +' ' Text +'return' Keyword ' ' Text -'done' Name +'reinterpret' Name '(' Punctuation -'s' Name +'Char' Keyword.Type ',' Punctuation -'k' Name +' ' Text +'u' Name ')' Punctuation +',' Punctuation +' ' Text +'i' Name '\n' Text -' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'u' Literal.String -'n' Literal.String -'t' Literal.String -'e' Literal.String -'r' Literal.String -'m' Literal.String -'i' Literal.String -'n' Literal.String -'a' Literal.String -'t' Literal.String -'e' Literal.String -'d' Literal.String -' ' Literal.String -'d' Literal.String -'o' Literal.String -'u' Literal.String -'b' Literal.String -'l' Literal.String -'e' Literal.String -' ' Literal.String -'q' Literal.String -'u' Literal.String -'o' Literal.String -'t' Literal.String -'e' Literal.String -'"' Literal.String -')' Punctuation +'end' Keyword '\n' Text -' ' Text -'end' Keyword '\n' Text -' ' Text -'if' Keyword -' ' Text -'s' Name -'[' Punctuation -'k' Name -']' Punctuation -' ' Text -'==' Operator +'@propagate_inbounds' Name.Decorator ' ' Text -'\'"\'' Literal.String.Char -' ' Text -'||' Operator -' ' Text -'s' Name -'[' Punctuation -'k' Name -']' Punctuation -' ' Text -'==' Operator +'function' Keyword ' ' Text -"'$'" Literal.String.Char -'\n' Text - -' ' Text -'update_arg' Name +'getindex' Name '(' Punctuation 's' Name -'[' Punctuation -'i' Name -':' Operator -'j' Name -'-' Operator -'1' Literal.Number.Integer -']' Punctuation -')' Punctuation -';' Punctuation +'::' Operator +'String' Keyword.Type +',' Punctuation ' ' Text 'i' Name -' ' Text -'=' Operator -' ' Text -'k' Name +'::' Operator +'Int' Keyword.Type +')' Punctuation '\n' Text -' ' Text -'c' Name -',' Punctuation -' ' Text -'k' Name +' ' Text +'b' Name ' ' Text '=' Operator ' ' Text -'next' Name +'codeunit' Name '(' Punctuation 's' Name ',' Punctuation -'k' Name -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'elseif' Keyword -' ' Text -'!' Operator -'in_single_quotes' Name -'\n' Text - -' ' Text -'if' Keyword ' ' Text -'done' Name -'(' Punctuation -'s' Name -',' Punctuation -'k' Name -')' Punctuation -'\n' Text - -' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'d' Literal.String -'a' Literal.String -'n' Literal.String -'g' Literal.String -'l' Literal.String -'i' Literal.String -'n' Literal.String -'g' Literal.String -' ' Literal.String -'b' Literal.String -'a' Literal.String -'c' Literal.String -'k' Literal.String -'s' Literal.String -'l' Literal.String -'a' Literal.String -'s' Literal.String -'h' Literal.String -'"' Literal.String -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'update_arg' Name -'(' Punctuation -'s' Name -'[' Punctuation 'i' Name -':' Operator -'j' Name -'-' Operator -'1' Literal.Number.Integer -']' Punctuation ')' Punctuation -';' Punctuation -' ' Text -'i' Name -' ' Text -'=' Operator -' ' Text -'k' Name '\n' Text -' ' Text -'c' Name -',' Punctuation -' ' Text -'k' Name +' ' Text +'u' Name ' ' Text '=' Operator ' ' Text -'next' Name +'UInt32' Keyword.Type '(' Punctuation -'s' Name -',' Punctuation -'k' Name +'b' Name ')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'j' Name ' ' Text -'=' Operator +'<<' Operator ' ' Text -'k' Name -'\n' Text - -' ' Text -'end' Keyword +'24' Literal.Number.Integer '\n' Text ' ' Text -'end' Keyword -'\n' Text - -'\n' Text - -' ' Text -'if' Keyword +'between' Name +'(' Punctuation +'b' Name +',' Punctuation ' ' Text -'in_single_quotes' Name -';' Punctuation +'0x80' Literal.Number.Hex +',' Punctuation ' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'u' Literal.String -'n' Literal.String -'t' Literal.String -'e' Literal.String -'r' Literal.String -'m' Literal.String -'i' Literal.String -'n' Literal.String -'a' Literal.String -'t' Literal.String -'e' Literal.String -'d' Literal.String -' ' Literal.String -'s' Literal.String -'i' Literal.String -'n' Literal.String -'g' Literal.String -'l' Literal.String -'e' Literal.String -' ' Literal.String -'q' Literal.String -'u' Literal.String -'o' Literal.String -'t' Literal.String -'e' Literal.String -'"' Literal.String +'0xf7' Literal.Number.Hex ')' Punctuation -';' Punctuation ' ' Text -'end' Keyword -'\n' Text - -' ' Text -'if' Keyword +'||' Operator ' ' Text -'in_double_quotes' Name -';' Punctuation +'return' Keyword ' ' Text -'error' Name +'reinterpret' Name '(' Punctuation -'"' Literal.String -'u' Literal.String -'n' Literal.String -'t' Literal.String -'e' Literal.String -'r' Literal.String -'m' Literal.String -'i' Literal.String -'n' Literal.String -'a' Literal.String -'t' Literal.String -'e' Literal.String -'d' Literal.String -' ' Literal.String -'d' Literal.String -'o' Literal.String -'u' Literal.String -'b' Literal.String -'l' Literal.String -'e' Literal.String -' ' Literal.String -'q' Literal.String -'u' Literal.String -'o' Literal.String -'t' Literal.String -'e' Literal.String -'"' Literal.String -')' Punctuation -';' Punctuation +'Char' Keyword.Type +',' Punctuation ' ' Text -'end' Keyword -'\n' Text - -'\n' Text - -' ' Text -'update_arg' Name -'(' Punctuation -'s' Name -'[' Punctuation -'i' Name -':' Operator -']' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'append_arg' Name -'(' Punctuation +'u' Name ')' Punctuation '\n' Text -'\n' Text - ' ' Text -'if' Keyword -' ' Text -'!' Operator -'interp' Name -'\n' Text - -' ' Text 'return' Keyword ' ' Text -'args' Name -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -'\n' Text - -' ' Text -'# construct an expression' Comment -'\n' Text - -' ' Text -'exprs' Name -' ' Text -'=' Operator -' ' Text -'{' Punctuation -'}' Punctuation -'\n' Text - -' ' Text -'for' Keyword -' ' Text -'arg' Name -' ' Text -'in' Keyword.Pseudo -' ' Text -'args' Name -'\n' Text - -' ' Text -'push' Name +'getindex_continued' Name '(' Punctuation -'exprs' Name +'s' Name ',' Punctuation ' ' Text -'expr' Name -'(' Punctuation -':' Operator -'tuple' Name +'i' Name ',' Punctuation ' ' Text -'arg' Name -')' Punctuation +'u' Name ')' Punctuation '\n' Text -' ' Text 'end' Keyword '\n' Text -' ' Text -'expr' Name -'(' Punctuation -':' Operator -'tuple' Name -',' Punctuation -'exprs' Name -')' Punctuation -'\n' Text - -'end' Keyword '\n' Text -'_jl_shell_parse' Name +'function' Keyword +' ' Text +'getindex_continued' Name '(' Punctuation 's' Name '::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator +'String' Keyword.Type +',' Punctuation ' ' Text -'_jl_shell_parse' Name -'(' Punctuation -'s' Name +'i' Name +'::' Operator +'Int' Keyword.Type ',' Punctuation -'true' Keyword.Constant -')' Punctuation -'\n' Text - -'\n' Text - -'function' Keyword ' ' Text -'shell_split' Name -'(' Punctuation -'s' Name +'u' Name '::' Operator -'String' Name +'UInt32' Keyword.Type ')' Punctuation '\n' Text ' ' Text -'parsed' Name -' ' Text -'=' Operator +'if' Keyword ' ' Text -'_jl_shell_parse' Name -'(' Punctuation -'s' Name -',' Punctuation -'false' Keyword.Constant -')' Punctuation -'\n' Text - -' ' Text -'args' Name +'u' Name ' ' Text -'=' Operator +'<' Operator ' ' Text -'String' Name -'[' Punctuation -']' Punctuation +'0xc0000000' Literal.Number.Hex '\n' Text -' ' Text -'for' Keyword -' ' Text -'arg' Name -' ' Text -'in' Keyword.Pseudo -' ' Text -'parsed' Name +' ' Text +'# called from `getindex` which checks bounds' Comment '\n' Text -' ' Text -'push' Name +' ' Text +'@inbounds' Name.Decorator +' ' Text +'isvalid' Name '(' Punctuation -'args' Name +'s' Name ',' Punctuation ' ' Text -'strcat' Name -'(' Punctuation -'arg' Name -'.' Operator -'.' Operator -'.' Operator -')' Punctuation +'i' Name ')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'args' Name -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'function' Keyword ' ' Text -'print_shell_word' Name -'(' Punctuation -'word' Name -'::' Operator -'String' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword +'&&' Operator ' ' Text -'isempty' Name -'(' Punctuation -'word' Name -')' Punctuation +'@goto' Name.Decorator +' ' Text +'ret' Name '\n' Text ' ' Text -'print' Name +'string_index_err' Name '(' Punctuation -'"' Literal.String -"'" Literal.String -"'" Literal.String -'"' Literal.String +'s' Name +',' Punctuation +' ' Text +'i' Name ')' Punctuation '\n' Text @@ -8074,1209 +2808,514 @@ '\n' Text ' ' Text -'has_single' Name +'n' Name ' ' Text '=' Operator ' ' Text -'false' Keyword.Constant +'ncodeunits' Name +'(' Punctuation +'s' Name +')' Punctuation '\n' Text -' ' Text -'has_special' Name -' ' Text -'=' Operator -' ' Text -'false' Keyword.Constant '\n' Text ' ' Text -'for' Keyword -' ' Text -'c' Name -' ' Text -'in' Keyword.Pseudo -' ' Text -'word' Name -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'iswspace' Name '(' Punctuation -'c' Name -')' Punctuation -' ' Text -'||' Operator -' ' Text -'c' Name -'==' Operator -"'\\\\'" Literal.String.Char -' ' Text -'||' Operator -' ' Text -'c' Name -'==' Operator -"'\\''" Literal.String.Char +'i' Name ' ' Text -'||' Operator +'+=' Operator ' ' Text -'c' Name -'==' Operator -'\'"\'' Literal.String.Char +'1' Literal.Number.Integer +')' Punctuation ' ' Text -'||' Operator +'>' Operator +'\xa0' Text +'n' Name ' ' Text -'c' Name -'==' Operator -"'$'" Literal.String.Char -'\n' Text - -' ' Text -'has_special' Name +'&&' Operator ' ' Text -'=' Operator +'@goto' Name.Decorator ' ' Text -'true' Keyword.Constant +'ret' Name '\n' Text -' ' Text -'if' Keyword -' ' Text -'c' Name -' ' Text -'==' Operator +' ' Text +'@inbounds' Name.Decorator ' ' Text -"'\\''" Literal.String.Char -'\n' Text - -' ' Text -'has_single' Name +'b' Name ' ' Text '=' Operator ' ' Text -'true' Keyword.Constant -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'!' Operator -'has_special' Name -'\n' Text - -' ' Text -'print' Name -'(' Punctuation -'word' Name -')' Punctuation -'\n' Text - -' ' Text -'elseif' Keyword -' ' Text -'!' Operator -'has_single' Name -'\n' Text - -' ' Text -'print' Name +'codeunit' Name '(' Punctuation -"'\\''" Literal.String.Char -',' Punctuation -' ' Text -'word' Name +'s' Name ',' Punctuation ' ' Text -"'\\''" Literal.String.Char +'i' Name ')' Punctuation +' ' Text +'# cont byte 1' Comment '\n' Text ' ' Text -'else' Keyword -'\n' Text - -' ' Text -'print' Name -'(' Punctuation -'\'"\'' Literal.String.Char -')' Punctuation -'\n' Text - -' ' Text -'for' Keyword -' ' Text -'c' Name -' ' Text -'in' Keyword.Pseudo +'b' Name ' ' Text -'word' Name -'\n' Text - -' ' Text -'if' Keyword +'&' Operator ' ' Text -'c' Name +'0xc0' Literal.Number.Hex ' ' Text '==' Operator ' ' Text -'\'"\'' Literal.String.Char +'0x80' Literal.Number.Hex ' ' Text '||' Operator ' ' Text -'c' Name +'@goto' Name.Decorator ' ' Text -'==' Operator -' ' Text -"'$'" Literal.String.Char -'\n' Text - -' ' Text -'print' Name -'(' Punctuation -"'\\\\'" Literal.String.Char -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'print' Name -'(' Punctuation -'c' Name -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'print' Name -'(' Punctuation -'\'"\'' Literal.String.Char -')' Punctuation +'ret' Name '\n' Text ' ' Text -'end' Keyword -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'function' Keyword +'u' Name ' ' Text -'print_shell_escaped' Name -'(' Punctuation -'cmd' Name -'::' Operator -'String' Name -',' Punctuation +'|=' Operator ' ' Text -'args' Name -'::' Operator -'String' Name -'.' Operator -'.' Operator -'.' Operator -')' Punctuation -'\n' Text - -' ' Text -'print_shell_word' Name +'UInt32' Keyword.Type '(' Punctuation -'cmd' Name +'b' Name ')' Punctuation -'\n' Text - -' ' Text -'for' Keyword ' ' Text -'arg' Name -' ' Text -'in' Keyword.Pseudo +'<<' Operator ' ' Text -'args' Name -'\n' Text - -' ' Text -'print' Name -'(' Punctuation -"' '" Literal.String.Char -')' Punctuation +'16' Literal.Number.Integer '\n' Text -' ' Text -'print_shell_word' Name -'(' Punctuation -'arg' Name -')' Punctuation '\n' Text ' ' Text -'end' Keyword -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'shell_escape' Name '(' Punctuation -'cmd' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'args' Name -'::' Operator -'String' Name -'.' Operator -'.' Operator -'.' Operator -')' Punctuation -' ' Text -'=' Operator -'\n' Text - -' ' Text -'print_to_string' Name '(' Punctuation -'print_shell_escaped' Name -',' Punctuation +'i' Name ' ' Text -'cmd' Name -',' Punctuation +'+=' Operator ' ' Text -'args' Name -'.' Operator -'.' Operator -'.' Operator +'1' Literal.Number.Integer ')' Punctuation -'\n' Text - -'\n' Text - -'## interface to parser ##' Comment -'\n' Text - -'\n' Text - -'function' Keyword ' ' Text -'parse' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'pos' Name -',' Punctuation +'>' Operator ' ' Text -'greedy' Name +'n' Name ')' Punctuation -'\n' Text - -' ' Text -'# returns (expr, end_pos). expr is () in case of parse error.' Comment -'\n' Text - -' ' Text -'ex' Name -',' Punctuation ' ' Text -'pos' Name -' ' Text -'=' Operator -' ' Text -'ccall' Keyword -'(' Punctuation -':' Operator -'jl_parse_string' Name -',' Punctuation +'|' Operator ' ' Text -'Any' Keyword.Type -',' Punctuation -'\n' Text - -' ' Text '(' Punctuation -'Ptr' Keyword.Type -'{' Punctuation -'Uint8' Name -'}' Punctuation -',' Punctuation +'u' Name ' ' Text -'Int32' Keyword.Type -',' Punctuation +'<' Operator ' ' Text -'Int32' Keyword.Type +'0xe0000000' Literal.Number.Hex ')' Punctuation -',' Punctuation -'\n' Text - -' ' Text -'cstring' Name -'(' Punctuation -'s' Name -')' Punctuation -',' Punctuation -' ' Text -'pos' Name -'-' Operator -'1' Literal.Number.Integer -',' Punctuation ' ' Text -'greedy' Name +'&&' Operator ' ' Text -'?' Operator +'@goto' Name.Decorator ' ' Text -'1' Literal.Number.Integer -':' Operator -'0' Literal.Number.Integer -')' Punctuation +'ret' Name '\n' Text ' ' Text -'if' Keyword +'@inbounds' Name.Decorator ' ' Text -'isa' Keyword.Pseudo -'(' Punctuation -'ex' Name -',' Punctuation -'Expr' Keyword.Type -')' Punctuation +'b' Name ' ' Text -'&&' Operator +'=' Operator ' ' Text -'is' Name +'codeunit' Name '(' Punctuation -'ex' Name -'.' Operator -'head' Name +'s' Name ',' Punctuation -':' Operator -'error' Name -')' Punctuation -'\n' Text - -' ' Text -'throw' Name -'(' Punctuation -'ParseError' Keyword.Type -'(' Punctuation -'ex' Name -'.' Operator -'args' Name -'[' Punctuation -'1' Literal.Number.Integer -']' Punctuation -')' Punctuation +' ' Text +'i' Name ')' Punctuation +' ' Text +'# cont byte 2' Comment '\n' Text ' ' Text -'end' Keyword -'\n' Text - -' ' Text -'if' Keyword +'b' Name ' ' Text -'ex' Name +'&' Operator +' ' Text +'0xc0' Literal.Number.Hex ' ' Text '==' Operator ' ' Text -'(' Punctuation -')' Punctuation -';' Punctuation +'0x80' Literal.Number.Hex ' ' Text -'throw' Name -'(' Punctuation -'ParseError' Keyword.Type -'(' Punctuation -'"' Literal.String -'e' Literal.String -'n' Literal.String -'d' Literal.String -' ' Literal.String -'o' Literal.String -'f' Literal.String -' ' Literal.String -'i' Literal.String -'n' Literal.String -'p' Literal.String -'u' Literal.String -'t' Literal.String -'"' Literal.String -')' Punctuation -')' Punctuation -';' Punctuation +'||' Operator ' ' Text -'end' Keyword +'@goto' Name.Decorator +' ' Text +'ret' Name '\n' Text ' ' Text -'ex' Name -',' Punctuation +'u' Name ' ' Text -'pos' Name -'+' Operator -'1' Literal.Number.Integer +'|=' Operator ' ' Text -'# C is zero-based, Julia is 1-based' Comment -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'parse' Name +'UInt32' Keyword.Type '(' Punctuation -'s' Name -'::' Operator -'String' Name +'b' Name ')' Punctuation -' ' Text -'=' Operator -' ' Text -'parse' Name -'(' Punctuation -'s' Name -',' Punctuation ' ' Text -'1' Literal.Number.Integer -',' Punctuation +'<<' Operator ' ' Text -'true' Keyword.Constant -')' Punctuation +'8' Literal.Number.Integer '\n' Text -'parse' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'pos' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'parse' Name -'(' Punctuation -'s' Name -',' Punctuation -' ' Text -'pos' Name -',' Punctuation -' ' Text -'true' Keyword.Constant -')' Punctuation '\n' Text -'parseatom' Name +' ' Text '(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'parse' Name '(' Punctuation -'s' Name -',' Punctuation +'i' Name ' ' Text -'1' Literal.Number.Integer -',' Punctuation +'+=' Operator ' ' Text -'false' Keyword.Constant +'1' Literal.Number.Integer ')' Punctuation -'\n' Text - -'parseatom' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation ' ' Text -'pos' Name +'>' Operator +' ' Text +'n' Name ')' Punctuation ' ' Text -'=' Operator +'|' Operator ' ' Text -'parse' Name '(' Punctuation -'s' Name -',' Punctuation +'u' Name ' ' Text -'pos' Name -',' Punctuation +'<' Operator ' ' Text -'false' Keyword.Constant +'0xf0000000' Literal.Number.Hex ')' Punctuation -'\n' Text - -'\n' Text - -'## miscellaneous string functions ##' Comment -'\n' Text - -'\n' Text - -'function' Keyword ' ' Text -'lpad' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation +'&&' Operator ' ' Text -'n' Name -'::' Operator -'Integer' Keyword.Type -',' Punctuation +'@goto' Name.Decorator ' ' Text -'p' Name -'::' Operator -'String' Name -')' Punctuation +'ret' Name '\n' Text ' ' Text -'m' Name -' ' Text -'=' Operator +'@inbounds' Name.Decorator ' ' Text -'n' Name +'b' Name ' ' Text -'-' Operator +'=' Operator ' ' Text -'strlen' Name +'codeunit' Name '(' Punctuation 's' Name +',' Punctuation +' ' Text +'i' Name ')' Punctuation +' ' Text +'# cont byte 3' Comment '\n' Text ' ' Text -'if' Keyword +'b' Name ' ' Text -'m' Name +'&' Operator ' ' Text -'<=' Operator +'0xc0' Literal.Number.Hex ' ' Text -'0' Literal.Number.Integer -';' Punctuation +'==' Operator ' ' Text -'return' Keyword +'0x80' Literal.Number.Hex ' ' Text -'s' Name -';' Punctuation +'||' Operator ' ' Text -'end' Keyword +'@goto' Name.Decorator +' ' Text +'ret' Name '\n' Text ' ' Text -'l' Name +'u' Name ' ' Text -'=' Operator +'|=' Operator ' ' Text -'strlen' Name +'UInt32' Keyword.Type '(' Punctuation -'p' Name +'b' Name ')' Punctuation '\n' Text -' ' Text -'if' Keyword +'@label' Name.Decorator ' ' Text -'l' Name -'==' Operator -'1' Literal.Number.Integer +'ret' Name '\n' Text -' ' Text +' ' Text 'return' Keyword ' ' Text -'p' Name -'^' Operator -'m' Name -' ' Text -'*' Operator +'reinterpret' Name +'(' Punctuation +'Char' Keyword.Type +',' Punctuation ' ' Text -'s' Name +'u' Name +')' Punctuation '\n' Text -' ' Text 'end' Keyword '\n' Text -' ' Text -'q' Name -' ' Text -'=' Operator -' ' Text -'div' Name -'(' Punctuation -'m' Name -',' Punctuation -'l' Name -')' Punctuation '\n' Text -' ' Text +'getindex' Name +'(' Punctuation +'s' Name +'::' Operator +'String' Keyword.Type +',' Punctuation +' ' Text 'r' Name +'::' Operator +'UnitRange' Keyword.Type +'{' Punctuation +'<:' Operator +'Integer' Keyword.Type +'}' Punctuation +')' Punctuation ' ' Text '=' Operator ' ' Text -'m' Name -' ' Text -'-' Operator -' ' Text -'q' Name -'*' Operator -'l' Name -'\n' Text - -' ' Text -'cstring' Name -'(' Punctuation -'p' Name -'^' Operator -'q' Name -'*' Operator -'p' Name +'s' Name '[' Punctuation -'1' Literal.Number.Integer +'Int' Keyword.Type +'(' Punctuation +'first' Name +'(' Punctuation +'r' Name +')' Punctuation +')' Punctuation ':' Operator -'chr2ind' Name +'Int' Keyword.Type +'(' Punctuation +'last' Name '(' Punctuation -'p' Name -',' Punctuation 'r' Name ')' Punctuation -']' Punctuation -'*' Operator -'s' Name ')' Punctuation -'\n' Text - -'end' Keyword +']' Punctuation '\n' Text '\n' Text +'@inline' Name.Decorator +' ' Text 'function' Keyword ' ' Text -'rpad' Name +'getindex' Name '(' Punctuation 's' Name '::' Operator -'String' Name -',' Punctuation -' ' Text -'n' Name -'::' Operator -'Integer' Keyword.Type +'String' Keyword.Type ',' Punctuation ' ' Text -'p' Name +'r' Name '::' Operator -'String' Name +'UnitRange' Keyword.Type +'{' Punctuation +'Int' Keyword.Type +'}' Punctuation ')' Punctuation '\n' Text ' ' Text -'m' Name -' ' Text -'=' Operator -' ' Text -'n' Name -' ' Text -'-' Operator -' ' Text -'strlen' Name +'isempty' Name '(' Punctuation -'s' Name +'r' Name ')' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'m' Name -' ' Text -'<=' Operator ' ' Text -'0' Literal.Number.Integer -';' Punctuation +'&&' Operator ' ' Text 'return' Keyword ' ' Text -'s' Name -';' Punctuation -' ' Text -'end' Keyword +'"' Literal.String +'"' Literal.String '\n' Text ' ' Text -'l' Name +'i' Name +',' Punctuation +' ' Text +'j' Name ' ' Text '=' Operator ' ' Text -'strlen' Name +'first' Name '(' Punctuation -'p' Name +'r' Name ')' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'l' Name -'==' Operator -'1' Literal.Number.Integer -'\n' Text - -' ' Text -'return' Keyword -' ' Text -'s' Name -' ' Text -'*' Operator -' ' Text -'p' Name -'^' Operator -'m' Name -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'q' Name -' ' Text -'=' Operator +',' Punctuation ' ' Text -'div' Name +'last' Name '(' Punctuation -'m' Name -',' Punctuation -'l' Name +'r' Name ')' Punctuation '\n' Text ' ' Text -'r' Name -' ' Text -'=' Operator -' ' Text -'m' Name -' ' Text -'-' Operator +'@boundscheck' Name.Decorator ' ' Text -'q' Name -'*' Operator -'l' Name +'begin' Keyword '\n' Text -' ' Text -'cstring' Name +' ' Text +'checkbounds' Name '(' Punctuation 's' Name -'*' Operator -'p' Name -'^' Operator -'q' Name -'*' Operator -'p' Name -'[' Punctuation -'1' Literal.Number.Integer -':' Operator -'chr2ind' Name -'(' Punctuation -'p' Name ',' Punctuation +' ' Text 'r' Name ')' Punctuation -']' Punctuation -')' Punctuation '\n' Text -'end' Keyword -'\n' Text - -'\n' Text - -'lpad' Name +' ' Text +'@inbounds' Name.Decorator +' ' Text +'isvalid' Name '(' Punctuation 's' Name ',' Punctuation ' ' Text -'n' Name -'::' Operator -'Integer' Keyword.Type -',' Punctuation -' ' Text -'p' Name +'i' Name ')' Punctuation ' ' Text -'=' Operator +'||' Operator ' ' Text -'lpad' Name -'(' Punctuation -'string' Name +'string_index_err' Name '(' Punctuation 's' Name -')' Punctuation ',' Punctuation ' ' Text -'n' Name -',' Punctuation -' ' Text -'string' Name -'(' Punctuation -'p' Name -')' Punctuation +'i' Name ')' Punctuation '\n' Text -'rpad' Name +' ' Text +'@inbounds' Name.Decorator +' ' Text +'isvalid' Name '(' Punctuation 's' Name ',' Punctuation ' ' Text -'n' Name -'::' Operator -'Integer' Keyword.Type -',' Punctuation -' ' Text -'p' Name +'j' Name ')' Punctuation ' ' Text -'=' Operator +'||' Operator ' ' Text -'rpad' Name -'(' Punctuation -'string' Name +'string_index_err' Name '(' Punctuation 's' Name -')' Punctuation -',' Punctuation -' ' Text -'n' Name ',' Punctuation ' ' Text -'string' Name -'(' Punctuation -'p' Name -')' Punctuation +'j' Name ')' Punctuation '\n' Text +' ' Text +'end' Keyword '\n' Text -'lpad' Name -'(' Punctuation -'s' Name -',' Punctuation -' ' Text -'n' Name -'::' Operator -'Integer' Keyword.Type -')' Punctuation +' ' Text +'j' Name ' ' Text '=' Operator ' ' Text -'lpad' Name -'(' Punctuation -'string' Name +'nextind' Name '(' Punctuation 's' Name -')' Punctuation ',' Punctuation ' ' Text -'n' Name -',' Punctuation -' ' Text -'"' Literal.String -' ' Literal.String -'"' Literal.String +'j' Name ')' Punctuation +' ' Text +'-' Operator +' ' Text +'1' Literal.Number.Integer '\n' Text -'rpad' Name -'(' Punctuation -'s' Name -',' Punctuation -' ' Text +' ' Text 'n' Name -'::' Operator -'Integer' Keyword.Type -')' Punctuation ' ' Text '=' Operator ' ' Text -'rpad' Name -'(' Punctuation -'string' Name -'(' Punctuation -'s' Name -')' Punctuation -',' Punctuation -' ' Text -'n' Name -',' Punctuation -' ' Text -'"' Literal.String -' ' Literal.String -'"' Literal.String -')' Punctuation -'\n' Text - -'\n' Text - -'function' Keyword -' ' Text -'split' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation +'j' Name ' ' Text -'delims' Name -',' Punctuation +'-' Operator ' ' Text -'include_empty' Name -'::' Operator -'Bool' Keyword.Type -')' Punctuation -'\n' Text - -' ' Text 'i' Name ' ' Text -'=' Operator +'+' Operator ' ' Text '1' Literal.Number.Integer '\n' Text ' ' Text -'strs' Name +'ss' Name ' ' Text '=' Operator ' ' Text -'String' Name -'[' Punctuation -']' Punctuation -'\n' Text - -' ' Text -'len' Name -' ' Text -'=' Operator -' ' Text -'length' Name +'_string_n' Name '(' Punctuation -'s' Name +'n' Name ')' Punctuation '\n' Text ' ' Text -'while' Keyword -' ' Text -'true' Keyword.Constant -'\n' Text - -' ' Text -'tokstart' Name +'GC' Name +'.' Operator +'@preserve' Name.Decorator ' ' Text -'=' Operator +'s' Name ' ' Text -'tokend' Name +'ss' Name ' ' Text -'=' Operator -' ' Text -'i' Name -'\n' Text - -' ' Text -'while' Keyword -' ' Text -'!' Operator -'done' Name +'unsafe_copyto!' Name '(' Punctuation -'s' Name -',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text +'pointer' Name '(' Punctuation -'c' Name -',' Punctuation -'i' Name +'ss' Name ')' Punctuation -' ' Text -'=' Operator -' ' Text -'next' Name -'(' Punctuation -'s' Name ',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword ' ' Text -'contains' Name +'pointer' Name '(' Punctuation -'delims' Name -',' Punctuation -' ' Text -'c' Name -')' Punctuation -'\n' Text - -' ' Text -'break' Keyword -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'tokend' Name -' ' Text -'=' Operator -' ' Text -'i' Name -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'tok' Name -' ' Text -'=' Operator -' ' Text 's' Name -'[' Punctuation -'tokstart' Name -':' Operator -'(' Punctuation -'tokend' Name -'-' Operator -'1' Literal.Number.Integer -')' Punctuation -']' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'include_empty' Name -' ' Text -'||' Operator -' ' Text -'!' Operator -'isempty' Name -'(' Punctuation -'tok' Name -')' Punctuation -'\n' Text - -' ' Text -'push' Name -'(' Punctuation -'strs' Name ',' Punctuation ' ' Text -'tok' Name -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'!' Operator -'(' Punctuation -'(' Punctuation 'i' Name -' ' Text -'<=' Operator -' ' Text -'len' Name ')' Punctuation +',' Punctuation ' ' Text -'||' Operator -' ' Text -'(' Punctuation -'i' Name -'==' Operator -'len' Name -'+' Operator -'1' Literal.Number.Integer -' ' Text -'&&' Operator -' ' Text -'tokend!' Name -'=' Operator -'i' Name -')' Punctuation +'n' Name ')' Punctuation '\n' Text -' ' Text -'break' Keyword -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - ' ' Text -'strs' Name +'return' Keyword +' ' Text +'ss' Name '\n' Text 'end' Keyword @@ -9284,1190 +3323,529 @@ '\n' Text -'split' Name +'length' Name '(' Punctuation 's' Name '::' Operator -'String' Name +'String' Keyword.Type ')' Punctuation ' ' Text '=' Operator ' ' Text -'split' Name +'length_continued' Name '(' Punctuation 's' Name ',' Punctuation ' ' Text -'(' Punctuation -"' '" Literal.String.Char -',' Punctuation -"'\\t'" Literal.String.Char -',' Punctuation -"'\\n'" Literal.String.Char -',' Punctuation -"'\\v'" Literal.String.Char -',' Punctuation -"'\\f'" Literal.String.Char -',' Punctuation -"'\\r'" Literal.String.Char -')' Punctuation +'1' Literal.Number.Integer ',' Punctuation ' ' Text -'false' Keyword.Constant -')' Punctuation -'\n' Text - -'split' Name +'ncodeunits' Name '(' Punctuation 's' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'x' Name ')' Punctuation -' ' Text -'=' Operator -' ' Text -'split' Name -'(' Punctuation -'s' Name ',' Punctuation ' ' Text -'x' Name -',' Punctuation -' ' Text -'true' Keyword.Constant -')' Punctuation -'\n' Text - -'split' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'x' Name -'::' Operator -'Char' Keyword.Type -',' Punctuation -' ' Text -'incl' Name -'::' Operator -'Bool' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'split' Name +'ncodeunits' Name '(' Punctuation 's' Name -',' Punctuation -' ' Text -'(' Punctuation -'x' Name -',' Punctuation ')' Punctuation -',' Punctuation -' ' Text -'incl' Name ')' Punctuation '\n' Text '\n' Text +'@inline' Name.Decorator +' ' Text 'function' Keyword ' ' Text -'print_joined' Name +'length' Name '(' Punctuation -'strings' Name -',' Punctuation -' ' Text -'delim' Name +'s' Name +'::' Operator +'String' Keyword.Type ',' Punctuation ' ' Text -'last' Name -')' Punctuation -'\n' Text - -' ' Text 'i' Name +'::' Operator +'Int' Keyword.Type +',' Punctuation ' ' Text -'=' Operator -' ' Text -'start' Name -'(' Punctuation -'strings' Name +'j' Name +'::' Operator +'Int' Keyword.Type ')' Punctuation '\n' Text ' ' Text -'if' Keyword +'@boundscheck' Name.Decorator ' ' Text -'done' Name -'(' Punctuation -'strings' Name -',' Punctuation -'i' Name -')' Punctuation +'begin' Keyword '\n' Text ' ' Text -'return' Keyword -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'str' Name -',' Punctuation +'0' Literal.Number.Integer +' ' Text +'<' Operator ' ' Text 'i' Name ' ' Text -'=' Operator +'≤' Operator ' ' Text -'next' Name -'(' Punctuation -'strings' Name -',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'print' Name +'ncodeunits' Name '(' Punctuation -'str' Name +'s' Name ')' Punctuation -'\n' Text - -' ' Text -'while' Keyword +'+' Operator +'1' Literal.Number.Integer ' ' Text -'!' Operator -'done' Name +'||' Operator +' ' Text +'throw' Name +'(' Punctuation +'BoundsError' Keyword.Type '(' Punctuation -'strings' Name +'s' Name ',' Punctuation +' ' Text 'i' Name ')' Punctuation +')' Punctuation '\n' Text ' ' Text -'str' Name -',' Punctuation +'0' Literal.Number.Integer ' ' Text -'i' Name +'≤' Operator +'\xa0' Text +'j' Name ' ' Text -'=' Operator +'<' Operator ' ' Text -'next' Name -'(' Punctuation -'strings' Name -',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'print' Name +'ncodeunits' Name '(' Punctuation -'done' Name -'(' Punctuation -'strings' Name -',' Punctuation -'i' Name +'s' Name ')' Punctuation +'+' Operator +'1' Literal.Number.Integer ' ' Text -'?' Operator -' ' Text -'last' Name -' ' Text -':' Operator +'||' Operator ' ' Text -'delim' Name -')' Punctuation -'\n' Text - -' ' Text -'print' Name +'throw' Name '(' Punctuation -'str' Name -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'function' Keyword -' ' Text -'print_joined' Name +'BoundsError' Keyword.Type '(' Punctuation -'strings' Name +'s' Name ',' Punctuation ' ' Text -'delim' Name +'j' Name +')' Punctuation ')' Punctuation '\n' Text ' ' Text -'i' Name -' ' Text -'=' Operator -' ' Text -'start' Name -'(' Punctuation -'strings' Name -')' Punctuation +'end' Keyword '\n' Text ' ' Text -'while' Keyword +'j' Name ' ' Text -'!' Operator -'done' Name -'(' Punctuation -'strings' Name -',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'str' Name -',' Punctuation +'<' Operator ' ' Text 'i' Name ' ' Text -'=' Operator +'&&' Operator ' ' Text -'next' Name -'(' Punctuation -'strings' Name -',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'print' Name -'(' Punctuation -'str' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword +'return' Keyword ' ' Text -'!' Operator -'done' Name -'(' Punctuation -'strings' Name -',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'print' Name -'(' Punctuation -'delim' Name -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword +'0' Literal.Number.Integer '\n' Text ' ' Text -'end' Keyword -'\n' Text - -'end' Keyword -'\n' Text - -'print_joined' Name -'(' Punctuation -'strings' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'print_joined' Name -'(' Punctuation -'strings' Name -',' Punctuation -' ' Text -'"' Literal.String -'"' Literal.String -')' Punctuation -'\n' Text - -'\n' Text - -'join' Name -'(' Punctuation -'args' Name -'.' Operator -'.' Operator -'.' Operator -')' Punctuation +'@inbounds' Name.Decorator ' ' Text -'=' Operator -' ' Text -'print_to_string' Name -'(' Punctuation -'print_joined' Name +'i' Name ',' Punctuation ' ' Text -'args' Name -'.' Operator -'.' Operator -'.' Operator -')' Punctuation -'\n' Text - -'\n' Text - -'chop' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation +'k' Name ' ' Text '=' Operator ' ' Text -'s' Name -'[' Punctuation -'1' Literal.Number.Integer -':' Operator 'thisind' Name '(' Punctuation 's' Name ',' Punctuation -'length' Name -'(' Punctuation -'s' Name -')' Punctuation -')' Punctuation -'-' Operator -'1' Literal.Number.Integer -']' Punctuation -'\n' Text - -'chomp' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator ' ' Text -'(' Punctuation 'i' Name -'=' Operator -'thisind' Name -'(' Punctuation -'s' Name -',' Punctuation -'length' Name -'(' Punctuation -'s' Name ')' Punctuation -')' Punctuation -';' Punctuation -' ' Text -'s' Name -'[' Punctuation -'i' Name -']' Punctuation -'==' Operator -"'\\n'" Literal.String.Char -' ' Text -'?' Operator +',' Punctuation ' ' Text -'s' Name -'[' Punctuation -'1' Literal.Number.Integer -':' Operator 'i' Name -'-' Operator -'1' Literal.Number.Integer -']' Punctuation -' ' Text -':' Operator -' ' Text -'s' Name -')' Punctuation '\n' Text -'chomp' Name -'(' Punctuation -'s' Name -'::' Operator -'ByteString' Name -')' Punctuation +' ' Text +'c' Name ' ' Text '=' Operator ' ' Text -'s' Name -'.' Operator -'data' Name -'[' Punctuation -'end' Keyword -']' Punctuation -'==' Operator -'0x0a' Literal.Number.Hex -' ' Text -'?' Operator +'j' Name ' ' Text -'s' Name -'[' Punctuation -'1' Literal.Number.Integer -':' Operator -'end' Keyword '-' Operator -'1' Literal.Number.Integer -']' Punctuation ' ' Text -':' Operator +'i' Name ' ' Text -'s' Name -'\n' Text - -'\n' Text - -'function' Keyword +'+' Operator ' ' Text -'lstrip' Name '(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -'\n' Text - -' ' Text 'i' Name ' ' Text -'=' Operator +'==' Operator ' ' Text -'start' Name -'(' Punctuation -'s' Name +'k' Name ')' Punctuation '\n' Text ' ' Text -'while' Keyword -' ' Text -'!' Operator -'done' Name +'length_continued' Name '(' Punctuation 's' Name ',' Punctuation +' ' Text 'i' Name -')' Punctuation -'\n' Text - -' ' Text -'c' Name ',' Punctuation ' ' Text 'j' Name -' ' Text -'=' Operator -' ' Text -'next' Name -'(' Punctuation -'s' Name ',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword ' ' Text -'!' Operator -'iswspace' Name -'(' Punctuation 'c' Name ')' Punctuation '\n' Text -' ' Text -'return' Keyword -' ' Text -'s' Name -'[' Punctuation -'i' Name -':' Operator 'end' Keyword -']' Punctuation '\n' Text -' ' Text -'end' Keyword '\n' Text -' ' Text -'i' Name +'@inline' Name.Decorator ' ' Text -'=' Operator -' ' Text -'j' Name -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'"' Literal.String -'"' Literal.String -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - 'function' Keyword ' ' Text -'rstrip' Name +'length_continued' Name '(' Punctuation 's' Name '::' Operator -'String' Name -')' Punctuation -'\n' Text - -' ' Text -'r' Name +'String' Keyword.Type +',' Punctuation ' ' Text -'=' Operator +'i' Name +'::' Operator +'Int' Keyword.Type +',' Punctuation ' ' Text -'reverse' Name -'(' Punctuation -'s' Name +'n' Name +'::' Operator +'Int' Keyword.Type +',' Punctuation +' ' Text +'c' Name +'::' Operator +'Int' Keyword.Type ')' Punctuation '\n' Text ' ' Text 'i' Name ' ' Text -'=' Operator +'<' Operator ' ' Text -'start' Name -'(' Punctuation -'r' Name -')' Punctuation -'\n' Text - -' ' Text -'while' Keyword +'n' Name ' ' Text -'!' Operator -'done' Name -'(' Punctuation -'r' Name -',' Punctuation -'i' Name -')' Punctuation +'||' Operator +' ' Text +'return' Keyword +' ' Text +'c' Name '\n' Text -' ' Text -'c' Name -',' Punctuation +' ' Text +'@inbounds' Name.Decorator ' ' Text -'j' Name +'b' Name ' ' Text '=' Operator ' ' Text -'next' Name +'codeunit' Name '(' Punctuation -'r' Name +'s' Name ',' Punctuation +' ' Text 'i' Name ')' Punctuation '\n' Text -' ' Text -'if' Keyword +' ' Text +'@inbounds' Name.Decorator ' ' Text -'!' Operator -'iswspace' Name -'(' Punctuation -'c' Name -')' Punctuation -'\n' Text - -' ' Text -'return' Keyword +'while' Keyword ' ' Text -'s' Name -'[' Punctuation -'1' Literal.Number.Integer -':' Operator -'end' Keyword -'-' Operator -'i' Name -'+' Operator -'1' Literal.Number.Integer -']' Punctuation -'\n' Text - -' ' Text -'end' Keyword +'true' Name.Builtin '\n' Text ' ' Text -'i' Name -' ' Text -'=' Operator +'while' Keyword ' ' Text -'j' Name -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'"' Literal.String -'"' Literal.String -'\n' Text - -'end' Keyword +'true' Name.Builtin '\n' Text -'\n' Text - -'strip' Name +' ' Text '(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation +'i' Name ' ' Text -'=' Operator +'+=' Operator ' ' Text -'lstrip' Name -'(' Punctuation -'rstrip' Name -'(' Punctuation -'s' Name -')' Punctuation +'1' Literal.Number.Integer ')' Punctuation -'\n' Text - -'\n' Text - -'## string to integer functions ##' Comment -'\n' Text - -'\n' Text - -'function' Keyword ' ' Text -'parse_int' Name -'{' Punctuation -'T' Name -'<:' Operator -'Integer' Keyword.Type -'}' Punctuation -'(' Punctuation -'::' Operator -'Type' Keyword.Type -'{' Punctuation -'T' Name -'}' Punctuation -',' Punctuation +'≤' Operator +'\xa0' Text +'n' Name ' ' Text -'s' Name -'::' Operator -'String' Name -',' Punctuation +'||' Operator ' ' Text -'base' Name -'::' Operator -'Integer' Keyword.Type -')' Punctuation +'return' Keyword +' ' Text +'c' Name '\n' Text -' ' Text -'if' Keyword -' ' Text -'!' Operator -'(' Punctuation -'2' Literal.Number.Integer -' ' Text -'<=' Operator -' ' Text -'base' Name +' ' Text +'0xc0' Literal.Number.Hex ' ' Text -'<=' Operator +'≤' Operator +'\xa0' Text +'b' Name ' ' Text -'36' Literal.Number.Integer -')' Punctuation -';' Punctuation +'≤' Operator +'\xa0' Text +'0xf7' Literal.Number.Hex ' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'i' Literal.String -'n' Literal.String -'v' Literal.String -'a' Literal.String -'l' Literal.String -'i' Literal.String -'d' Literal.String -' ' Literal.String -'b' Literal.String -'a' Literal.String -'s' Literal.String -'e' Literal.String -':' Literal.String -' ' Literal.String -'"' Literal.String -',' Punctuation -'base' Name -')' Punctuation -';' Punctuation +'&&' Operator ' ' Text -'end' Keyword +'break' Keyword '\n' Text -' ' Text -'i' Name +' ' Text +'b' Name ' ' Text '=' Operator ' ' Text -'start' Name -'(' Punctuation -'s' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'done' Name +'codeunit' Name '(' Punctuation 's' Name ',' Punctuation +' ' Text 'i' Name ')' Punctuation '\n' Text ' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'p' Literal.String -'r' Literal.String -'e' Literal.String -'m' Literal.String -'a' Literal.String -'t' Literal.String -'u' Literal.String -'r' Literal.String -'e' Literal.String -' ' Literal.String -'e' Literal.String -'n' Literal.String -'d' Literal.String -' ' Literal.String -'o' Literal.String -'f' Literal.String -' ' Literal.String -'i' Literal.String -'n' Literal.String -'t' Literal.String -'e' Literal.String -'g' Literal.String -'e' Literal.String -'r' Literal.String -' ' Literal.String -'(' Literal.String -'i' Literal.String -'n' Literal.String -' ' Literal.String -'"' Literal.String -',' Punctuation -'show_to_string' Name -'(' Punctuation -'s' Name -')' Punctuation -',' Punctuation -'"' Literal.String -')' Literal.String -'"' Literal.String -')' Punctuation +'end' Keyword '\n' Text -' ' Text -'end' Keyword +' ' Text +'l' Name +' ' Text +'=' Operator +' ' Text +'b' Name '\n' Text -' ' Text -'c' Name -',' Punctuation -'i' Name +' ' Text +'b' Name ' ' Text '=' Operator ' ' Text -'next' Name +'codeunit' Name '(' Punctuation 's' Name ',' Punctuation +' ' Text 'i' Name ')' Punctuation +' ' Text +'# cont byte 1' Comment '\n' Text -' ' Text -'sgn' Name +' ' Text +'c' Name ' ' Text -'=' Operator +'-=' Operator ' ' Text -'one' Name '(' Punctuation -'T' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'T' Name +'x' Name ' ' Text -'<:' Operator +'=' Operator ' ' Text -'Signed' Keyword.Type +'b' Name ' ' Text -'&&' Operator +'&' Operator ' ' Text -'c' Name +'0xc0' Literal.Number.Hex ' ' Text '==' Operator ' ' Text -"'-'" Literal.String.Char -'\n' Text - -' ' Text -'sgn' Name -' ' Text -'=' Operator -' ' Text -'-' Operator -'sgn' Name -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'done' Name -'(' Punctuation -'s' Name -',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'error' Name -'(' Punctuation -'"' Literal.String -'p' Literal.String -'r' Literal.String -'e' Literal.String -'m' Literal.String -'a' Literal.String -'t' Literal.String -'u' Literal.String -'r' Literal.String -'e' Literal.String -' ' Literal.String -'e' Literal.String -'n' Literal.String -'d' Literal.String -' ' Literal.String -'o' Literal.String -'f' Literal.String -' ' Literal.String -'i' Literal.String -'n' Literal.String -'t' Literal.String -'e' Literal.String -'g' Literal.String -'e' Literal.String -'r' Literal.String -' ' Literal.String -'(' Literal.String -'i' Literal.String -'n' Literal.String -' ' Literal.String -'"' Literal.String -',' Punctuation -'show_to_string' Name -'(' Punctuation -'s' Name +'0x80' Literal.Number.Hex ')' Punctuation -',' Punctuation -'"' Literal.String -')' Literal.String -'"' Literal.String -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword '\n' Text ' ' Text -'c' Name -',' Punctuation -'i' Name +'x' Name ' ' Text -'=' Operator +'&' Operator ' ' Text -'next' Name '(' Punctuation -'s' Name -',' Punctuation -'i' Name -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'base' Name +'l' Name ' ' Text -'=' Operator +'≥' Operator ' ' Text -'convert' Name -'(' Punctuation -'T' Name -',' Punctuation -'base' Name +'0xe0' Literal.Number.Hex ')' Punctuation -'\n' Text - -' ' Text -'n' Name -'::' Operator -'T' Name ' ' Text -'=' Operator +'||' Operator ' ' Text -'0' Literal.Number.Integer +'continue' Keyword '\n' Text -' ' Text -'while' Keyword -' ' Text -'true' Keyword.Constant '\n' Text ' ' Text -'d' Name -' ' Text -'=' Operator -' ' Text -"'0'" Literal.String.Char +'(' Punctuation +'i' Name ' ' Text -'<=' Operator +'+=' Operator ' ' Text -'c' Name +'1' Literal.Number.Integer +')' Punctuation ' ' Text -'<=' Operator +'≤' Operator +'\xa0' Text +'n' Name ' ' Text -"'9'" Literal.String.Char +'||' Operator ' ' Text -'?' Operator +'return' Keyword ' ' Text 'c' Name -'-' Operator -"'0'" Literal.String.Char -' ' Text -':' Operator '\n' Text -' ' Text -"'A'" Literal.String.Char -' ' Text -'<=' Operator -' ' Text -'c' Name -' ' Text -'<=' Operator +' ' Text +'b' Name ' ' Text -"'Z'" Literal.String.Char +'=' Operator ' ' Text -'?' Operator +'codeunit' Name +'(' Punctuation +'s' Name +',' Punctuation ' ' Text -'c' Name -'-' Operator -"'A'" Literal.String.Char -'+' Operator -'10' Literal.Number.Integer +'i' Name +')' Punctuation ' ' Text -':' Operator +'# cont byte 2' Comment '\n' Text -' ' Text -"'a'" Literal.String.Char +' ' Text +'c' Name ' ' Text -'<=' Operator +'-=' Operator ' ' Text -'c' Name +'(' Punctuation +'x' Name ' ' Text -'<=' Operator +'=' Operator ' ' Text -"'z'" Literal.String.Char +'b' Name ' ' Text -'?' Operator +'&' Operator ' ' Text -'c' Name -'-' Operator -"'a'" Literal.String.Char -'+' Operator -'10' Literal.Number.Integer +'0xc0' Literal.Number.Hex ' ' Text -':' Operator +'==' Operator ' ' Text -'typemax' Name -'(' Punctuation -'Int' Keyword.Type +'0x80' Literal.Number.Hex ')' Punctuation '\n' Text ' ' Text -'if' Keyword -' ' Text -'d' Name +'x' Name ' ' Text -'>=' Operator +'&' Operator ' ' Text -'base' Name -'\n' Text - -' ' Text -'error' Name -'(' Punctuation -'show_to_string' Name -'(' Punctuation -'c' Name -')' Punctuation -',' Punctuation -'"' Literal.String -' ' Literal.String -'i' Literal.String -'s' Literal.String -' ' Literal.String -'n' Literal.String -'o' Literal.String -'t' Literal.String -' ' Literal.String -'a' Literal.String -' ' Literal.String -'v' Literal.String -'a' Literal.String -'l' Literal.String -'i' Literal.String -'d' Literal.String -' ' Literal.String -'d' Literal.String -'i' Literal.String -'g' Literal.String -'i' Literal.String -'t' Literal.String -' ' Literal.String -'(' Literal.String -'i' Literal.String -'n' Literal.String -' ' Literal.String -'"' Literal.String -',' Punctuation -'show_to_string' Name '(' Punctuation -'s' Name -')' Punctuation -',' Punctuation -'"' Literal.String -')' Literal.String -'"' Literal.String +'l' Name +' ' Text +'≥' Operator +' ' Text +'0xf0' Literal.Number.Hex ')' Punctuation +' ' Text +'||' Operator +' ' Text +'continue' Keyword '\n' Text -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'# TODO: overflow detection?' Comment '\n' Text ' ' Text -'n' Name +'(' Punctuation +'i' Name ' ' Text -'=' Operator +'+=' Operator +' ' Text +'1' Literal.Number.Integer +')' Punctuation ' ' Text +'≤' Operator +'\xa0' Text 'n' Name -'*' Operator -'base' Name ' ' Text -'+' Operator +'||' Operator +' ' Text +'return' Keyword ' ' Text -'d' Name +'c' Name '\n' Text ' ' Text -'if' Keyword +'b' Name ' ' Text -'done' Name +'=' Operator +' ' Text +'codeunit' Name '(' Punctuation 's' Name ',' Punctuation +' ' Text 'i' Name ')' Punctuation -'\n' Text - -' ' Text -'break' Keyword -'\n' Text - -' ' Text -'end' Keyword +' ' Text +'# cont byte 3' Comment '\n' Text ' ' Text 'c' Name -',' Punctuation -'i' Name ' ' Text -'=' Operator +'-=' Operator ' ' Text -'next' Name '(' Punctuation -'s' Name -',' Punctuation -'i' Name +'b' Name +' ' Text +'&' Operator +' ' Text +'0xc0' Literal.Number.Hex +' ' Text +'==' Operator +' ' Text +'0x80' Literal.Number.Hex ')' Punctuation '\n' Text @@ -10475,1244 +3853,386 @@ 'end' Keyword '\n' Text -' ' Text -'return' Keyword -' ' Text -'flipsign' Name -'(' Punctuation -'n' Name -',' Punctuation -'sgn' Name -')' Punctuation -'\n' Text - 'end' Keyword '\n' Text '\n' Text -'parse_int' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation -' ' Text -'base' Name -'::' Operator -'Integer' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'parse_int' Name -'(' Punctuation -'Int' Keyword.Type -',' Punctuation -'s' Name -',' Punctuation -'base' Name -')' Punctuation +'## overload methods for efficiency ##' Comment '\n' Text -'parse_int' Name -'(' Punctuation -'T' Name -'::' Operator -'Type' Keyword.Type -',' Punctuation -' ' Text -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'parse_int' Name -'(' Punctuation -'T' Name -',' Punctuation -'s' Name -',' Punctuation -'10' Literal.Number.Integer -')' Punctuation '\n' Text -'parse_int' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'parse_int' Name +'isvalid' Name '(' Punctuation -'Int' Keyword.Type -',' Punctuation 's' Name -',' Punctuation -'10' Literal.Number.Integer -')' Punctuation -'\n' Text - -'\n' Text - -'parse_bin' Name -'(' Punctuation -'T' Name '::' Operator -'Type' Keyword.Type +'String' Keyword.Type ',' Punctuation ' ' Text -'s' Name +'i' Name '::' Operator -'String' Name +'Int' Keyword.Type ')' Punctuation ' ' Text '=' Operator ' ' Text -'parse_int' Name +'checkbounds' Name '(' Punctuation -'T' Name +'Bool' Keyword.Type ',' Punctuation +' ' Text 's' Name ',' Punctuation -'2' Literal.Number.Integer -')' Punctuation -'\n' Text - -'parse_oct' Name -'(' Punctuation -'T' Name -'::' Operator -'Type' Keyword.Type -',' Punctuation ' ' Text -'s' Name -'::' Operator -'String' Name +'i' Name ')' Punctuation ' ' Text -'=' Operator +'&&' Operator ' ' Text -'parse_int' Name +'thisind' Name '(' Punctuation -'T' Name -',' Punctuation 's' Name ',' Punctuation -'8' Literal.Number.Integer -')' Punctuation -'\n' Text - -'parse_hex' Name -'(' Punctuation -'T' Name -'::' Operator -'Type' Keyword.Type -',' Punctuation ' ' Text -'s' Name -'::' Operator -'String' Name +'i' Name ')' Punctuation ' ' Text -'=' Operator +'==' Operator ' ' Text -'parse_int' Name -'(' Punctuation -'T' Name -',' Punctuation -'s' Name -',' Punctuation -'16' Literal.Number.Integer -')' Punctuation +'i' Name '\n' Text '\n' Text -'parse_bin' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator +'function' Keyword ' ' Text -'parse_int' Name -'(' Punctuation -'Int' Keyword.Type -',' Punctuation -'s' Name -',' Punctuation -'2' Literal.Number.Integer -')' Punctuation -'\n' Text - -'parse_oct' Name +'isascii' Name '(' Punctuation 's' Name '::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'parse_int' Name -'(' Punctuation -'Int' Keyword.Type -',' Punctuation -'s' Name -',' Punctuation -'8' Literal.Number.Integer +'String' Keyword.Type ')' Punctuation '\n' Text -'parse_hex' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator +' ' Text +'@inbounds' Name.Decorator ' ' Text -'parse_int' Name -'(' Punctuation -'Int' Keyword.Type -',' Punctuation -'s' Name -',' Punctuation -'16' Literal.Number.Integer -')' Punctuation -'\n' Text - -'\n' Text - -'integer' Name +'for' Keyword ' ' Text -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation +'i' Name ' ' Text '=' Operator ' ' Text -'int' Name +'1' Literal.Number.Integer +':' Operator +'ncodeunits' Name '(' Punctuation 's' Name ')' Punctuation '\n' Text -'unsigned' Name +' ' Text +'codeunit' Name '(' Punctuation 's' Name -'::' Operator -'String' Name +',' Punctuation +' ' Text +'i' Name ')' Punctuation ' ' Text -'=' Operator +'>=' Operator ' ' Text -'uint' Name -'(' Punctuation -'s' Name -')' Punctuation -'\n' Text - -'int' Name -' ' Text -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation +'0x80' Literal.Number.Hex ' ' Text -'=' Operator +'&&' Operator ' ' Text -'parse_int' Name -'(' Punctuation -'Int' Keyword.Type -',' Punctuation -'s' Name -')' Punctuation +'return' Keyword +' ' Text +'false' Name.Builtin '\n' Text -'uint' Name ' ' Text -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'parse_int' Name -'(' Punctuation -'Uint' Name -',' Punctuation -'s' Name -')' Punctuation +'end' Keyword '\n' Text -'int8' Name ' ' Text -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator +'return' Keyword ' ' Text -'parse_int' Name -'(' Punctuation -'Int8' Keyword.Type -',' Punctuation -'s' Name -')' Punctuation +'true' Name.Builtin '\n' Text -'uint8' Name -' ' Text -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'parse_int' Name -'(' Punctuation -'Uint8' Name -',' Punctuation -'s' Name -')' Punctuation +'end' Keyword '\n' Text -'int16' Name -' ' Text -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'parse_int' Name -'(' Punctuation -'Int16' Keyword.Type -',' Punctuation -'s' Name -')' Punctuation '\n' Text -'uint16' Name -' ' Text -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'parse_int' Name -'(' Punctuation -'Uint16' Name -',' Punctuation -'s' Name -')' Punctuation -'\n' Text +'"""' Literal.String +"\n repeat(c::AbstractChar, r::Integer) -> String\n\nRepeat a character `r` times. This can equivalently be accomplished by calling\n[`c^r`](@ref :^(::Union{AbstractString, AbstractChar}, ::Integer)).\n\n# Examples\n```jldoctest\njulia> repeat('A', 3)\n" Literal.String -'int32' Name -' ' Text -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'parse_int' Name -'(' Punctuation -'Int32' Keyword.Type -',' Punctuation -'s' Name -')' Punctuation +'"' Literal.String +'AAA' Literal.String +'"' Literal.String +'\n```\n' Literal.String + +'"""' Literal.String '\n' Text -'uint32' Name -' ' Text +'repeat' Name '(' Punctuation -'s' Name +'c' Name '::' Operator -'String' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'parse_int' Name -'(' Punctuation -'Uint32' Name +'AbstractChar' Keyword.Type ',' Punctuation -'s' Name -')' Punctuation -'\n' Text - -'int64' Name -' ' Text -'(' Punctuation -'s' Name +' ' Text +'r' Name '::' Operator -'String' Name +'Integer' Keyword.Type ')' Punctuation ' ' Text '=' Operator ' ' Text -'parse_int' Name +'repeat' Name '(' Punctuation -'Int64' Keyword.Type -',' Punctuation -'s' Name -')' Punctuation -'\n' Text - -'uint64' Name -' ' Text +'Char' Keyword.Type '(' Punctuation -'s' Name -'::' Operator -'String' Name +'c' Name ')' Punctuation -' ' Text -'=' Operator -' ' Text -'parse_int' Name -'(' Punctuation -'Uint64' Name ',' Punctuation -'s' Name -')' Punctuation -'\n' Text - -'\n' Text - -'## integer to string functions ##' Comment -'\n' Text - -'\n' Text - -'const' Keyword.Declaration ' ' Text -'_jl_dig_syms' Name -' ' Text -'=' Operator +'r' Name +')' Punctuation ' ' Text -'"' Literal.String -'0' Literal.String -'1' Literal.String -'2' Literal.String -'3' Literal.String -'4' Literal.String -'5' Literal.String -'6' Literal.String -'7' Literal.String -'8' Literal.String -'9' Literal.String -'a' Literal.String -'b' Literal.String -'c' Literal.String -'d' Literal.String -'e' Literal.String -'f' Literal.String -'g' Literal.String -'h' Literal.String -'i' Literal.String -'j' Literal.String -'k' Literal.String -'l' Literal.String -'m' Literal.String -'n' Literal.String -'o' Literal.String -'p' Literal.String -'q' Literal.String -'r' Literal.String -'s' Literal.String -'t' Literal.String -'u' Literal.String -'v' Literal.String -'w' Literal.String -'x' Literal.String -'y' Literal.String -'z' Literal.String -'"' Literal.String -'.' Operator -'data' Name -'\n' Text - +'# fallback' Comment '\n' Text 'function' Keyword ' ' Text -'int2str' Name +'repeat' Name '(' Punctuation -'n' Name +'c' Name '::' Operator -'Union' Keyword.Type -'(' Punctuation -'Int64' Keyword.Type -',' Punctuation -'Uint64' Name -')' Punctuation +'Char' Keyword.Type ',' Punctuation ' ' Text -'b' Name +'r' Name '::' Operator 'Integer' Keyword.Type -',' Punctuation -' ' Text -'l' Name -'::' Operator -'Int' Keyword.Type ')' Punctuation '\n' Text ' ' Text -'if' Keyword -' ' Text -'b' Name -' ' Text -'<' Operator -' ' Text -'2' Literal.Number.Integer +'r' Name ' ' Text -'||' Operator +'==' Operator ' ' Text -'b' Name +'0' Literal.Number.Integer ' ' Text -'>' Operator +'&&' Operator ' ' Text -'36' Literal.Number.Integer -';' Punctuation +'return' Keyword ' ' Text -'error' Name -'(' Punctuation '"' Literal.String -'i' Literal.String -'n' Literal.String -'t' Literal.String -'2' Literal.String -'s' Literal.String -'t' Literal.String -'r' Literal.String -':' Literal.String -' ' Literal.String -'i' Literal.String -'n' Literal.String -'v' Literal.String -'a' Literal.String -'l' Literal.String -'i' Literal.String -'d' Literal.String -' ' Literal.String -'b' Literal.String -'a' Literal.String -'s' Literal.String -'e' Literal.String -' ' Literal.String '"' Literal.String -',' Punctuation -' ' Text -'b' Name -')' Punctuation -';' Punctuation -' ' Text -'end' Keyword '\n' Text ' ' Text -'neg' Name -' ' Text -'=' Operator -' ' Text -'n' Name +'r' Name ' ' Text '<' Operator ' ' Text '0' Literal.Number.Integer -'\n' Text - -' ' Text -'n' Name ' ' Text -'=' Operator +'&&' Operator ' ' Text -'unsigned' Name +'throw' Name '(' Punctuation -'abs' Name +'ArgumentError' Keyword.Type '(' Punctuation -'n' Name +'"' Literal.String +"can't repeat a character " Literal.String +'$r' Literal.String.Interpol +' times' Literal.String +'"' Literal.String ')' Punctuation ')' Punctuation '\n' Text ' ' Text -'b' Name +'u' Name ' ' Text '=' Operator ' ' Text -'convert' Name +'bswap' Name '(' Punctuation -'typeof' Name +'reinterpret' Name '(' Punctuation -'n' Name -')' Punctuation +'UInt32' Keyword.Type ',' Punctuation ' ' Text -'b' Name +'c' Name +')' Punctuation ')' Punctuation '\n' Text ' ' Text -'ndig' Name +'n' Name ' ' Text '=' Operator ' ' Text -'ndigits' Name -'(' Punctuation -'n' Name -',' Punctuation -' ' Text -'b' Name -')' Punctuation -'\n' Text - -' ' Text -'sz' Name +'4' Literal.Number.Integer ' ' Text -'=' Operator +'-' Operator ' ' Text -'max' Name '(' Punctuation -'convert' Name +'leading_zeros' Name '(' Punctuation -'Int' Keyword.Type -',' Punctuation +'u' Name ' ' Text -'ndig' Name -')' Punctuation -',' Punctuation +'|' Operator ' ' Text -'l' Name +'0xff' Literal.Number.Hex ')' Punctuation ' ' Text -'+' Operator -' ' Text -'neg' Name -'\n' Text - -' ' Text -'data' Name -' ' Text -'=' Operator +'>>' Operator ' ' Text -'Array' Keyword.Type -'(' Punctuation -'Uint8' Name -',' Punctuation -' ' Text -'sz' Name +'3' Literal.Number.Integer ')' Punctuation '\n' Text ' ' Text -'i' Name -' ' Text -'=' Operator -' ' Text -'sz' Name -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'ispow2' Name -'(' Punctuation -'b' Name -')' Punctuation -'\n' Text - -' ' Text -'digmask' Name -' ' Text -'=' Operator -' ' Text -'b' Name -'-' Operator -'1' Literal.Number.Integer -'\n' Text - -' ' Text -'shift' Name +'s' Name ' ' Text '=' Operator ' ' Text -'trailing_zeros' Name +'_string_n' Name '(' Punctuation -'b' Name -')' Punctuation -'\n' Text - -' ' Text -'while' Keyword -' ' Text -'i' Name -' ' Text -'>' Operator -' ' Text -'neg' Name -'\n' Text - -' ' Text -'ch' Name -' ' Text -'=' Operator -' ' Text 'n' Name -' ' Text -'&' Operator -' ' Text -'digmask' Name -'\n' Text - -' ' Text -'data' Name -'[' Punctuation -'i' Name -']' Punctuation -' ' Text -'=' Operator -' ' Text -'_jl_dig_syms' Name -'[' Punctuation -'int' Name -'(' Punctuation -'ch' Name +'*' Operator +'r' Name ')' Punctuation -'+' Operator -'1' Literal.Number.Integer -']' Punctuation -'\n' Text - -' ' Text -'n' Name -' ' Text -'>>=' Operator -' ' Text -'shift' Name -'\n' Text - -' ' Text -'i' Name -' ' Text -'-=' Operator -' ' Text -'1' Literal.Number.Integer -'\n' Text - -' ' Text -'end' Keyword '\n' Text ' ' Text -'else' Keyword -'\n' Text - -' ' Text -'while' Keyword -' ' Text -'i' Name -' ' Text -'>' Operator -' ' Text -'neg' Name -'\n' Text - -' ' Text -'ch' Name -' ' Text -'=' Operator -' ' Text -'n' Name -' ' Text -'%' Operator -' ' Text -'b' Name -'\n' Text - -' ' Text -'data' Name -'[' Punctuation -'i' Name -']' Punctuation +'p' Name ' ' Text '=' Operator ' ' Text -'_jl_dig_syms' Name -'[' Punctuation -'int' Name +'pointer' Name '(' Punctuation -'ch' Name +'s' Name ')' Punctuation -'+' Operator -'1' Literal.Number.Integer -']' Punctuation '\n' Text -' ' Text -'n' Name +' ' Text +'GC' Name +'.' Operator +'@preserve' Name.Decorator ' ' Text -'=' Operator +'s' Name +' ' Text +'if' Keyword ' ' Text -'div' Name -'(' Punctuation 'n' Name -',' Punctuation -'b' Name -')' Punctuation -'\n' Text - -' ' Text -'i' Name ' ' Text -'-=' Operator +'==' Operator ' ' Text '1' Literal.Number.Integer '\n' Text ' ' Text -'end' Keyword -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'if' Keyword -' ' Text -'neg' Name -'\n' Text - -' ' Text -'data' Name -'[' Punctuation -'1' Literal.Number.Integer -']' Punctuation -' ' Text -'=' Operator -' ' Text -"'-'" Literal.String.Char -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -' ' Text -'ASCIIString' Keyword.Type -'(' Punctuation -'data' Name -')' Punctuation -'\n' Text - -'end' Keyword -'\n' Text - -'int2str' Name -'(' Punctuation -'n' Name -'::' Operator -'Integer' Keyword.Type -',' Punctuation -' ' Text -'b' Name -'::' Operator -'Integer' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'int2str' Name +'ccall' Keyword '(' Punctuation -'n' Name +':memset' Literal.String.Symbol ',' Punctuation ' ' Text -'b' Name +'Ptr' Keyword.Type +'{' Punctuation +'Cvoid' Keyword.Type +'}' Punctuation ',' Punctuation ' ' Text -'0' Literal.Number.Integer -')' Punctuation -'\n' Text - -'int2str' Name '(' Punctuation -'n' Name -'::' Operator -'Integer' Keyword.Type +'Ptr' Keyword.Type +'{' Punctuation +'UInt8' Keyword.Type +'}' Punctuation ',' Punctuation ' ' Text -'b' Name -'::' Operator -'Integer' Keyword.Type +'Cint' Keyword.Type ',' Punctuation ' ' Text -'l' Name -'::' Operator -'Int' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'int2str' Name -'(' Punctuation -'int64' Name -'(' Punctuation -'n' Name +'Csize_t' Keyword.Type ')' Punctuation ',' Punctuation ' ' Text -'b' Name +'p' Name ',' Punctuation ' ' Text -'l' Name -')' Punctuation -'\n' Text - -'\n' Text - -'string' Name -'(' Punctuation -'x' Name -'::' Operator -'Signed' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'dec' Name -'(' Punctuation -'int64' Name -'(' Punctuation -'x' Name -')' Punctuation -')' Punctuation -'\n' Text - -'cstring' Name -'(' Punctuation -'x' Name -'::' Operator -'Signed' Keyword.Type -')' Punctuation -' ' Text -'=' Operator -' ' Text -'dec' Name -'(' Punctuation -'int64' Name -'(' Punctuation -'x' Name -')' Punctuation -')' Punctuation -'\n' Text - -'\n' Text - -'## string to float functions ##' Comment -'\n' Text - -'\n' Text - -'function' Keyword +'u' Name ' ' Text -'float64_isvalid' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation +'%' Operator ' ' Text -'out' Name -'::' Operator -'Array' Keyword.Type -'{' Punctuation -'Float64' Keyword.Type +'UInt8' Keyword.Type ',' Punctuation -'1' Literal.Number.Integer -'}' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'s' Name -' ' Text -'=' Operator ' ' Text -'cstring' Name -'(' Punctuation -'s' Name +'r' Name ')' Punctuation '\n' Text ' ' Text -'return' Keyword -' ' Text -'(' Punctuation -'ccall' Keyword -'(' Punctuation -':' Operator -'jl_strtod' Name -',' Punctuation -' ' Text -'Int32' Keyword.Type -',' Punctuation -' ' Text -'(' Punctuation -'Ptr' Keyword.Type -'{' Punctuation -'Uint8' Name -'}' Punctuation -',' Punctuation -'Ptr' Keyword.Type -'{' Punctuation -'Float64' Keyword.Type -'}' Punctuation -')' Punctuation -',' Punctuation +'elseif' Keyword ' ' Text -'s' Name -',' Punctuation +'n' Name ' ' Text -'out' Name -')' Punctuation '==' Operator -'0' Literal.Number.Integer -')' Punctuation -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'function' Keyword -' ' Text -'float32_isvalid' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -',' Punctuation ' ' Text -'out' Name -'::' Operator -'Array' Keyword.Type -'{' Punctuation -'Float32' Keyword.Type -',' Punctuation -'1' Literal.Number.Integer -'}' Punctuation -')' Punctuation +'2' Literal.Number.Integer '\n' Text -' ' Text -'s' Name +' ' Text +'p16' Name ' ' Text '=' Operator ' ' Text -'cstring' Name -'(' Punctuation -'s' Name -')' Punctuation -'\n' Text - -' ' Text -'return' Keyword -' ' Text +'reinterpret' Name '(' Punctuation -'ccall' Keyword -'(' Punctuation -':' Operator -'jl_strtof' Name -',' Punctuation -' ' Text -'Int32' Keyword.Type -',' Punctuation -' ' Text -'(' Punctuation -'Ptr' Keyword.Type -'{' Punctuation -'Uint8' Name -'}' Punctuation -',' Punctuation 'Ptr' Keyword.Type '{' Punctuation -'Float32' Keyword.Type +'UInt16' Keyword.Type '}' Punctuation -')' Punctuation ',' Punctuation ' ' Text -'s' Name -',' Punctuation -' ' Text -'out' Name -')' Punctuation -'==' Operator -'0' Literal.Number.Integer +'p' Name ')' Punctuation '\n' Text -'end' Keyword -'\n' Text - -'\n' Text - -'begin' Keyword -'\n' Text - -' ' Text -'local' Keyword.Declaration +' ' Text +'for' Keyword ' ' Text -'tmp' Name -'::' Operator -'Array' Keyword.Type -'{' Punctuation -'Float64' Keyword.Type -',' Punctuation -'1' Literal.Number.Integer -'}' Punctuation +'i' Name ' ' Text '=' Operator ' ' Text -'Array' Keyword.Type -'(' Punctuation -'Float64' Keyword.Type -',' Punctuation '1' Literal.Number.Integer -')' Punctuation +':' Operator +'r' Name '\n' Text -' ' Text -'local' Keyword.Declaration -' ' Text -'tmpf' Name -'::' Operator -'Array' Keyword.Type -'{' Punctuation -'Float32' Keyword.Type -',' Punctuation -'1' Literal.Number.Integer -'}' Punctuation -' ' Text -'=' Operator -' ' Text -'Array' Keyword.Type +' ' Text +'unsafe_store!' Name '(' Punctuation -'Float32' Keyword.Type -',' Punctuation -'1' Literal.Number.Integer -')' Punctuation -'\n' Text - -' ' Text -'global' Keyword.Declaration -' ' Text -'float64' Name +'p16' Name ',' Punctuation ' ' Text -'float32' Name -'\n' Text - -' ' Text -'function' Keyword +'u' Name ' ' Text -'float64' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword +'%' Operator ' ' Text -'!' Operator -'float64_isvalid' Name -'(' Punctuation -'s' Name +'UInt16' Keyword.Type ',' Punctuation ' ' Text -'tmp' Name -')' Punctuation -'\n' Text - -' ' Text -'throw' Name -'(' Punctuation -'ArgumentError' Keyword.Type -'(' Punctuation -'"' Literal.String -'f' Literal.String -'l' Literal.String -'o' Literal.String -'a' Literal.String -'t' Literal.String -'6' Literal.String -'4' Literal.String -'(' Literal.String -'S' Literal.String -'t' Literal.String -'r' Literal.String -'i' Literal.String -'n' Literal.String -'g' Literal.String -')' Literal.String -':' Literal.String -' ' Literal.String -'i' Literal.String -'n' Literal.String -'v' Literal.String -'a' Literal.String -'l' Literal.String -'i' Literal.String -'d' Literal.String -' ' Literal.String -'n' Literal.String -'u' Literal.String -'m' Literal.String -'b' Literal.String -'e' Literal.String -'r' Literal.String -' ' Literal.String -'f' Literal.String -'o' Literal.String -'r' Literal.String -'m' Literal.String -'a' Literal.String -'t' Literal.String -'"' Literal.String -')' Punctuation +'i' Name ')' Punctuation '\n' Text @@ -11720,654 +4240,196 @@ 'end' Keyword '\n' Text -' ' Text -'return' Keyword -' ' Text -'tmp' Name -'[' Punctuation -'1' Literal.Number.Integer -']' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -'\n' Text - ' ' Text -'function' Keyword +'elseif' Keyword ' ' Text -'float32' Name -'(' Punctuation -'s' Name -'::' Operator -'String' Name -')' Punctuation -'\n' Text - -' ' Text -'if' Keyword +'n' Name ' ' Text -'!' Operator -'float32_isvalid' Name -'(' Punctuation -'s' Name -',' Punctuation +'==' Operator ' ' Text -'tmpf' Name -')' Punctuation -'\n' Text - -' ' Text -'throw' Name -'(' Punctuation -'ArgumentError' Keyword.Type -'(' Punctuation -'"' Literal.String -'f' Literal.String -'l' Literal.String -'o' Literal.String -'a' Literal.String -'t' Literal.String -'3' Literal.String -'2' Literal.String -'(' Literal.String -'S' Literal.String -'t' Literal.String -'r' Literal.String -'i' Literal.String -'n' Literal.String -'g' Literal.String -')' Literal.String -':' Literal.String -' ' Literal.String -'i' Literal.String -'n' Literal.String -'v' Literal.String -'a' Literal.String -'l' Literal.String -'i' Literal.String -'d' Literal.String -' ' Literal.String -'n' Literal.String -'u' Literal.String -'m' Literal.String -'b' Literal.String -'e' Literal.String -'r' Literal.String -' ' Literal.String -'f' Literal.String -'o' Literal.String -'r' Literal.String -'m' Literal.String -'a' Literal.String -'t' Literal.String -'"' Literal.String -')' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'end' Keyword +'3' Literal.Number.Integer '\n' Text ' ' Text -'return' Keyword -' ' Text -'tmpf' Name -'[' Punctuation -'1' Literal.Number.Integer -']' Punctuation -'\n' Text - -' ' Text -'end' Keyword -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'float' Name -'(' Punctuation -'x' Name -'::' Operator -'String' Name -')' Punctuation +'b1' Name ' ' Text '=' Operator ' ' Text -'float64' Name -'(' Punctuation -'x' Name -')' Punctuation -'\n' Text - -'parse_float' Name '(' Punctuation -'x' Name -'::' Operator -'String' Name -')' Punctuation +'u' Name ' ' Text -'=' Operator +'>>' Operator ' ' Text -'float64' Name -'(' Punctuation -'x' Name -')' Punctuation -'\n' Text - -'parse_float' Name -'(' Punctuation -'::' Operator -'Type' Keyword.Type -'{' Punctuation -'Float64' Keyword.Type -'}' Punctuation -',' Punctuation -' ' Text -'x' Name -'::' Operator -'String' Name +'0' Literal.Number.Integer ')' Punctuation ' ' Text -'=' Operator +'%' Operator ' ' Text -'float64' Name -'(' Punctuation -'x' Name -')' Punctuation +'UInt8' Keyword.Type '\n' Text -'parse_float' Name -'(' Punctuation -'::' Operator -'Type' Keyword.Type -'{' Punctuation -'Float32' Keyword.Type -'}' Punctuation -',' Punctuation -' ' Text -'x' Name -'::' Operator -'String' Name -')' Punctuation +' ' Text +'b2' Name ' ' Text '=' Operator ' ' Text -'float32' Name '(' Punctuation -'x' Name -')' Punctuation -'\n' Text - -'\n' Text - -'# copying a byte string (generally not needed due to "immutability")' Comment -'\n' Text - -'\n' Text - -'strcpy' Name -'{' Punctuation -'T' Name -'<:' Operator -'ByteString' Name -'}' Punctuation -'(' Punctuation -'s' Name -'::' Operator -'T' Name -')' Punctuation +'u' Name ' ' Text -'=' Operator +'>>' Operator ' ' Text -'T' Name -'(' Punctuation -'copy' Name -'(' Punctuation -'s' Name -'.' Operator -'data' Name -')' Punctuation +'8' Literal.Number.Integer ')' Punctuation -'\n' Text - -'\n' Text - -'# lexicographically compare byte arrays (used by Latin-1 and UTF-8)' Comment -'\n' Text - -'\n' Text - -'function' Keyword ' ' Text -'lexcmp' Name -'(' Punctuation -'a' Name -'::' Operator -'Array' Keyword.Type -'{' Punctuation -'Uint8' Name -',' Punctuation -'1' Literal.Number.Integer -'}' Punctuation -',' Punctuation +'%' Operator ' ' Text -'b' Name -'::' Operator -'Array' Keyword.Type -'{' Punctuation -'Uint8' Name -',' Punctuation -'1' Literal.Number.Integer -'}' Punctuation -')' Punctuation +'UInt8' Keyword.Type '\n' Text -' ' Text -'c' Name +' ' Text +'b3' Name ' ' Text '=' Operator ' ' Text -'ccall' Keyword '(' Punctuation -':' Operator -'memcmp' Name -',' Punctuation -' ' Text -'Int32' Keyword.Type -',' Punctuation -' ' Text -'(' Punctuation -'Ptr' Keyword.Type -'{' Punctuation -'Uint8' Name -'}' Punctuation -',' Punctuation +'u' Name ' ' Text -'Ptr' Keyword.Type -'{' Punctuation -'Uint8' Name -'}' Punctuation -',' Punctuation +'>>' Operator ' ' Text -'Uint' Name +'16' Literal.Number.Integer ')' Punctuation -',' Punctuation -'\n' Text - -' ' Text -'a' Name -',' Punctuation ' ' Text -'b' Name -',' Punctuation +'%' Operator ' ' Text -'min' Name -'(' Punctuation -'length' Name -'(' Punctuation -'a' Name -')' Punctuation -',' Punctuation -'length' Name -'(' Punctuation -'b' Name -')' Punctuation -')' Punctuation -')' Punctuation +'UInt8' Keyword.Type '\n' Text -' ' Text -'c' Name -' ' Text -'<' Operator -' ' Text -'0' Literal.Number.Integer -' ' Text -'?' Operator -' ' Text -'-' Operator -'1' Literal.Number.Integer -' ' Text -':' Operator +' ' Text +'for' Keyword ' ' Text -'c' Name +'i' Name ' ' Text -'>' Operator +'=' Operator ' ' Text '0' Literal.Number.Integer -' ' Text -'?' Operator -' ' Text -'+' Operator -'1' Literal.Number.Integer -' ' Text ':' Operator -' ' Text -'cmp' Name -'(' Punctuation -'length' Name -'(' Punctuation -'a' Name -')' Punctuation -',' Punctuation -'length' Name -'(' Punctuation -'b' Name -')' Punctuation -')' Punctuation -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'# find the index of the first occurrence of a byte value in a byte array' Comment -'\n' Text - +'r' Name +'-' Operator +'1' Literal.Number.Integer '\n' Text -'function' Keyword -' ' Text -'memchr' Name +' ' Text +'unsafe_store!' Name '(' Punctuation -'a' Name -'::' Operator -'Array' Keyword.Type -'{' Punctuation -'Uint8' Name +'p' Name ',' Punctuation -'1' Literal.Number.Integer -'}' Punctuation +' ' Text +'b1' Name ',' Punctuation ' ' Text -'b' Name -'::' Operator -'Integer' Keyword.Type -')' Punctuation -'\n' Text - -' ' Text -'p' Name +'3' Literal.Number.Integer +'i' Name ' ' Text -'=' Operator +'+' Operator ' ' Text -'pointer' Name -'(' Punctuation -'a' Name +'1' Literal.Number.Integer ')' Punctuation '\n' Text -' ' Text -'q' Name -' ' Text -'=' Operator -' ' Text -'ccall' Keyword -'(' Punctuation -':' Operator -'memchr' Name -',' Punctuation -' ' Text -'Ptr' Keyword.Type -'{' Punctuation -'Uint8' Name -'}' Punctuation -',' Punctuation -' ' Text +' ' Text +'unsafe_store!' Name '(' Punctuation -'Ptr' Keyword.Type -'{' Punctuation -'Uint8' Name -'}' Punctuation -',' Punctuation -' ' Text -'Int32' Keyword.Type -',' Punctuation -' ' Text -'Uint' Name -')' Punctuation -',' Punctuation -' ' Text 'p' Name ',' Punctuation ' ' Text -'b' Name +'b2' Name ',' Punctuation ' ' Text -'length' Name -'(' Punctuation -'a' Name -')' Punctuation -')' Punctuation -'\n' Text - -' ' Text -'q' Name -' ' Text -'==' Operator -' ' Text -'C_NULL' Name.Builtin -' ' Text -'?' Operator -' ' Text -'0' Literal.Number.Integer -' ' Text -':' Operator -' ' Text -'q' Name -' ' Text -'-' Operator -' ' Text -'p' Name +'3' Literal.Number.Integer +'i' Name ' ' Text '+' Operator ' ' Text -'1' Literal.Number.Integer -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'# concatenate byte arrays into a single array' Comment -'\n' Text - -'\n' Text - -'memcat' Name -'(' Punctuation -')' Punctuation -' ' Text -'=' Operator -' ' Text -'Array' Keyword.Type -'(' Punctuation -'Uint8' Name -',' Punctuation -'0' Literal.Number.Integer +'2' Literal.Number.Integer ')' Punctuation '\n' Text -'memcat' Name +' ' Text +'unsafe_store!' Name '(' Punctuation -'a' Name -'::' Operator -'Array' Keyword.Type -'{' Punctuation -'Uint8' Name +'p' Name ',' Punctuation -'1' Literal.Number.Integer -'}' Punctuation -')' Punctuation -' ' Text -'=' Operator ' ' Text -'copy' Name -'(' Punctuation -'a' Name -')' Punctuation -'\n' Text - -'\n' Text - -'function' Keyword -' ' Text -'memcat' Name -'(' Punctuation -'arrays' Name -'::' Operator -'Array' Keyword.Type -'{' Punctuation -'Uint8' Name +'b3' Name ',' Punctuation -'1' Literal.Number.Integer -'}' Punctuation -'.' Operator -'.' Operator -'.' Operator -')' Punctuation -'\n' Text - -' ' Text -'n' Name -' ' Text -'=' Operator -' ' Text -'0' Literal.Number.Integer -'\n' Text - -' ' Text -'for' Keyword -' ' Text -'a' Name ' ' Text -'in' Keyword.Pseudo -' ' Text -'arrays' Name -'\n' Text - -' ' Text -'n' Name +'3' Literal.Number.Integer +'i' Name ' ' Text -'+=' Operator +'+' Operator ' ' Text -'length' Name -'(' Punctuation -'a' Name +'3' Literal.Number.Integer ')' Punctuation '\n' Text -' ' Text +' ' Text 'end' Keyword '\n' Text ' ' Text -'arr' Name -' ' Text -'=' Operator -' ' Text -'Array' Keyword.Type -'(' Punctuation -'Uint8' Name -',' Punctuation +'elseif' Keyword ' ' Text 'n' Name -')' Punctuation -'\n' Text - -' ' Text -'ptr' Name ' ' Text -'=' Operator +'==' Operator ' ' Text -'pointer' Name -'(' Punctuation -'arr' Name -')' Punctuation +'4' Literal.Number.Integer '\n' Text -' ' Text -'offset' Name +' ' Text +'p32' Name ' ' Text '=' Operator ' ' Text -'0' Literal.Number.Integer -'\n' Text - -' ' Text -'for' Keyword -' ' Text -'a' Name -' ' Text -'in' Keyword.Pseudo -' ' Text -'arrays' Name -'\n' Text - -' ' Text -'ccall' Keyword +'reinterpret' Name '(' Punctuation -':' Operator -'memcpy' Name -',' Punctuation -' ' Text 'Ptr' Keyword.Type '{' Punctuation -'Uint8' Name +'UInt32' Keyword.Type '}' Punctuation ',' Punctuation ' ' Text -'(' Punctuation -'Ptr' Keyword.Type -'{' Punctuation -'Uint8' Name -'}' Punctuation -',' Punctuation +'p' Name +')' Punctuation +'\n' Text + +' ' Text +'for' Keyword ' ' Text -'Ptr' Keyword.Type -'{' Punctuation -'Uint8' Name -'}' Punctuation -',' Punctuation +'i' Name ' ' Text -'Uint' Name -')' Punctuation -',' Punctuation +'=' Operator +' ' Text +'1' Literal.Number.Integer +':' Operator +'r' Name '\n' Text -' ' Text -'ptr' Name -'+' Operator -'offset' Name +' ' Text +'unsafe_store!' Name +'(' Punctuation +'p32' Name ',' Punctuation ' ' Text -'a' Name +'u' Name ',' Punctuation ' ' Text -'length' Name -'(' Punctuation -'a' Name -')' Punctuation +'i' Name ')' Punctuation '\n' Text ' ' Text -'offset' Name -' ' Text -'+=' Operator -' ' Text -'length' Name -'(' Punctuation -'a' Name -')' Punctuation +'end' Keyword '\n' Text ' ' Text @@ -12377,64 +4439,8 @@ ' ' Text 'return' Keyword ' ' Text -'arr' Name -'\n' Text - -'end' Keyword -'\n' Text - -'\n' Text - -'# concatenate the data fields of byte strings' Comment -'\n' Text - -'\n' Text - -'memcat' Name -'(' Punctuation -'s' Name -'::' Operator -'ByteString' Name -')' Punctuation -' ' Text -'=' Operator -' ' Text -'memcat' Name -'(' Punctuation 's' Name -'.' Operator -'data' Name -')' Punctuation '\n' Text -'memcat' Name -'(' Punctuation -'sx' Name -'::' Operator -'ByteString' Name -'.' Operator -'.' Operator -'.' Operator -')' Punctuation -' ' Text -'=' Operator -' ' Text -'memcat' Name -'(' Punctuation -'map' Name -'(' Punctuation -'s' Name -'-' Operator -'>' Operator -'s' Name -'.' Operator -'data' Name -',' Punctuation -' ' Text -'sx' Name -')' Punctuation -'.' Operator -'.' Operator -'.' Operator -')' Punctuation +'end' Keyword '\n' Text diff --git a/tests/snippets/julia-repl/test_repl.txt b/tests/snippets/julia-repl/test_repl.txt new file mode 100644 index 00000000..798f0047 --- /dev/null +++ b/tests/snippets/julia-repl/test_repl.txt @@ -0,0 +1,51 @@ +Tests separating Julia's commands from output in REPL-like code blocks + +---input--- +julia> f(x) = sin(π/2x) +f (generic function with 1 method) + +julia> @. f(1:2) +2-element Vector{Float64}: + 1.0 + 0.7071067811865475 + +---tokens--- +'julia>' Generic.Prompt +' ' Text +'f' Name +'(' Punctuation +'x' Name +')' Punctuation +' ' Text +'=' Operator +' ' Text +'sin' Name +'(' Punctuation +'π' Name.Builtin +'/' Operator +'2' Literal.Number.Integer +'x' Name +')' Punctuation +'\n' Text + +'f (generic function with 1 method)\n' Generic.Output + +'\n' Generic.Output + +'julia>' Generic.Prompt +' ' Text +'@.' Name.Decorator +' ' Text +'f' Name +'(' Punctuation +'1' Literal.Number.Integer +':' Operator +'2' Literal.Number.Integer +')' Punctuation +'\n' Text + +'2-element Vector{Float64}:\n' Generic.Output + +' 1.0\n' Generic.Output + +' 0.7071067811865475\n' Generic.Output diff --git a/tests/snippets/julia/test_keywords.txt b/tests/snippets/julia/test_keywords.txt new file mode 100644 index 00000000..235c411c --- /dev/null +++ b/tests/snippets/julia/test_keywords.txt @@ -0,0 +1,89 @@ +# Test keywords are identified + +---input--- +mutable struct MutableType end +struct ImmutableType end +abstract type AbstractMyType end +primitive type MyPrimitive 32 end +(abstract, mutable, type) = true, π, missing + +abstract type AbstractMyType end +primitive type MyPrimitive 32 end +mutable struct MutableType end + +---tokens--- +'mutable struct' Keyword +' ' Text +'MutableType' Keyword.Type +' ' Text +'end' Keyword +'\n' Text + +'struct' Keyword +' ' Text +'ImmutableType' Keyword.Type +' ' Text +'end' Keyword +'\n' Text + +'abstract type' Keyword +' ' Text +'AbstractMyType' Keyword.Type +' ' Text +'end' Keyword +'\n' Text + +'primitive type' Keyword +' ' Text +'MyPrimitive' Keyword.Type +' ' Text +'32' Literal.Number.Integer +' ' Text +'end' Keyword +'\n' Text + +'(' Punctuation +'abstract' Name +',' Punctuation +' ' Text +'mutable' Name +',' Punctuation +' ' Text +'type' Name +')' Punctuation +' ' Text +'=' Operator +' ' Text +'true' Name.Builtin +',' Punctuation +' ' Text +'π' Name.Builtin +',' Punctuation +' ' Text +'missing' Name.Builtin +'\n' Text + +'\n' Text + +'abstract type' Keyword +' ' Text +'AbstractMyType' Keyword.Type +' ' Text +'end' Keyword +'\n' Text + +'primitive \ttype' Keyword +' ' Text +'MyPrimitive' Keyword.Type +' ' Text +'32' Literal.Number.Integer +' ' Text +'end' Keyword +'\n' Text + +'mutable struct' Keyword +' ' Text +'MutableType' Keyword.Type +' ' Text +'end' Keyword +'\n' Text diff --git a/tests/snippets/julia/test_macros.txt b/tests/snippets/julia/test_macros.txt new file mode 100644 index 00000000..8dc27187 --- /dev/null +++ b/tests/snippets/julia/test_macros.txt @@ -0,0 +1,56 @@ +# Test that macros are parsed, including ones which are defined as symbols + +---input--- +@generated function +@. a + b +@~ a + b +@± a + b +@mymacro(a, b) +@+¹ᵀ a + +---tokens--- +'@generated' Name.Decorator +' ' Text +'function' Keyword +'\n' Text + +'@.' Name.Decorator +' ' Text +'a' Name +' ' Text +'+' Operator +' ' Text +'b' Name +'\n' Text + +'@~' Name.Decorator +' ' Text +'a' Name +' ' Text +'+' Operator +' ' Text +'b' Name +'\n' Text + +'@±' Name.Decorator +' ' Text +'a' Name +' ' Text +'+' Operator +' ' Text +'b' Name +'\n' Text + +'@mymacro' Name.Decorator +'(' Punctuation +'a' Name +',' Punctuation +' ' Text +'b' Name +')' Punctuation +'\n' Text + +'@+¹ᵀ' Name.Decorator +' ' Text +'a' Name +'\n' Text diff --git a/tests/snippets/julia/test_names.txt b/tests/snippets/julia/test_names.txt new file mode 100644 index 00000000..338f483f --- /dev/null +++ b/tests/snippets/julia/test_names.txt @@ -0,0 +1,148 @@ +# Test that the range of Julia variable names are correctly identified + +---input--- +a # single character variable +a_simple_name +_leading_underscore +5implicit_mul +6_more_mul +nums1 +nums_2 +nameswith! +multiple!! +embedded!_inthemiddle +embed!1 +prime_suffix′ +for_each # starts with keyword substring + +# variables with characters > \u00A1 +ð # category Ll +Aʺ # category Lm -- \U02BA (MODIFIER LETTER DOUBLE PRIME), not \U2033 (DOUBLE PRIME) +א # category Lo +Ð # category Lu +A̅ # category Mn -- \U0305 (COMBINING OVERLINE) +ⅿ # category Nl -- \U217F (SMALL ROMAN NUMERAL ONE THOUSAND) +A₁ # category No +A² # category No +€ # category Sc +© # category So + +# number-like names +𝟙 # category Nd +𝟏 # category Nd + +---tokens--- +'a' Name +' ' Text +'# single character variable' Comment +'\n' Text + +'a_simple_name' Name +'\n' Text + +'_leading_underscore' Name +'\n' Text + +'5' Literal.Number.Integer +'implicit_mul' Name +'\n' Text + +'6' Literal.Number.Integer +'_more_mul' Name +'\n' Text + +'nums1' Name +'\n' Text + +'nums_2' Name +'\n' Text + +'nameswith!' Name +'\n' Text + +'multiple!!' Name +'\n' Text + +'embedded!_inthemiddle' Name +'\n' Text + +'embed!1' Name +'\n' Text + +'prime_suffix′' Name +'\n' Text + +'for_each' Name +' ' Text +'# starts with keyword substring' Comment +'\n' Text + +'\n' Text + +'# variables with characters > \\u00A1' Comment +'\n' Text + +'ð' Name +' ' Text +'# category Ll' Comment +'\n' Text + +'Aʺ' Name +' ' Text +'# category Lm -- \\U02BA (MODIFIER LETTER DOUBLE PRIME), not \\U2033 (DOUBLE PRIME)' Comment +'\n' Text + +'א' Name +' ' Text +'# category Lo' Comment +'\n' Text + +'Ð' Name +' ' Text +'# category Lu' Comment +'\n' Text + +'A̅' Name +' ' Text +'# category Mn -- \\U0305 (COMBINING OVERLINE)' Comment +'\n' Text + +'ⅿ' Name +' ' Text +'# category Nl -- \\U217F (SMALL ROMAN NUMERAL ONE THOUSAND)' Comment +'\n' Text + +'A₁' Name +' ' Text +'# category No' Comment +'\n' Text + +'A²' Name +' ' Text +'# category No' Comment +'\n' Text + +'€' Name +' ' Text +'# category Sc' Comment +'\n' Text + +'©' Name +' ' Text +'# category So' Comment +'\n' Text + +'\n' Text + +'# number-like names' Comment +'\n' Text + +'𝟙' Name +' ' Text +'# category Nd' Comment +'\n' Text + +'𝟏' Name +' ' Text +'# category Nd' Comment +'\n' Text diff --git a/tests/snippets/julia/test_numbers.txt b/tests/snippets/julia/test_numbers.txt new file mode 100644 index 00000000..5c572438 --- /dev/null +++ b/tests/snippets/julia/test_numbers.txt @@ -0,0 +1,261 @@ +# Tests identification of number forms + +---input--- +# floats + 1e1 1e+1 1e-1 +1.1e1 1.1e+1 1.1e-1 .1e1 .1_1e1 1_1.1e1 1.1_1e1 1.1_11e1 +1.1E1 1.1E+1 1.1E-1 .1E1 .1_1E1 1_1.1E1 1.1_1E1 1.1_11E1 +1.1f1 1.1f+1 1.1f-1 .1f1 .1_1f1 1_1.1f1 1.1_1f1 1.1_11f1 +1E1 1E+1 1E-1 +1f1 1f+1 1f-1 +.1 1. 1.1 1.1_1 1.1_11 .1_1 .1_11 1_1.1_1 +# hex floats +0x1p1 0xa_bp10 0x01_ap11 0x01_abp1 +0x1.1p1 0xA.Bp10 0x0.1_Ap9 0x0_1.Ap1 0x0_1.A_Bp9 + +# integers +1 01 10_1 10_11 + +# non-decimal +0xf 0xf_0 0xfff_000 +0o7 0o7_0 0o777_000 +0b1 0b1_0 0b111_000 + +# invalid in Julia - out of range values +0xg 0o8 0b2 0x1pA +# invalid in Julia - no trailing underscores +1_ 1.1_ 0xf_ 0o7_ 0b1_ 0xF_p1 +# parsed as juxtaposed numeral + variable in Julia (no underscores in exponents) +1e1_1 1E1_1 1f1_1 0xfp1_1 + +# not floats -- range-like expression parts +1..1 ..1 1.. + +---tokens--- +'# floats' Comment +'\n' Text + +' ' Text +'1e1' Literal.Number.Float +' ' Text +'1e+1' Literal.Number.Float +' ' Text +'1e-1' Literal.Number.Float +'\n' Text + +'1.1e1' Literal.Number.Float +' ' Text +'1.1e+1' Literal.Number.Float +' ' Text +'1.1e-1' Literal.Number.Float +' ' Text +'.1e1' Literal.Number.Float +' ' Text +'.1_1e1' Literal.Number.Float +' ' Text +'1_1.1e1' Literal.Number.Float +' ' Text +'1.1_1e1' Literal.Number.Float +' ' Text +'1.1_11e1' Literal.Number.Float +'\n' Text + +'1.1E1' Literal.Number.Float +' ' Text +'1.1E+1' Literal.Number.Float +' ' Text +'1.1E-1' Literal.Number.Float +' ' Text +'.1E1' Literal.Number.Float +' ' Text +'.1_1E1' Literal.Number.Float +' ' Text +'1_1.1E1' Literal.Number.Float +' ' Text +'1.1_1E1' Literal.Number.Float +' ' Text +'1.1_11E1' Literal.Number.Float +'\n' Text + +'1.1f1' Literal.Number.Float +' ' Text +'1.1f+1' Literal.Number.Float +' ' Text +'1.1f-1' Literal.Number.Float +' ' Text +'.1f1' Literal.Number.Float +' ' Text +'.1_1f1' Literal.Number.Float +' ' Text +'1_1.1f1' Literal.Number.Float +' ' Text +'1.1_1f1' Literal.Number.Float +' ' Text +'1.1_11f1' Literal.Number.Float +'\n' Text + +'1E1' Literal.Number.Float +' ' Text +'1E+1' Literal.Number.Float +' ' Text +'1E-1' Literal.Number.Float +'\n' Text + +'1f1' Literal.Number.Float +' ' Text +'1f+1' Literal.Number.Float +' ' Text +'1f-1' Literal.Number.Float +'\n' Text + +'.1' Literal.Number.Float +' ' Text +'1.' Literal.Number.Float +' ' Text +'1.1' Literal.Number.Float +' ' Text +'1.1_1' Literal.Number.Float +' ' Text +'1.1_11' Literal.Number.Float +' ' Text +'.1_1' Literal.Number.Float +' ' Text +'.1_11' Literal.Number.Float +' ' Text +'1_1.1_1' Literal.Number.Float +'\n' Text + +'# hex floats' Comment +'\n' Text + +'0x1p1' Literal.Number.Float +' ' Text +'0xa_bp10' Literal.Number.Float +' ' Text +'0x01_ap11' Literal.Number.Float +' ' Text +'0x01_abp1' Literal.Number.Float +'\n' Text + +'0x1.1p1' Literal.Number.Float +' ' Text +'0xA.Bp10' Literal.Number.Float +' ' Text +'0x0.1_Ap9' Literal.Number.Float +' ' Text +'0x0_1.Ap1' Literal.Number.Float +' ' Text +'0x0_1.A_Bp9' Literal.Number.Float +'\n' Text + +'\n' Text + +'# integers' Comment +'\n' Text + +'1' Literal.Number.Integer +' ' Text +'01' Literal.Number.Integer +' ' Text +'10_1' Literal.Number.Integer +' ' Text +'10_11' Literal.Number.Integer +'\n' Text + +'\n' Text + +'# non-decimal' Comment +'\n' Text + +'0xf' Literal.Number.Hex +' ' Text +'0xf_0' Literal.Number.Hex +' ' Text +'0xfff_000' Literal.Number.Hex +'\n' Text + +'0o7' Literal.Number.Oct +' ' Text +'0o7_0' Literal.Number.Oct +' ' Text +'0o777_000' Literal.Number.Oct +'\n' Text + +'0b1' Literal.Number.Bin +' ' Text +'0b1_0' Literal.Number.Bin +' ' Text +'0b111_000' Literal.Number.Bin +'\n' Text + +'\n' Text + +'# invalid in Julia - out of range values' Comment +'\n' Text + +'0' Literal.Number.Integer +'xg' Name +' ' Text +'0' Literal.Number.Integer +'o8' Name +' ' Text +'0' Literal.Number.Integer +'b2' Name +' ' Text +'0x1' Literal.Number.Hex +'pA' Name +'\n' Text + +'# invalid in Julia - no trailing underscores' Comment +'\n' Text + +'1' Literal.Number.Integer +'_' Name +' ' Text +'1.1' Literal.Number.Float +'_' Name +' ' Text +'0xf' Literal.Number.Hex +'_' Name +' ' Text +'0o7' Literal.Number.Oct +'_' Name +' ' Text +'0b1' Literal.Number.Bin +'_' Name +' ' Text +'0xF' Literal.Number.Hex +'_p1' Name +'\n' Text + +'# parsed as juxtaposed numeral + variable in Julia (no underscores in exponents)' Comment +'\n' Text + +'1e1' Literal.Number.Float +'_1' Name +' ' Text +'1E1' Literal.Number.Float +'_1' Name +' ' Text +'1f1' Literal.Number.Float +'_1' Name +' ' Text +'0xfp1' Literal.Number.Float +'_1' Name +'\n' Text + +'\n' Text + +'# not floats -- range-like expression parts' Comment +'\n' Text + +'1' Literal.Number.Integer +'..' Operator +'1' Literal.Number.Integer +' ' Text +'..' Operator +'1' Literal.Number.Integer +' ' Text +'1' Literal.Number.Integer +'..' Operator +'\n' Text diff --git a/tests/snippets/julia/test_operators.txt b/tests/snippets/julia/test_operators.txt new file mode 100644 index 00000000..017a48e9 --- /dev/null +++ b/tests/snippets/julia/test_operators.txt @@ -0,0 +1,172 @@ +# Test that operators --- dotted and unicode --- are identified correctly. + +---input--- +a += b.c +a .÷= .~b.c +a = !b ⋆ c! +a = b ? c : d ⊕ e +a = √(5) +a -> (a...) .+ 1 +a \ b +1..2 +a = a === b +a <: T +a >: T +a::T +[adjoint]' +(identity)'' +adjoint''' +transpose'ᵀ +suffixed +¹ operator +suffixed +¹²³ operator + +---tokens--- +'a' Name +' ' Text +'+=' Operator +' ' Text +'b' Name +'.' Operator +'c' Name +'\n' Text + +'a' Name +' ' Text +'.÷=' Operator +' ' Text +'.~' Operator +'b' Name +'.' Operator +'c' Name +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'!' Operator +'b' Name +' ' Text +'⋆' Operator +' ' Text +'c!' Name +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'b' Name +' ' Text +'?' Operator +' ' Text +'c' Name +' ' Text +':' Operator +' ' Text +'d' Name +' ' Text +'⊕' Operator +' ' Text +'e' Name +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'√' Operator +'(' Punctuation +'5' Literal.Number.Integer +')' Punctuation +'\n' Text + +'a' Name +' ' Text +'->' Operator +' ' Text +'(' Punctuation +'a' Name +'...' Operator +')' Punctuation +' ' Text +'.+' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'a' Name +' ' Text +'\\' Operator +' ' Text +'b' Name +'\n' Text + +'1' Literal.Number.Integer +'..' Operator +'2' Literal.Number.Integer +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'a' Name +' ' Text +'===' Operator +' ' Text +'b' Name +'\n' Text + +'a' Keyword.Type +' ' Text +'<:' Operator +' ' Text +'T' Keyword.Type +'\n' Text + +'a' Keyword.Type +' ' Text +'>:' Operator +' ' Text +'T' Keyword.Type +'\n' Text + +'a' Name +'::' Operator +'T' Keyword.Type +'\n' Text + +'[' Punctuation +'adjoint' Name +']' Punctuation +"'" Operator +'\n' Text + +'(' Punctuation +'identity' Name +')' Punctuation +"''" Operator +'\n' Text + +'adjoint' Name +"'''" Operator +'\n' Text + +'transpose' Name +"'ᵀ" Operator +'\n' Text + +'suffixed' Name +' ' Text +'+¹' Operator +' ' Text +'operator' Name +'\n' Text + +'suffixed' Name +' ' Text +'+¹²³' Operator +' ' Text +'operator' Name +'\n' Text diff --git a/tests/snippets/julia/test_strings.txt b/tests/snippets/julia/test_strings.txt new file mode 100644 index 00000000..436bfe3c --- /dev/null +++ b/tests/snippets/julia/test_strings.txt @@ -0,0 +1,225 @@ +# Tests string forms + +---input--- +"global function" +"An $interpolated variable" +"An $(a + 1) expression" +"""a""" +""" +global function +de e f +"inner string" +""" +raw"\\ a \" $interp $(1 + 1) \"" +raw""" +"inner string" +$interp +$(1 + 1) +""" +# commented "string" + +@sprintf "%0.2f" var +v"1.0" +var"#nonstandard#" + +r"^[abs]+$"m +arbi"trary"suff +arbi"trary"1234 + +`global function` +`abc \` \$ $interpolated` +`abc $(a + 1)` +```a``` +``` +global function +"thing" ` \$ +`now` $(now()) +``` +# commented `command` + +arbi`trary`suff +arbi`trary`1234 + +---tokens--- +'"' Literal.String +'global function' Literal.String +'"' Literal.String +'\n' Text + +'"' Literal.String +'An ' Literal.String +'$interpolated' Literal.String.Interpol +' variable' Literal.String +'"' Literal.String +'\n' Text + +'"' Literal.String +'An ' Literal.String +'$' Literal.String.Interpol +'(' Punctuation +'a' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +')' Punctuation +' expression' Literal.String +'"' Literal.String +'\n' Text + +'"""' Literal.String +'a' Literal.String +'"""' Literal.String +'\n' Text + +'"""' Literal.String +'\nglobal function\nde e f\n' Literal.String + +'"' Literal.String +'inner string' Literal.String +'"' Literal.String +'\n' Literal.String + +'"""' Literal.String +'\n' Text + +'raw' Literal.String.Affix +'"' Literal.String +'\\\\ a ' Literal.String +'\\"' Literal.String.Escape +' $interp $(1 + 1) ' Literal.String +'\\"' Literal.String.Escape +'"' Literal.String +'\n' Text + +'raw' Literal.String.Affix +'"""' Literal.String +'\n"inner string"\n$interp\n$(1 + 1)\n' Literal.String + +'"""' Literal.String +'\n' Text + +'# commented "string"' Comment +'\n' Text + +'\n' Text + +'@sprintf' Name.Decorator +' ' Text +'"' Literal.String +'%0.2f' Literal.String.Interpol +'"' Literal.String +' ' Text +'var' Name +'\n' Text + +'v' Literal.String.Affix +'"' Literal.String +'1.0' Literal.String +'"' Literal.String +'\n' Text + +'var' Literal.String.Affix +'"' Literal.String +'#nonstandard#' Literal.String +'"' Literal.String +'\n' Text + +'\n' Text + +'r' Literal.String.Affix +'"' Literal.String.Regex +'^[abs]+$' Literal.String.Regex +'"' Literal.String.Regex +'m' Literal.String.Affix +'\n' Text + +'arbi' Literal.String.Affix +'"' Literal.String +'trary' Literal.String +'"' Literal.String +'suff' Literal.String.Affix +'\n' Text + +'arbi' Literal.String.Affix +'"' Literal.String +'trary' Literal.String +'"' Literal.String +'1234' Literal.String.Affix +'\n' Text + +'\n' Text + +'`' Literal.String.Backtick +'global function' Literal.String.Backtick +'`' Literal.String.Backtick +'\n' Text + +'`' Literal.String.Backtick +'abc ' Literal.String.Backtick +'\\`' Literal.String.Escape +' ' Literal.String.Backtick +'\\$' Literal.String.Escape +' ' Literal.String.Backtick +'$interpolated' Literal.String.Interpol +'`' Literal.String.Backtick +'\n' Text + +'`' Literal.String.Backtick +'abc ' Literal.String.Backtick +'$' Literal.String.Interpol +'(' Punctuation +'a' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +')' Punctuation +'`' Literal.String.Backtick +'\n' Text + +'```' Literal.String.Backtick +'a' Literal.String.Backtick +'```' Literal.String.Backtick +'\n' Text + +'```' Literal.String.Backtick +'\nglobal function\n"thing" ' Literal.String.Backtick +'`' Literal.String.Backtick +' ' Literal.String.Backtick +'\\$' Literal.String.Escape +'\n' Literal.String.Backtick + +'`' Literal.String.Backtick +'now' Literal.String.Backtick +'`' Literal.String.Backtick +' ' Literal.String.Backtick +'$' Literal.String.Interpol +'(' Punctuation +'now' Name +'(' Punctuation +')' Punctuation +')' Punctuation +'\n' Literal.String.Backtick + +'```' Literal.String.Backtick +'\n' Text + +'# commented `command`' Comment +'\n' Text + +'\n' Text + +'arbi' Literal.String.Affix +'`' Literal.String.Backtick +'trary' Literal.String.Backtick +'`' Literal.String.Backtick +'suff' Literal.String.Affix +'\n' Text + +'arbi' Literal.String.Affix +'`' Literal.String.Backtick +'trary' Literal.String.Backtick +'`' Literal.String.Backtick +'1234' Literal.String.Affix +'\n' Text diff --git a/tests/snippets/julia/test_symbols.txt b/tests/snippets/julia/test_symbols.txt new file mode 100644 index 00000000..8b85a8e1 --- /dev/null +++ b/tests/snippets/julia/test_symbols.txt @@ -0,0 +1,78 @@ +# Tests that symbols are parsed as special literals + +---input--- +:abc_123 +:abc_def +:α +Val{:mysymbol} + +# non-symbols +a:b +1:b +1.:b +a::T +a<:T +a>:T +UInt(1):UInt(2) + +---tokens--- +':abc_123' Literal.String.Symbol +'\n' Text + +':abc_def' Literal.String.Symbol +'\n' Text + +':α' Literal.String.Symbol +'\n' Text + +'Val' Keyword.Type +'{' Punctuation +':mysymbol' Literal.String.Symbol +'}' Punctuation +'\n' Text + +'\n' Text + +'# non-symbols' Comment +'\n' Text + +'a' Name +':' Operator +'b' Name +'\n' Text + +'1' Literal.Number.Integer +':' Operator +'b' Name +'\n' Text + +'1.' Literal.Number.Float +':' Operator +'b' Name +'\n' Text + +'a' Name +'::' Operator +'T' Keyword.Type +'\n' Text + +'a' Keyword.Type +'<:' Operator +'T' Keyword.Type +'\n' Text + +'a' Keyword.Type +'>:' Operator +'T' Keyword.Type +'\n' Text + +'UInt' Keyword.Type +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +':' Operator +'UInt' Keyword.Type +'(' Punctuation +'2' Literal.Number.Integer +')' Punctuation +'\n' Text diff --git a/tests/snippets/julia/test_types.txt b/tests/snippets/julia/test_types.txt new file mode 100644 index 00000000..dc475349 --- /dev/null +++ b/tests/snippets/julia/test_types.txt @@ -0,0 +1,196 @@ +# Tests identifying names which must be types from context + +---input--- +Union{} +MyType{Nothing, Any} +f(::Union{T,S}) where S where T = 1 +f(::T) where {T} = 1 +f(::Type{<:T}) = 1 +f(::AT) where AT <: AbstractArray{MyType,1} = 1 +f(::Val{:named}) = 1 +f(::typeof(sin)) = 1 +MyInt <: Integer +Number >: MyInt +AT{T,1} <: B +B>:AT{T,1} +A <: f(B) +g(C) <: T + +---tokens--- +'Union' Keyword.Type +'{' Punctuation +'}' Punctuation +'\n' Text + +'MyType' Keyword.Type +'{' Punctuation +'Nothing' Keyword.Type +',' Punctuation +' ' Text +'Any' Keyword.Type +'}' Punctuation +'\n' Text + +'f' Name +'(' Punctuation +'::' Operator +'Union' Keyword.Type +'{' Punctuation +'T' Keyword.Type +',' Punctuation +'S' Keyword.Type +'}' Punctuation +')' Punctuation +' ' Text +'where' Keyword +' ' Text +'S' Keyword.Type +' ' Text +'where' Keyword +' ' Text +'T' Keyword.Type +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'f' Name +'(' Punctuation +'::' Operator +'T' Keyword.Type +')' Punctuation +' ' Text +'where' Keyword +' ' Text +'{' Punctuation +'T' Keyword.Type +'}' Punctuation +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'f' Name +'(' Punctuation +'::' Operator +'Type' Keyword.Type +'{' Punctuation +'<:' Operator +'T' Keyword.Type +'}' Punctuation +')' Punctuation +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'f' Name +'(' Punctuation +'::' Operator +'AT' Keyword.Type +')' Punctuation +' ' Text +'where' Keyword +' ' Text +'AT' Keyword.Type +' ' Text +'<:' Operator +' ' Text +'AbstractArray' Keyword.Type +'{' Punctuation +'MyType' Keyword.Type +',' Punctuation +'1' Literal.Number.Integer +'}' Punctuation +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'f' Name +'(' Punctuation +'::' Operator +'Val' Keyword.Type +'{' Punctuation +':named' Literal.String.Symbol +'}' Punctuation +')' Punctuation +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'f' Name +'(' Punctuation +'::' Operator +'typeof' Name +'(' Punctuation +'sin' Name +')' Punctuation +')' Punctuation +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'MyInt' Keyword.Type +' ' Text +'<:' Operator +' ' Text +'Integer' Keyword.Type +'\n' Text + +'Number' Keyword.Type +' ' Text +'>:' Operator +' ' Text +'MyInt' Keyword.Type +'\n' Text + +'AT' Keyword.Type +'{' Punctuation +'T' Keyword.Type +',' Punctuation +'1' Literal.Number.Integer +'}' Punctuation +' ' Text +'<:' Operator +' ' Text +'B' Keyword.Type +'\n' Text + +'B' Keyword.Type +'>:' Operator +'AT' Keyword.Type +'{' Punctuation +'T' Keyword.Type +',' Punctuation +'1' Literal.Number.Integer +'}' Punctuation +'\n' Text + +'A' Keyword.Type +' ' Text +'<:' Operator +' ' Text +'f' Name +'(' Punctuation +'B' Name +')' Punctuation +'\n' Text + +'g' Name +'(' Punctuation +'C' Name +')' Punctuation +' ' Text +'<:' Operator +' ' Text +'T' Keyword.Type +'\n' Text |