1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
{1}%% Correctly defined arguments block{0}
{4}function{0} {7}y{0} {6}={0} {7}foo{0} {6}({7}x{6}){0}
{1}% Some comment here{0}
{1}% And, maybe, here{0}
{4}arguments{0}
{7}x{0} {6}({3}1{6},{3}2{6}){0} {6}{{7}mustBeReal{6}({7}x{6})}{0}
{4}end{0}
{7}y{0} {6}={0} {7}x{6}*{3}2{6};{0}
{7}arguments{0} {6}={0} {3}1{6};{0}
{7}y{0} {6}={0} {7}y{0} {6}+{0} {7}arguments{6};{0}
{4}end{0}
{1}%% No arguments block, "arguments" is used {0}
{1}% as a variable name (identifier){0}
{1}% Prevent arguments from folding with an identifier{0}
{4}function{0} {7}y{0} {6}={0} {7}foo{0} {6}({7}x{6}){0}
{1}% Some comment here{0}
{7}x{0} {6}={0} {7}x{0} {6}+{0} {3}1{6};{0}
{7}arguments{0} {6}={0} {3}10{6};{0}
{7}y{0} {6}={0} {7}x{0} {6}+{0} {7}arguments{6};{0}
{4}end{0}
{1}% Prevent arguments from folding with a number{0}
{4}function{0} {7}y{0} {6}={0} {7}foo{0} {6}({7}x{6}){0}
{3}4{0}
{7}arguments{0} {6}={0} {3}10{6};{0}
{7}y{0} {6}={0} {7}x{0} {6}+{0} {7}arguments{6};{0}
{4}end{0}
{1}% With a double quote string{0}
{4}function{0} {7}y{0} {6}={0} {7}foo{0} {6}({7}x{6}){0}
{8}"test"{0}
{7}arguments{0} {6}={0} {3}10{6};{0}
{7}y{0} {6}={0} {7}x{0} {6}+{0} {7}arguments{6};{0}
{4}end{0}
{1}% With a string{0}
{4}function{0} {7}y{0} {6}={0} {7}foo{0} {6}({7}x{6}){0}
{5}'test'{0}
{7}arguments{0} {6}={0} {3}10{6};{0}
{7}y{0} {6}={0} {7}x{0} {6}+{0} {7}arguments{6};{0}
{4}end{0}
{1}% With a keyword{0}
{4}function{0} {7}y{0} {6}={0} {7}foo{0} {6}({7}x{6}){0}
{4}if{0} {7}x{0} {6}=={0} {3}0{6};{0}
{4}return{0} {3}0{6};{0}
{4}end{0}
{7}arguments{0} {6}={0} {3}10{6};{0}
{7}y{0} {6}={0} {7}x{0} {6}+{0} {7}arguments{6};{0}
{4}end{0}
{1}% With an operator (illegal syntax){0}
{4}function{0} {7}y{0} {6}={0} {7}foo{0} {6}({7}x{6}){0}
{6}*{0}
{7}arguments{0} {6}={0} {3}10{6};{0}
{7}y{0} {6}={0} {7}x{0} {6}+{0} {7}arguments{6};{0}
{4}end{0}
{1}% Semicolon is equivalent to a comment{0}
{4}function{0} {7}y{0} {6}={0} {7}foo{6}({7}x{6}){0}
{6};;;;;;;{0}
{4}arguments{0}
{7}x{0}
{4}end{0}
{7}y{0} {6}={0} {7}x{0} {6}+{0} {3}2{6};{0}
{4}end{0}
{1}% Arguments block is illegal in nested functions,{0}
{1}% but lexer should process it anyway{0}
{4}function{0} {7}y{0} {6}={0} {7}foo{0} {6}({7}x{6}){0}
{4}arguments{0}
{7}x{0} {6}({3}1{6},{3}2{6}){0} {6}{{7}mustBeReal{6}({7}x{6})}{0}
{4}end{0}
{4}function{0} {7}y{0} {6}={0} {7}foo{0} {6}({7}x{6}){0}
{4}arguments{0}
{7}x{0} {6}({3}1{6},{3}2{6}){0} {6}{{7}mustBeReal{6}({7}x{6})}{0}
{4}end{0}
{7}var{0} {6}={0} {3}0{6};{0}
{7}arguments{0} {6}={0} {3}5{6};{0}
{7}y{0} {6}={0} {7}arguments{0} {6}+{0} {7}x{6};{0}
{4}end{0}
{1}% Use as a variable, just in case{0}
{7}arguments{0} {6}={0} {3}10{6};{0}
{4}end{0}
{1}% Erroneous use of arguments block{0}
{4}function{0} {7}y{0} {6}={0} {7}foo{6}({7}x{6}){0}
{1}% Some comment{0}
{7}x{0} {6}={0} {7}x{0} {6}+{0} {3}1{6};{0}
{7}arguments{0}
{7}x{0}
{4}end{0}
{7}y{0} {6}={0} {7}x{6};{0}
{4}end{0}
{1}% "arguments" is an argument name too{0}
{4}function{0} {7}r{0} {6}={0} {7}foo{6}({7}x{6},{0} {7}arguments{6}){0}
{4}arguments{0}
{7}x{0}
{7}arguments{0}
{4}end{0}
{7}r{0} {6}={0} {7}bar{6}({7}x{6},{0} {7}arguments{6}{:});{0}
{4}end{0}
{1}% Multiple arguments blocks{0}
{4}function{0} {6}[{7}a{6},{0} {7}b{6}]{0} {6}={0} {7}foo{6}({7}x{6},{0} {7}y{6},{0} {7}varargin{6}){0}
{4}arguments{6}({7}Input{6}){0}
{7}x{0} {6}({3}1{6},{3}4{6}){0} {6}{{7}mustBeReal{6}}{0}
{7}y{0} {6}({3}1{6},:){0} {6}{{7}mustBeInteger{6}}{0} {6}={0} {7}x{6}({3}2{6}:{3}end{6});{0}
{4}end{0}
{4}arguments{6}({7}Input{6},{0} {7}Repeating{6}){0}
{7}varargin{0}
{4}end{0}
{4}arguments{6}({7}Output{6}){0}
{7}a{0} {6}({3}1{6},{3}1{6}){0} {6}{{7}mustBeReal{6}}{0}
{7}b{0} {6}({3}1{6},{3}1{6}){0} {6}{{7}mustBeNonNegative{6}}{0}
{4}end{0}
{7}var{0} {6}={0} {3}10{6};{0}
{7}arguments{0} {6}={0} {6}{{8}"now"{6},{0} {8}"it's"{6},{0} {8}"variable"{6}};{0}
{6}[{7}a{6},{0} {7}b{6}]{0} {6}={0} {7}bar{6}({7}x{6},{0} {7}y{6},{0} {7}arguments{6});{0}
{4}end{0}
{1}% One line function with arguments block.{0}
{1}% This code style is rarely used (if at all), but the{0}
{1}% lexer shouldn't break{0}
{4}function{0} {7}y{0} {6}={0} {7}foo{6}({7}x{6});{0} {4}arguments{6};{0} {7}x{6};{0} {4}end{6};{0} {7}y{0} {6}={0} {7}bar{6}({7}x{6});{0} {4}end{0}
|