Class: Parser::Lexer
- Inherits:
-
Object
- Object
- Parser::Lexer
- Defined in:
- lib/parser/lexer.rb
Overview
line 3 “lib/parser/lexer.rl”
BEFORE YOU START ===
Read the Ruby Hacking Guide chapter 11, available in English at whitequark.org/blog/2013/04/01/ruby-hacking-guide-ch-11-finite-state-lexer/
Remember two things about Ragel scanners:
1) Longest match wins.
2) If two matches have the same length, the first
in source code wins.
General rules of making Ragel and Bison happy:
* `p` (position) and `@te` contain the index of the character
they're pointing to ("current"), plus one. `@ts` contains the index
of the corresponding character. The code for extracting matched token is:
@source[@ts...@te]
* If your input is `foooooooobar` and the rule is:
'f' 'o'+
the result will be:
foooooooobar
^ ts=0 ^ p=te=9
* A Ragel lexer action should not emit more than one token, unless
you know what you are doing.
* All Ragel commands (fnext, fgoto, ...) end with a semicolon.
* If an action emits the token and transitions to another state, use
these Ragel commands:
emit($whatever)
fnext $next_state; fbreak;
If you perform `fgoto` in an action which does not emit a token nor
rewinds the stream pointer, the parser's side-effectful,
context-sensitive lookahead actions will break in a hard to detect
and debug way.
* If an action does not emit a token:
fgoto $next_state;
* If an action features lookbehind, i.e. matches characters with the
intent of passing them to another action:
p = @ts - 1
fgoto $next_state;
or, if the lookbehind consists of a single character:
fhold; fgoto $next_state;
* Ragel merges actions. So, if you have `e_lparen = '(' %act` and
`c_lparen = '('` and a lexer action `e_lparen | c_lparen`, the result
_will_ invoke the action `act`.
e_something stands for "something with **e**mbedded action".
* EOF is explicit and is matched by `c_eof`. If you want to introspect
the state of the lexer, add this rule to the state:
c_eof => do_eof;
* If you proceed past EOF, the lexer will complain:
NoMethodError: undefined method `ord' for nil:NilClass
Defined Under Namespace
Modules: Explanation Classes: Literal, StackState
Constant Summary collapse
- LEX_STATES =
{ :line_begin => lex_en_line_begin, :expr_beg => lex_en_expr_beg, :expr_value => lex_en_expr_value, :expr_mid => lex_en_expr_mid, :expr_dot => lex_en_expr_dot, :expr_fname => lex_en_expr_fname, :expr_end => lex_en_expr_end, :expr_arg => lex_en_expr_arg, :expr_endarg => lex_en_expr_endarg, }
Class Attribute Summary collapse
-
._lex_actions ⇒ Object
Returns the value of attribute _lex_actions.
-
._lex_eof_trans ⇒ Object
Returns the value of attribute _lex_eof_trans.
-
._lex_from_state_actions ⇒ Object
Returns the value of attribute _lex_from_state_actions.
-
._lex_index_offsets ⇒ Object
Returns the value of attribute _lex_index_offsets.
-
._lex_indicies ⇒ Object
Returns the value of attribute _lex_indicies.
-
._lex_key_offsets ⇒ Object
Returns the value of attribute _lex_key_offsets.
-
._lex_range_lengths ⇒ Object
Returns the value of attribute _lex_range_lengths.
-
._lex_single_lengths ⇒ Object
Returns the value of attribute _lex_single_lengths.
-
._lex_to_state_actions ⇒ Object
Returns the value of attribute _lex_to_state_actions.
-
._lex_trans_actions ⇒ Object
Returns the value of attribute _lex_trans_actions.
-
._lex_trans_keys ⇒ Object
Returns the value of attribute _lex_trans_keys.
-
._lex_trans_targs ⇒ Object
Returns the value of attribute _lex_trans_targs.
-
.lex_en_expr_arg ⇒ Object
Returns the value of attribute lex_en_expr_arg.
-
.lex_en_expr_beg ⇒ Object
Returns the value of attribute lex_en_expr_beg.
-
.lex_en_expr_dot ⇒ Object
Returns the value of attribute lex_en_expr_dot.
-
.lex_en_expr_end ⇒ Object
Returns the value of attribute lex_en_expr_end.
-
.lex_en_expr_endarg ⇒ Object
Returns the value of attribute lex_en_expr_endarg.
-
.lex_en_expr_fname ⇒ Object
Returns the value of attribute lex_en_expr_fname.
-
.lex_en_expr_mid ⇒ Object
Returns the value of attribute lex_en_expr_mid.
-
.lex_en_expr_value ⇒ Object
Returns the value of attribute lex_en_expr_value.
-
.lex_en_expr_variable ⇒ Object
Returns the value of attribute lex_en_expr_variable.
-
.lex_en_interp_string ⇒ Object
Returns the value of attribute lex_en_interp_string.
-
.lex_en_interp_words ⇒ Object
Returns the value of attribute lex_en_interp_words.
-
.lex_en_leading_dot ⇒ Object
Returns the value of attribute lex_en_leading_dot.
-
.lex_en_line_begin ⇒ Object
Returns the value of attribute lex_en_line_begin.
-
.lex_en_line_comment ⇒ Object
Returns the value of attribute lex_en_line_comment.
-
.lex_en_plain_string ⇒ Object
Returns the value of attribute lex_en_plain_string.
-
.lex_en_plain_words ⇒ Object
Returns the value of attribute lex_en_plain_words.
-
.lex_en_regexp_modifiers ⇒ Object
Returns the value of attribute lex_en_regexp_modifiers.
-
.lex_error ⇒ Object
Returns the value of attribute lex_error.
-
.lex_start ⇒ Object
Returns the value of attribute lex_start.
Instance Attribute Summary collapse
-
#cmdarg ⇒ Object
Returns the value of attribute cmdarg.
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#cond ⇒ Object
Returns the value of attribute cond.
-
#diagnostics ⇒ Object
Returns the value of attribute diagnostics.
-
#source_buffer ⇒ Object
%.
-
#static_env ⇒ Object
Returns the value of attribute static_env.
Instance Method Summary collapse
-
#advance ⇒ Object
Return next token: [type, value].
-
#clear_comments ⇒ Object
Return the current collected comment block and clear the storage.
-
#initialize(version) ⇒ Lexer
constructor
A new instance of Lexer.
- #reset(reset_state = true) ⇒ Object
- #state ⇒ Object
- #state=(state) ⇒ Object
Constructor Details
#initialize(version) ⇒ Lexer
Returns a new instance of Lexer.
2929 2930 2931 2932 2933 2934 |
# File 'lib/parser/lexer.rb', line 2929 def initialize(version) @version = version @static_env = nil reset end |
Class Attribute Details
._lex_actions ⇒ Object
Returns the value of attribute _lex_actions.
86 87 88 |
# File 'lib/parser/lexer.rb', line 86 def _lex_actions @_lex_actions end |
._lex_eof_trans ⇒ Object
Returns the value of attribute _lex_eof_trans.
2725 2726 2727 |
# File 'lib/parser/lexer.rb', line 2725 def _lex_eof_trans @_lex_eof_trans end |
._lex_from_state_actions ⇒ Object
Returns the value of attribute _lex_from_state_actions.
2611 2612 2613 |
# File 'lib/parser/lexer.rb', line 2611 def _lex_from_state_actions @_lex_from_state_actions end |
._lex_index_offsets ⇒ Object
Returns the value of attribute _lex_index_offsets.
1365 1366 1367 |
# File 'lib/parser/lexer.rb', line 1365 def _lex_index_offsets @_lex_index_offsets end |
._lex_indicies ⇒ Object
Returns the value of attribute _lex_indicies.
1479 1480 1481 |
# File 'lib/parser/lexer.rb', line 1479 def _lex_indicies @_lex_indicies end |
._lex_key_offsets ⇒ Object
Returns the value of attribute _lex_key_offsets.
205 206 207 |
# File 'lib/parser/lexer.rb', line 205 def _lex_key_offsets @_lex_key_offsets end |
._lex_range_lengths ⇒ Object
Returns the value of attribute _lex_range_lengths.
1251 1252 1253 |
# File 'lib/parser/lexer.rb', line 1251 def _lex_range_lengths @_lex_range_lengths end |
._lex_single_lengths ⇒ Object
Returns the value of attribute _lex_single_lengths.
1137 1138 1139 |
# File 'lib/parser/lexer.rb', line 1137 def _lex_single_lengths @_lex_single_lengths end |
._lex_to_state_actions ⇒ Object
Returns the value of attribute _lex_to_state_actions.
2497 2498 2499 |
# File 'lib/parser/lexer.rb', line 2497 def _lex_to_state_actions @_lex_to_state_actions end |
._lex_trans_actions ⇒ Object
Returns the value of attribute _lex_trans_actions.
2343 2344 2345 |
# File 'lib/parser/lexer.rb', line 2343 def _lex_trans_actions @_lex_trans_actions end |
._lex_trans_keys ⇒ Object
Returns the value of attribute _lex_trans_keys.
319 320 321 |
# File 'lib/parser/lexer.rb', line 319 def _lex_trans_keys @_lex_trans_keys end |
._lex_trans_targs ⇒ Object
Returns the value of attribute _lex_trans_targs.
2189 2190 2191 |
# File 'lib/parser/lexer.rb', line 2189 def _lex_trans_targs @_lex_trans_targs end |
.lex_en_expr_arg ⇒ Object
Returns the value of attribute lex_en_expr_arg.
2880 2881 2882 |
# File 'lib/parser/lexer.rb', line 2880 def lex_en_expr_arg @lex_en_expr_arg end |
.lex_en_expr_beg ⇒ Object
Returns the value of attribute lex_en_expr_beg.
2892 2893 2894 |
# File 'lib/parser/lexer.rb', line 2892 def lex_en_expr_beg @lex_en_expr_beg end |
.lex_en_expr_dot ⇒ Object
Returns the value of attribute lex_en_expr_dot.
2876 2877 2878 |
# File 'lib/parser/lexer.rb', line 2876 def lex_en_expr_dot @lex_en_expr_dot end |
.lex_en_expr_end ⇒ Object
Returns the value of attribute lex_en_expr_end.
2900 2901 2902 |
# File 'lib/parser/lexer.rb', line 2900 def lex_en_expr_end @lex_en_expr_end end |
.lex_en_expr_endarg ⇒ Object
Returns the value of attribute lex_en_expr_endarg.
2884 2885 2886 |
# File 'lib/parser/lexer.rb', line 2884 def lex_en_expr_endarg @lex_en_expr_endarg end |
.lex_en_expr_fname ⇒ Object
Returns the value of attribute lex_en_expr_fname.
2872 2873 2874 |
# File 'lib/parser/lexer.rb', line 2872 def lex_en_expr_fname @lex_en_expr_fname end |
.lex_en_expr_mid ⇒ Object
Returns the value of attribute lex_en_expr_mid.
2888 2889 2890 |
# File 'lib/parser/lexer.rb', line 2888 def lex_en_expr_mid @lex_en_expr_mid end |
.lex_en_expr_value ⇒ Object
Returns the value of attribute lex_en_expr_value.
2896 2897 2898 |
# File 'lib/parser/lexer.rb', line 2896 def lex_en_expr_value @lex_en_expr_value end |
.lex_en_expr_variable ⇒ Object
Returns the value of attribute lex_en_expr_variable.
2868 2869 2870 |
# File 'lib/parser/lexer.rb', line 2868 def lex_en_expr_variable @lex_en_expr_variable end |
.lex_en_interp_string ⇒ Object
Returns the value of attribute lex_en_interp_string.
2852 2853 2854 |
# File 'lib/parser/lexer.rb', line 2852 def lex_en_interp_string @lex_en_interp_string end |
.lex_en_interp_words ⇒ Object
Returns the value of attribute lex_en_interp_words.
2848 2849 2850 |
# File 'lib/parser/lexer.rb', line 2848 def lex_en_interp_words @lex_en_interp_words end |
.lex_en_leading_dot ⇒ Object
Returns the value of attribute lex_en_leading_dot.
2904 2905 2906 |
# File 'lib/parser/lexer.rb', line 2904 def lex_en_leading_dot @lex_en_leading_dot end |
.lex_en_line_begin ⇒ Object
Returns the value of attribute lex_en_line_begin.
2912 2913 2914 |
# File 'lib/parser/lexer.rb', line 2912 def lex_en_line_begin @lex_en_line_begin end |
.lex_en_line_comment ⇒ Object
Returns the value of attribute lex_en_line_comment.
2908 2909 2910 |
# File 'lib/parser/lexer.rb', line 2908 def lex_en_line_comment @lex_en_line_comment end |
.lex_en_plain_string ⇒ Object
Returns the value of attribute lex_en_plain_string.
2860 2861 2862 |
# File 'lib/parser/lexer.rb', line 2860 def lex_en_plain_string @lex_en_plain_string end |
.lex_en_plain_words ⇒ Object
Returns the value of attribute lex_en_plain_words.
2856 2857 2858 |
# File 'lib/parser/lexer.rb', line 2856 def lex_en_plain_words @lex_en_plain_words end |
.lex_en_regexp_modifiers ⇒ Object
Returns the value of attribute lex_en_regexp_modifiers.
2864 2865 2866 |
# File 'lib/parser/lexer.rb', line 2864 def lex_en_regexp_modifiers @lex_en_regexp_modifiers end |
.lex_error ⇒ Object
Returns the value of attribute lex_error.
2843 2844 2845 |
# File 'lib/parser/lexer.rb', line 2843 def lex_error @lex_error end |
.lex_start ⇒ Object
Returns the value of attribute lex_start.
2839 2840 2841 |
# File 'lib/parser/lexer.rb', line 2839 def lex_start @lex_start end |
Instance Attribute Details
#cmdarg ⇒ Object
Returns the value of attribute cmdarg.
2925 2926 2927 |
# File 'lib/parser/lexer.rb', line 2925 def cmdarg @cmdarg end |
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
2927 2928 2929 |
# File 'lib/parser/lexer.rb', line 2927 def comments @comments end |
#cond ⇒ Object
Returns the value of attribute cond.
2925 2926 2927 |
# File 'lib/parser/lexer.rb', line 2925 def cond @cond end |
#diagnostics ⇒ Object
Returns the value of attribute diagnostics.
2922 2923 2924 |
# File 'lib/parser/lexer.rb', line 2922 def diagnostics @diagnostics end |
#source_buffer ⇒ Object
%
2920 2921 2922 |
# File 'lib/parser/lexer.rb', line 2920 def source_buffer @source_buffer end |
#static_env ⇒ Object
Returns the value of attribute static_env.
2923 2924 2925 |
# File 'lib/parser/lexer.rb', line 2923 def static_env @static_env end |
Instance Method Details
#advance ⇒ Object
Return next token: [type, value].
3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 |
# File 'lib/parser/lexer.rb', line 3016 def advance if @token_queue.any? return @token_queue.shift end # Ugly, but dependent on Ragel output. Consider refactoring it somehow. _lex_trans_keys = self.class.send :_lex_trans_keys _lex_actions = self.class.send :_lex_actions _lex_key_offsets = self.class.send :_lex_key_offsets _lex_index_offsets = self.class.send :_lex_index_offsets _lex_single_lengths = self.class.send :_lex_single_lengths _lex_range_lengths = self.class.send :_lex_range_lengths _lex_indicies = self.class.send :_lex_indicies _lex_trans_targs = self.class.send :_lex_trans_targs _lex_trans_actions = self.class.send :_lex_trans_actions _lex_to_state_actions = self.class.send :_lex_to_state_actions _lex_from_state_actions = self.class.send :_lex_from_state_actions p, pe, eof = @p, @source.length + 1, nil # line 3038 "lib/parser/lexer.rb" begin _klen, _trans, _keys, _acts, _nacts = nil _goto_level = 0 _resume = 10 _eof_trans = 15 _again = 20 _test_eof = 30 _out = 40 while true _trigger_goto = false if _goto_level <= 0 if p == pe _goto_level = _test_eof next end if @cs == 0 _goto_level = _out next end end if _goto_level <= _resume _acts = _lex_from_state_actions[ @cs] _nacts = _lex_actions[_acts] _acts += 1 while _nacts > 0 _nacts -= 1 _acts += 1 case _lex_actions[_acts - 1] when 42 then # line 1 "NONE" begin @ts = p end # line 3072 "lib/parser/lexer.rb" end # from state action switch end if _trigger_goto next end _keys = _lex_key_offsets[ @cs] _trans = _lex_index_offsets[ @cs] _klen = _lex_single_lengths[ @cs] _break_match = false begin if _klen > 0 _lower = _keys _upper = _keys + _klen - 1 loop do break if _upper < _lower _mid = _lower + ( (_upper - _lower) >> 1 ) if ( @source[p].ord) < _lex_trans_keys[_mid] _upper = _mid - 1 elsif ( @source[p].ord) > _lex_trans_keys[_mid] _lower = _mid + 1 else _trans += (_mid - _keys) _break_match = true break end end # loop break if _break_match _keys += _klen _trans += _klen end _klen = _lex_range_lengths[ @cs] if _klen > 0 _lower = _keys _upper = _keys + (_klen << 1) - 2 loop do break if _upper < _lower _mid = _lower + (((_upper-_lower) >> 1) & ~1) if ( @source[p].ord) < _lex_trans_keys[_mid] _upper = _mid - 2 elsif ( @source[p].ord) > _lex_trans_keys[_mid+1] _lower = _mid + 2 else _trans += ((_mid - _keys) >> 1) _break_match = true break end end # loop break if _break_match _trans += _klen end end while false _trans = _lex_indicies[_trans] end if _goto_level <= _eof_trans @cs = _lex_trans_targs[_trans] if _lex_trans_actions[_trans] != 0 _acts = _lex_trans_actions[_trans] _nacts = _lex_actions[_acts] _acts += 1 while _nacts > 0 _nacts -= 1 _acts += 1 case _lex_actions[_acts - 1] when 0 then # line 353 "lib/parser/lexer.rl" begin # Record position of a newline for precise line and column reporting. # # This action is embedded directly into c_nl, as it is idempotent and # there are no cases when we need to skip it. @newline_s = p end when 1 then # line 480 "lib/parser/lexer.rl" begin @escape = "" codepoints = tok(@escape_s + 2, p - 1) codepoints.split(/[ \t]/).each do |codepoint_str| codepoint = codepoint_str.to_i(16) if codepoint >= 0x110000 @escape = lambda do # TODO better location reporting diagnostic :error, Parser::ERRORS[:unicode_point_too_large], range(@escape_s, p) end break end @escape += codepoint.chr(Encoding::UTF_8) end end when 2 then # line 501 "lib/parser/lexer.rl" begin @escape = { 'a' => "\a", 'b' => "\b", 'e' => "\e", 'f' => "\f", 'n' => "\n", 'r' => "\r", 's' => "\s", 't' => "\t", 'v' => "\v", '\\' => "\\" }.fetch(@source[p - 1].chr, @source[p - 1].chr) end when 3 then # line 509 "lib/parser/lexer.rl" begin @escape = lambda do diagnostic :error, Parser::ERRORS[:invalid_escape] end end when 4 then # line 515 "lib/parser/lexer.rl" begin @escape = (@escape[0].ord & 0x9f).chr end when 5 then # line 519 "lib/parser/lexer.rl" begin @escape = (@escape[0].ord | 0x80).chr end when 6 then # line 525 "lib/parser/lexer.rl" begin @escape = @source[p - 1].chr end when 7 then # line 530 "lib/parser/lexer.rl" begin @escape = "\x7f" end when 8 then # line 531 "lib/parser/lexer.rl" begin @escape = @source[p - 1].chr end when 9 then # line 537 "lib/parser/lexer.rl" begin @escape = tok(@escape_s, p).to_i(8).chr end when 10 then # line 541 "lib/parser/lexer.rl" begin @escape = tok(@escape_s + 1, p).to_i(16).chr end when 11 then # line 544 "lib/parser/lexer.rl" begin @escape = tok(@escape_s + 1, p).to_i(16).chr(Encoding::UTF_8) end when 12 then # line 549 "lib/parser/lexer.rl" begin @escape = lambda do diagnostic :error, Parser::ERRORS[:invalid_hex_escape], range(@escape_s - 1, p + 2) end end when 13 then # line 564 "lib/parser/lexer.rl" begin @escape = lambda do diagnostic :error, Parser::ERRORS[:invalid_unicode_escape], range(@escape_s - 1, p) end end when 14 then # line 578 "lib/parser/lexer.rl" begin @escape = lambda do diagnostic :fatal, Parser::ERRORS[:unterminated_unicode], range(p - 1, p) end end when 15 then # line 607 "lib/parser/lexer.rl" begin diagnostic :fatal, Parser::ERRORS[:escape_eof], range(p - 1, p) end when 16 then # line 614 "lib/parser/lexer.rl" begin @escape_s = p @escape = nil end when 17 then # line 654 "lib/parser/lexer.rl" begin # After every heredoc was parsed, @herebody_s contains the # position of next token after all heredocs. if @herebody_s p = @herebody_s - 1 @herebody_s = nil end end when 18 then # line 782 "lib/parser/lexer.rl" begin @cond.push(false); @cmdarg.push(false) if literal literal.start_interp_brace end end when 19 then # line 790 "lib/parser/lexer.rl" begin if literal if literal.end_interp_brace_and_try_closing emit(:tRCURLY, '}') if literal.words? emit(:tSPACE, nil) end if literal.saved_herebody_s @herebody_s = literal.saved_herebody_s end p = p - 1; @cs = (stack_pop); begin p += 1 _trigger_goto = true _goto_level = _out break end end end end when 20 then # line 884 "lib/parser/lexer.rl" begin tm = p end when 21 then # line 885 "lib/parser/lexer.rl" begin tm = p - 2 end when 22 then # line 890 "lib/parser/lexer.rl" begin tm = p end when 23 then # line 891 "lib/parser/lexer.rl" begin tm = p - 2 end when 24 then # line 892 "lib/parser/lexer.rl" begin tm = p - 2 end when 25 then # line 893 "lib/parser/lexer.rl" begin tm = p - 2 end when 26 then # line 894 "lib/parser/lexer.rl" begin tm = p - 3 end when 27 then # line 899 "lib/parser/lexer.rl" begin tm = p - 2 end when 28 then # line 904 "lib/parser/lexer.rl" begin tm = p - 2 end when 29 then # line 910 "lib/parser/lexer.rl" begin @cond.push(false); @cmdarg.push(false) end when 30 then # line 917 "lib/parser/lexer.rl" begin @cond.push(false); @cmdarg.push(false) @paren_nest += 1 end when 31 then # line 923 "lib/parser/lexer.rl" begin @paren_nest -= 1 end when 32 then # line 1279 "lib/parser/lexer.rl" begin @heredoc_e = p end when 33 then # line 1280 "lib/parser/lexer.rl" begin new_herebody_s = p end when 34 then # line 1583 "lib/parser/lexer.rl" begin @num_base = 16; @num_digits_s = p end when 35 then # line 1585 "lib/parser/lexer.rl" begin @num_base = 10; @num_digits_s = p end when 36 then # line 1587 "lib/parser/lexer.rl" begin @num_base = 8; @num_digits_s = p end when 37 then # line 1589 "lib/parser/lexer.rl" begin @num_base = 2; @num_digits_s = p end when 38 then # line 1592 "lib/parser/lexer.rl" begin @num_base = 10; @num_digits_s = @ts end when 39 then # line 1594 "lib/parser/lexer.rl" begin @num_base = 8; @num_digits_s = @ts end when 40 then # line 1691 "lib/parser/lexer.rl" begin tm = p end when 43 then # line 1 "NONE" begin @te = p+1 end when 44 then # line 810 "lib/parser/lexer.rl" begin @te = p+1 begin literal.flush_string emit(:tSTRING_DBEG, '#{') literal.saved_herebody_s = @herebody_s @herebody_s = nil literal.start_interp_brace begin @stack[ @top] = @cs @top+= 1 @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 45 then # line 760 "lib/parser/lexer.rl" begin @te = p+1 begin literal.flush_string emit(:tSTRING_DVAR, nil, @ts, @ts + 1) p = @ts begin @stack[ @top] = @cs @top+= 1 @cs = 302 _trigger_goto = true _goto_level = _again break end end end when 46 then # line 828 "lib/parser/lexer.rl" begin @te = p+1 begin literal.flush_string end end when 47 then # line 719 "lib/parser/lexer.rl" begin @te = p+1 begin is_eof = eof_char? @source[p] if literal.heredoc? # Try ending the heredoc with the complete most recently # scanned line. @herebody_s always refers to the start of such line. if literal.nest_and_try_closing(tok(@herebody_s, @te - 1), @herebody_s, @te - 1) # Adjust @herebody_s to point to the next line. @herebody_s = @te # Continue regular lexing after the heredoc reference (<<END). p = literal.heredoc_e - 1 begin @cs = (pop_literal) _trigger_goto = true _goto_level = _again break end else # Ditto. @herebody_s = @te end end if is_eof diagnostic :fatal, Parser::ERRORS[:string_eof], range(literal.str_s, literal.str_s + 1) end # A literal newline is appended if the heredoc was _not_ closed # this time. See also Literal#nest_and_try_closing for rationale of # calling #flush_string here. literal.extend_string tok, @ts, @te literal.flush_string end end when 48 then # line 663 "lib/parser/lexer.rl" begin @te = p+1 begin if literal.nest_and_try_closing tok, @ts, @te @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else literal.extend_string tok, @ts, @te end end end when 49 then # line 760 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin literal.flush_string emit(:tSTRING_DVAR, nil, @ts, @ts + 1) p = @ts begin @stack[ @top] = @cs @top+= 1 @cs = 302 _trigger_goto = true _goto_level = _again break end end end when 50 then # line 671 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin if literal.nest_and_try_closing('\\', @ts, @ts + 1) # If the literal is actually closed by the backslash, # rewind the input prior to consuming the escape sequence. p = @escape_s - 1 @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else # Get the first character after the backslash. escaped_char = @source[@escape_s].chr if literal.munge_escape? escaped_char # If this particular literal uses this character as an opening # or closing delimiter, it is an escape sequence for that # particular character. Write it without the backslash. if literal.regexp? # Regular expressions should have every escape sequence in its # raw form. literal.extend_string(tok, @ts, @te) else literal.extend_string(escaped_char, @ts, @te) end else # It does not. So this is an actual escape sequence, yay! # Two things to consider here. # # 1. The `escape' rule should be pure and so won't raise any # errors by itself. Instead, it stores them in lambdas. # # 2. Non-interpolated literals do not go through the aforementioned # rule. As \\ and \' (and variants) are munged, the full token # should always be written for such literals. @escape.call if @escape.respond_to? :call if literal.regexp? # Ditto. Also, expand escaped newlines. literal.extend_string(tok.gsub("\\\n", ''), @ts, @te) else literal.extend_string(@escape || tok, @ts, @te) end end end end end when 51 then # line 663 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin if literal.nest_and_try_closing tok, @ts, @te @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else literal.extend_string tok, @ts, @te end end end when 52 then # line 671 "lib/parser/lexer.rl" begin begin p = (( @te))-1; end begin if literal.nest_and_try_closing('\\', @ts, @ts + 1) # If the literal is actually closed by the backslash, # rewind the input prior to consuming the escape sequence. p = @escape_s - 1 @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else # Get the first character after the backslash. escaped_char = @source[@escape_s].chr if literal.munge_escape? escaped_char # If this particular literal uses this character as an opening # or closing delimiter, it is an escape sequence for that # particular character. Write it without the backslash. if literal.regexp? # Regular expressions should have every escape sequence in its # raw form. literal.extend_string(tok, @ts, @te) else literal.extend_string(escaped_char, @ts, @te) end else # It does not. So this is an actual escape sequence, yay! # Two things to consider here. # # 1. The `escape' rule should be pure and so won't raise any # errors by itself. Instead, it stores them in lambdas. # # 2. Non-interpolated literals do not go through the aforementioned # rule. As \\ and \' (and variants) are munged, the full token # should always be written for such literals. @escape.call if @escape.respond_to? :call if literal.regexp? # Ditto. Also, expand escaped newlines. literal.extend_string(tok.gsub("\\\n", ''), @ts, @te) else literal.extend_string(@escape || tok, @ts, @te) end end end end end when 53 then # line 663 "lib/parser/lexer.rl" begin begin p = (( @te))-1; end begin if literal.nest_and_try_closing tok, @ts, @te @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else literal.extend_string tok, @ts, @te end end end when 54 then # line 810 "lib/parser/lexer.rl" begin @te = p+1 begin literal.flush_string emit(:tSTRING_DBEG, '#{') literal.saved_herebody_s = @herebody_s @herebody_s = nil literal.start_interp_brace begin @stack[ @top] = @cs @top+= 1 @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 55 then # line 760 "lib/parser/lexer.rl" begin @te = p+1 begin literal.flush_string emit(:tSTRING_DVAR, nil, @ts, @ts + 1) p = @ts begin @stack[ @top] = @cs @top+= 1 @cs = 302 _trigger_goto = true _goto_level = _again break end end end when 56 then # line 719 "lib/parser/lexer.rl" begin @te = p+1 begin is_eof = eof_char? @source[p] if literal.heredoc? # Try ending the heredoc with the complete most recently # scanned line. @herebody_s always refers to the start of such line. if literal.nest_and_try_closing(tok(@herebody_s, @te - 1), @herebody_s, @te - 1) # Adjust @herebody_s to point to the next line. @herebody_s = @te # Continue regular lexing after the heredoc reference (<<END). p = literal.heredoc_e - 1 begin @cs = (pop_literal) _trigger_goto = true _goto_level = _again break end else # Ditto. @herebody_s = @te end end if is_eof diagnostic :fatal, Parser::ERRORS[:string_eof], range(literal.str_s, literal.str_s + 1) end # A literal newline is appended if the heredoc was _not_ closed # this time. See also Literal#nest_and_try_closing for rationale of # calling #flush_string here. literal.extend_string tok, @ts, @te literal.flush_string end end when 57 then # line 663 "lib/parser/lexer.rl" begin @te = p+1 begin if literal.nest_and_try_closing tok, @ts, @te @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else literal.extend_string tok, @ts, @te end end end when 58 then # line 760 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin literal.flush_string emit(:tSTRING_DVAR, nil, @ts, @ts + 1) p = @ts begin @stack[ @top] = @cs @top+= 1 @cs = 302 _trigger_goto = true _goto_level = _again break end end end when 59 then # line 671 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin if literal.nest_and_try_closing('\\', @ts, @ts + 1) # If the literal is actually closed by the backslash, # rewind the input prior to consuming the escape sequence. p = @escape_s - 1 @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else # Get the first character after the backslash. escaped_char = @source[@escape_s].chr if literal.munge_escape? escaped_char # If this particular literal uses this character as an opening # or closing delimiter, it is an escape sequence for that # particular character. Write it without the backslash. if literal.regexp? # Regular expressions should have every escape sequence in its # raw form. literal.extend_string(tok, @ts, @te) else literal.extend_string(escaped_char, @ts, @te) end else # It does not. So this is an actual escape sequence, yay! # Two things to consider here. # # 1. The `escape' rule should be pure and so won't raise any # errors by itself. Instead, it stores them in lambdas. # # 2. Non-interpolated literals do not go through the aforementioned # rule. As \\ and \' (and variants) are munged, the full token # should always be written for such literals. @escape.call if @escape.respond_to? :call if literal.regexp? # Ditto. Also, expand escaped newlines. literal.extend_string(tok.gsub("\\\n", ''), @ts, @te) else literal.extend_string(@escape || tok, @ts, @te) end end end end end when 60 then # line 663 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin if literal.nest_and_try_closing tok, @ts, @te @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else literal.extend_string tok, @ts, @te end end end when 61 then # line 671 "lib/parser/lexer.rl" begin begin p = (( @te))-1; end begin if literal.nest_and_try_closing('\\', @ts, @ts + 1) # If the literal is actually closed by the backslash, # rewind the input prior to consuming the escape sequence. p = @escape_s - 1 @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else # Get the first character after the backslash. escaped_char = @source[@escape_s].chr if literal.munge_escape? escaped_char # If this particular literal uses this character as an opening # or closing delimiter, it is an escape sequence for that # particular character. Write it without the backslash. if literal.regexp? # Regular expressions should have every escape sequence in its # raw form. literal.extend_string(tok, @ts, @te) else literal.extend_string(escaped_char, @ts, @te) end else # It does not. So this is an actual escape sequence, yay! # Two things to consider here. # # 1. The `escape' rule should be pure and so won't raise any # errors by itself. Instead, it stores them in lambdas. # # 2. Non-interpolated literals do not go through the aforementioned # rule. As \\ and \' (and variants) are munged, the full token # should always be written for such literals. @escape.call if @escape.respond_to? :call if literal.regexp? # Ditto. Also, expand escaped newlines. literal.extend_string(tok.gsub("\\\n", ''), @ts, @te) else literal.extend_string(@escape || tok, @ts, @te) end end end end end when 62 then # line 663 "lib/parser/lexer.rl" begin begin p = (( @te))-1; end begin if literal.nest_and_try_closing tok, @ts, @te @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else literal.extend_string tok, @ts, @te end end end when 63 then # line 671 "lib/parser/lexer.rl" begin @te = p+1 begin if literal.nest_and_try_closing('\\', @ts, @ts + 1) # If the literal is actually closed by the backslash, # rewind the input prior to consuming the escape sequence. p = @escape_s - 1 @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else # Get the first character after the backslash. escaped_char = @source[@escape_s].chr if literal.munge_escape? escaped_char # If this particular literal uses this character as an opening # or closing delimiter, it is an escape sequence for that # particular character. Write it without the backslash. if literal.regexp? # Regular expressions should have every escape sequence in its # raw form. literal.extend_string(tok, @ts, @te) else literal.extend_string(escaped_char, @ts, @te) end else # It does not. So this is an actual escape sequence, yay! # Two things to consider here. # # 1. The `escape' rule should be pure and so won't raise any # errors by itself. Instead, it stores them in lambdas. # # 2. Non-interpolated literals do not go through the aforementioned # rule. As \\ and \' (and variants) are munged, the full token # should always be written for such literals. @escape.call if @escape.respond_to? :call if literal.regexp? # Ditto. Also, expand escaped newlines. literal.extend_string(tok.gsub("\\\n", ''), @ts, @te) else literal.extend_string(@escape || tok, @ts, @te) end end end end end when 64 then # line 843 "lib/parser/lexer.rl" begin @te = p+1 begin literal.flush_string end end when 65 then # line 719 "lib/parser/lexer.rl" begin @te = p+1 begin is_eof = eof_char? @source[p] if literal.heredoc? # Try ending the heredoc with the complete most recently # scanned line. @herebody_s always refers to the start of such line. if literal.nest_and_try_closing(tok(@herebody_s, @te - 1), @herebody_s, @te - 1) # Adjust @herebody_s to point to the next line. @herebody_s = @te # Continue regular lexing after the heredoc reference (<<END). p = literal.heredoc_e - 1 begin @cs = (pop_literal) _trigger_goto = true _goto_level = _again break end else # Ditto. @herebody_s = @te end end if is_eof diagnostic :fatal, Parser::ERRORS[:string_eof], range(literal.str_s, literal.str_s + 1) end # A literal newline is appended if the heredoc was _not_ closed # this time. See also Literal#nest_and_try_closing for rationale of # calling #flush_string here. literal.extend_string tok, @ts, @te literal.flush_string end end when 66 then # line 663 "lib/parser/lexer.rl" begin @te = p+1 begin if literal.nest_and_try_closing tok, @ts, @te @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else literal.extend_string tok, @ts, @te end end end when 67 then # line 663 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin if literal.nest_and_try_closing tok, @ts, @te @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else literal.extend_string tok, @ts, @te end end end when 68 then # line 719 "lib/parser/lexer.rl" begin @te = p+1 begin is_eof = eof_char? @source[p] if literal.heredoc? # Try ending the heredoc with the complete most recently # scanned line. @herebody_s always refers to the start of such line. if literal.nest_and_try_closing(tok(@herebody_s, @te - 1), @herebody_s, @te - 1) # Adjust @herebody_s to point to the next line. @herebody_s = @te # Continue regular lexing after the heredoc reference (<<END). p = literal.heredoc_e - 1 begin @cs = (pop_literal) _trigger_goto = true _goto_level = _again break end else # Ditto. @herebody_s = @te end end if is_eof diagnostic :fatal, Parser::ERRORS[:string_eof], range(literal.str_s, literal.str_s + 1) end # A literal newline is appended if the heredoc was _not_ closed # this time. See also Literal#nest_and_try_closing for rationale of # calling #flush_string here. literal.extend_string tok, @ts, @te literal.flush_string end end when 69 then # line 671 "lib/parser/lexer.rl" begin @te = p+1 begin if literal.nest_and_try_closing('\\', @ts, @ts + 1) # If the literal is actually closed by the backslash, # rewind the input prior to consuming the escape sequence. p = @escape_s - 1 @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else # Get the first character after the backslash. escaped_char = @source[@escape_s].chr if literal.munge_escape? escaped_char # If this particular literal uses this character as an opening # or closing delimiter, it is an escape sequence for that # particular character. Write it without the backslash. if literal.regexp? # Regular expressions should have every escape sequence in its # raw form. literal.extend_string(tok, @ts, @te) else literal.extend_string(escaped_char, @ts, @te) end else # It does not. So this is an actual escape sequence, yay! # Two things to consider here. # # 1. The `escape' rule should be pure and so won't raise any # errors by itself. Instead, it stores them in lambdas. # # 2. Non-interpolated literals do not go through the aforementioned # rule. As \\ and \' (and variants) are munged, the full token # should always be written for such literals. @escape.call if @escape.respond_to? :call if literal.regexp? # Ditto. Also, expand escaped newlines. literal.extend_string(tok.gsub("\\\n", ''), @ts, @te) else literal.extend_string(@escape || tok, @ts, @te) end end end end end when 70 then # line 719 "lib/parser/lexer.rl" begin @te = p+1 begin is_eof = eof_char? @source[p] if literal.heredoc? # Try ending the heredoc with the complete most recently # scanned line. @herebody_s always refers to the start of such line. if literal.nest_and_try_closing(tok(@herebody_s, @te - 1), @herebody_s, @te - 1) # Adjust @herebody_s to point to the next line. @herebody_s = @te # Continue regular lexing after the heredoc reference (<<END). p = literal.heredoc_e - 1 begin @cs = (pop_literal) _trigger_goto = true _goto_level = _again break end else # Ditto. @herebody_s = @te end end if is_eof diagnostic :fatal, Parser::ERRORS[:string_eof], range(literal.str_s, literal.str_s + 1) end # A literal newline is appended if the heredoc was _not_ closed # this time. See also Literal#nest_and_try_closing for rationale of # calling #flush_string here. literal.extend_string tok, @ts, @te literal.flush_string end end when 71 then # line 663 "lib/parser/lexer.rl" begin @te = p+1 begin if literal.nest_and_try_closing tok, @ts, @te @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else literal.extend_string tok, @ts, @te end end end when 72 then # line 663 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin if literal.nest_and_try_closing tok, @ts, @te @cs = (pop_literal); begin p += 1 _trigger_goto = true _goto_level = _out break end else literal.extend_string tok, @ts, @te end end end when 73 then # line 869 "lib/parser/lexer.rl" begin @te = p+1 begin emit(:tREGEXP_OPT, tok(@ts, @te - 1), @ts, @te - 1) p = p - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 74 then # line 857 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin = tok.scan(/[^imxouesn]/) if .any? = Parser::ERRORS[:regexp_options] % { :options => .join } diagnostic :error, end emit(:tREGEXP_OPT) @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 75 then # line 932 "lib/parser/lexer.rl" begin @te = p+1 begin if tok =~ /^\$([1-9][0-9]*)$/ emit(:tNTH_REF, tok(@ts + 1).to_i) elsif tok =~ /^\$([&`'+])$/ emit(:tBACK_REF) else emit(:tGVAR) end @cs = (stack_pop); begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 76 then # line 932 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin if tok =~ /^\$([1-9][0-9]*)$/ emit(:tNTH_REF, tok(@ts + 1).to_i) elsif tok =~ /^\$([&`'+])$/ emit(:tBACK_REF) else emit(:tGVAR) end @cs = (stack_pop); begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 77 then # line 945 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin if tok =~ /^@@[0-9]/ = Parser::ERRORS[:cvar_name] % { :name => tok } diagnostic :error, end emit(:tCVAR) @cs = (stack_pop); begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 78 then # line 956 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin if tok =~ /^@[0-9]/ = Parser::ERRORS[:ivar_name] % { :name => tok } diagnostic :error, end emit(:tIVAR) @cs = (stack_pop); begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 79 then # line 978 "lib/parser/lexer.rl" begin @act = 25; end when 80 then # line 982 "lib/parser/lexer.rl" begin @act = 26; end when 81 then # line 986 "lib/parser/lexer.rl" begin @act = 27; end when 82 then # line 992 "lib/parser/lexer.rl" begin @te = p+1 begin emit_table(PUNCTUATION) @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 83 then # line 996 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 84 then # line 999 "lib/parser/lexer.rl" begin @te = p+1 begin p = @ts - 1 begin @stack[ @top] = @cs @top+= 1 @cs = 302 _trigger_goto = true _goto_level = _again break end end end when 85 then # line 1005 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 86 then # line 375 "lib/parser/lexer.rl" begin @te = p+1 begin # Sit at EOF indefinitely. #advance would return $eof each time. # This allows to feed the lexer more data if needed; this is only used # in tests. # # Note that this action is not embedded into e_eof like e_nl and e_bs # below. This is due to the fact that scanner state at EOF is observed # by tests, and encapsulating it in a rule would break the introspection. p = p - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 87 then # line 978 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(KEYWORDS[tok]); @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 88 then # line 982 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tIDENTIFIER) @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 89 then # line 986 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tIDENTIFIER, tok(@ts, tm), @ts, tm) @cs = 679; p = tm - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 90 then # line 992 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit_table(PUNCTUATION) @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 91 then # line 999 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin p = @ts - 1 begin @stack[ @top] = @cs @top+= 1 @cs = 302 _trigger_goto = true _goto_level = _again break end end end when 92 then # line 1002 "lib/parser/lexer.rl" begin @te = p p = p - 1; end when 93 then # line 1005 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin p = p - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 94 then # line 1 "NONE" begin case @act when 25 then begin begin p = (( @te))-1; end emit(KEYWORDS[tok]); @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end end when 26 then begin begin p = (( @te))-1; end emit(:tIDENTIFIER) @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end end when 27 then begin begin p = (( @te))-1; end emit(:tIDENTIFIER, tok(@ts, tm), @ts, tm) @cs = 679; p = tm - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end end when 95 then # line 1030 "lib/parser/lexer.rl" begin @te = p+1 begin emit_table(PUNCTUATION) @cs = 447; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 96 then # line 1035 "lib/parser/lexer.rl" begin @te = p+1 end when 97 then # line 1038 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 98 then # line 375 "lib/parser/lexer.rl" begin @te = p+1 begin # Sit at EOF indefinitely. #advance would return $eof each time. # This allows to feed the lexer more data if needed; this is only used # in tests. # # Note that this action is not embedded into e_eof like e_nl and e_bs # below. This is due to the fact that scanner state at EOF is observed # by tests, and encapsulating it in a rule would break the introspection. p = p - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 99 then # line 1016 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tCONSTANT) @cs = 447; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 100 then # line 1020 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tIDENTIFIER) @cs = 447; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 101 then # line 1024 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tFID, tok(@ts, tm), @ts, tm) @cs = 447; p = tm - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 102 then # line 1030 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit_table(PUNCTUATION) @cs = 447; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 103 then # line 1033 "lib/parser/lexer.rl" begin @te = p p = p - 1; end when 104 then # line 1038 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin p = p - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 105 then # line 1038 "lib/parser/lexer.rl" begin begin p = (( @te))-1; end begin p = p - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 106 then # line 1098 "lib/parser/lexer.rl" begin @act = 47; end when 107 then # line 1103 "lib/parser/lexer.rl" begin @act = 48; end when 108 then # line 1113 "lib/parser/lexer.rl" begin @act = 49; end when 109 then # line 1147 "lib/parser/lexer.rl" begin @act = 53; end when 110 then # line 1098 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 111 then # line 1124 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 112 then # line 1138 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; p = p - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 113 then # line 1147 "lib/parser/lexer.rl" begin @te = p+1 begin p = @ts - 1 begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 114 then # line 1153 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 115 then # line 1156 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 116 then # line 375 "lib/parser/lexer.rl" begin @te = p+1 begin # Sit at EOF indefinitely. #advance would return $eof each time. # This allows to feed the lexer more data if needed; this is only used # in tests. # # Note that this action is not embedded into e_eof like e_nl and e_bs # below. This is due to the fact that scanner state at EOF is observed # by tests, and encapsulating it in a rule would break the introspection. p = p - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 117 then # line 1054 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tLPAREN_ARG, '(', @te - 1, @te) @cs = 479; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 118 then # line 1060 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tLPAREN2) @cs = 479; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 119 then # line 1066 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tLBRACK, '[', @te - 1, @te) @cs = 479; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 120 then # line 1072 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin if @lambda_stack.last == @paren_nest p = @ts - 1 begin @cs = 679 _trigger_goto = true _goto_level = _again break end else emit(:tLCURLY, '{', @te - 1, @te) @cs = 676; begin p += 1 _trigger_goto = true _goto_level = _out break end end end end when 121 then # line 1089 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 122 then # line 1103 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin diagnostic :warning, Parser::ERRORS[:ambiguous_literal], range(@te - 1, @te) p = p - 1; p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 123 then # line 1129 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 124 then # line 1147 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin p = @ts - 1 begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 125 then # line 1156 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 126 then # line 1156 "lib/parser/lexer.rl" begin begin p = (( @te))-1; end begin p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 127 then # line 1 "NONE" begin case @act when 47 then begin begin p = (( @te))-1; end p = p - 1; p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end when 48 then begin begin p = (( @te))-1; end diagnostic :warning, Parser::ERRORS[:ambiguous_literal], range(@te - 1, @te) p = p - 1; p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end when 49 then begin begin p = (( @te))-1; end = Parser::ERRORS[:ambiguous_prefix] % { :prefix => tok(@te - 1, @te) } diagnostic :warning, , range(@te - 1, @te) p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end when 53 then begin begin p = (( @te))-1; end p = @ts - 1 begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end end when 128 then # line 1182 "lib/parser/lexer.rl" begin @te = p+1 begin emit(:kDO_BLOCK) @cs = 676; end end when 129 then # line 1188 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 130 then # line 375 "lib/parser/lexer.rl" begin @te = p+1 begin # Sit at EOF indefinitely. #advance would return $eof each time. # This allows to feed the lexer more data if needed; this is only used # in tests. # # Note that this action is not embedded into e_eof like e_nl and e_bs # below. This is due to the fact that scanner state at EOF is observed # by tests, and encapsulating it in a rule would break the introspection. p = p - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 131 then # line 1178 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tLBRACE_ARG) @cs = 676; end end when 132 then # line 1185 "lib/parser/lexer.rl" begin @te = p p = p - 1; end when 133 then # line 1188 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin p = p - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 134 then # line 1200 "lib/parser/lexer.rl" begin @te = p+1 begin emit_table(KEYWORDS) @cs = 479; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 135 then # line 1208 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 136 then # line 1211 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 137 then # line 375 "lib/parser/lexer.rl" begin @te = p+1 begin # Sit at EOF indefinitely. #advance would return $eof each time. # This allows to feed the lexer more data if needed; this is only used # in tests. # # Note that this action is not embedded into e_eof like e_nl and e_bs # below. This is due to the fact that scanner state at EOF is observed # by tests, and encapsulating it in a rule would break the introspection. p = p - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 138 then # line 1203 "lib/parser/lexer.rl" begin @te = p p = p - 1; end when 139 then # line 1205 "lib/parser/lexer.rl" begin @te = p p = p - 1; end when 140 then # line 1211 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 141 then # line 1211 "lib/parser/lexer.rl" begin begin p = (( @te))-1; end begin p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 142 then # line 1238 "lib/parser/lexer.rl" begin @act = 69; end when 143 then # line 1384 "lib/parser/lexer.rl" begin @act = 83; end when 144 then # line 1390 "lib/parser/lexer.rl" begin @act = 84; end when 145 then # line 1395 "lib/parser/lexer.rl" begin @act = 85; end when 146 then # line 1424 "lib/parser/lexer.rl" begin @act = 87; end when 147 then # line 1430 "lib/parser/lexer.rl" begin @act = 88; end when 148 then # line 1466 "lib/parser/lexer.rl" begin @act = 93; end when 149 then # line 1228 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; if tok.start_with? '-' emit(:tUMINUS_NUM, '-') @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end end end end when 150 then # line 1248 "lib/parser/lexer.rl" begin @te = p+1 begin type = delimiter = tok[0].chr p = p - 1; begin @cs = (push_literal(type, delimiter, @ts)) _trigger_goto = true _goto_level = _again break end end end when 151 then # line 1255 "lib/parser/lexer.rl" begin @te = p+1 begin type, delimiter = tok[0].chr, tok[-1].chr begin @cs = (push_literal(type, delimiter, @ts)) _trigger_goto = true _goto_level = _again break end end end when 152 then # line 1262 "lib/parser/lexer.rl" begin @te = p+1 begin type, delimiter = tok[0..-2], tok[-1].chr begin @cs = (push_literal(type, delimiter, @ts)) _trigger_goto = true _goto_level = _again break end end end when 153 then # line 1268 "lib/parser/lexer.rl" begin @te = p+1 begin diagnostic :fatal, Parser::ERRORS[:string_eof], range(@ts, @ts + 1) end end when 154 then # line 1303 "lib/parser/lexer.rl" begin @te = p+1 begin type, delimiter = tok, tok[-1].chr begin @cs = (push_literal(type, delimiter, @ts)) _trigger_goto = true _goto_level = _again break end end end when 155 then # line 1317 "lib/parser/lexer.rl" begin @te = p+1 begin emit(:tSYMBOL, tok(@ts + 1), @ts) @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 156 then # line 1329 "lib/parser/lexer.rl" begin @te = p+1 begin # Show an error if memorized. @escape.call if @escape.respond_to? :call value = @escape || tok(@ts + 1) if version?(18) emit(:tINTEGER, value[0].ord) else emit(:tSTRING, value) end @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 157 then # line 1345 "lib/parser/lexer.rl" begin @te = p+1 begin escape = { " " => '\s', "\r" => '\r', "\n" => '\n', "\t" => '\t', "\v" => '\v', "\f" => '\f' }[tok[@ts + 1]] = Parser::ERRORS[:invalid_escape_use] % { :escape => escape } diagnostic :warning, , range(@ts, @ts + 1) p = @ts - 1 begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 158 then # line 1357 "lib/parser/lexer.rl" begin @te = p+1 begin diagnostic :fatal, Parser::ERRORS[:incomplete_escape], range(@ts, @ts + 1) end end when 159 then # line 1384 "lib/parser/lexer.rl" begin @te = p+1 begin emit_table(PUNCTUATION_BEGIN) begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 160 then # line 1403 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; if version?(18) emit(:tIDENTIFIER, tok(@ts, @te - 2), @ts, @te - 2) p = p - 1; # continue as a symbol else emit(:tLABEL, tok(@ts, @te - 2), @ts, @te - 1) end begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 161 then # line 1444 "lib/parser/lexer.rl" begin @te = p+1 end when 162 then # line 1446 "lib/parser/lexer.rl" begin @te = p+1 end when 163 then # line 1449 "lib/parser/lexer.rl" begin @te = p+1 begin @comments << tok p = p - 1; end end when 164 then # line 1453 "lib/parser/lexer.rl" begin @te = p+1 begin p = @ts - 1 begin @cs = 177 _trigger_goto = true _goto_level = _again break end end end when 165 then # line 1466 "lib/parser/lexer.rl" begin @te = p+1 begin p = @ts - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 166 then # line 375 "lib/parser/lexer.rl" begin @te = p+1 begin # Sit at EOF indefinitely. #advance would return $eof each time. # This allows to feed the lexer more data if needed; this is only used # in tests. # # Note that this action is not embedded into e_eof like e_nl and e_bs # below. This is due to the fact that scanner state at EOF is observed # by tests, and encapsulating it in a rule would break the introspection. p = p - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 167 then # line 1238 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tSTAR) begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 168 then # line 1262 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin type, delimiter = tok[0..-2], tok[-1].chr begin @cs = (push_literal(type, delimiter, @ts)) _trigger_goto = true _goto_level = _again break end end end when 169 then # line 1281 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin tok(@ts, @heredoc_e) =~ /^<<(-?)(["'`]?)(.*)\2$/ indent = !$1.empty? type = $2.empty? ? '"' : $2 delimiter = $3 @cs = (push_literal(type, delimiter, @ts, @heredoc_e, indent)); if @herebody_s.nil? @herebody_s = new_herebody_s end p = @herebody_s - 1 end end when 170 then # line 1309 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tSYMBOL, tok(@ts + 1, tm), @ts, tm) p = tm - 1 @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 171 then # line 1317 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tSYMBOL, tok(@ts + 1), @ts) @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 172 then # line 1329 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin # Show an error if memorized. @escape.call if @escape.respond_to? :call value = @escape || tok(@ts + 1) if version?(18) emit(:tINTEGER, value[0].ord) else emit(:tSTRING, value) end @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 173 then # line 1364 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin p = @ts - 1 begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 174 then # line 1379 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit_table(PUNCTUATION_BEGIN) begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 175 then # line 1384 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit_table(PUNCTUATION_BEGIN) begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 176 then # line 1424 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin p = @ts - 1 begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 177 then # line 1430 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tIDENTIFIER) if @static_env && @static_env.declared?(tok) @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end else @cs = 447; begin p += 1 _trigger_goto = true _goto_level = _out break end end end end when 178 then # line 1444 "lib/parser/lexer.rl" begin @te = p p = p - 1; end when 179 then # line 1466 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin p = @ts - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 180 then # line 1329 "lib/parser/lexer.rl" begin begin p = (( @te))-1; end begin # Show an error if memorized. @escape.call if @escape.respond_to? :call value = @escape || tok(@ts + 1) if version?(18) emit(:tINTEGER, value[0].ord) else emit(:tSTRING, value) end @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 181 then # line 1444 "lib/parser/lexer.rl" begin begin p = (( @te))-1; end end when 182 then # line 1466 "lib/parser/lexer.rl" begin begin p = (( @te))-1; end begin p = @ts - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 183 then # line 1 "NONE" begin case @act when 69 then begin begin p = (( @te))-1; end emit(:tSTAR) begin p += 1 _trigger_goto = true _goto_level = _out break end end when 83 then begin begin p = (( @te))-1; end emit_table(PUNCTUATION_BEGIN) begin p += 1 _trigger_goto = true _goto_level = _out break end end when 84 then begin begin p = (( @te))-1; end emit_table(KEYWORDS_BEGIN) @cs = 472; begin p += 1 _trigger_goto = true _goto_level = _out break end end when 85 then begin begin p = (( @te))-1; end emit_table(KEYWORDS_BEGIN) @cs = 676; begin p += 1 _trigger_goto = true _goto_level = _out break end end when 87 then begin begin p = (( @te))-1; end p = @ts - 1 begin @cs = 679 _trigger_goto = true _goto_level = _again break end end when 88 then begin begin p = (( @te))-1; end emit(:tIDENTIFIER) if @static_env && @static_env.declared?(tok) @cs = 679; begin p += 1 _trigger_goto = true _goto_level = _out break end else @cs = 447; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 93 then begin begin p = (( @te))-1; end p = @ts - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end end when 184 then # line 1476 "lib/parser/lexer.rl" begin @te = p+1 begin p = @ts - 1 begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 185 then # line 1482 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 186 then # line 375 "lib/parser/lexer.rl" begin @te = p+1 begin # Sit at EOF indefinitely. #advance would return $eof each time. # This allows to feed the lexer more data if needed; this is only used # in tests. # # Note that this action is not embedded into e_eof like e_nl and e_bs # below. This is due to the fact that scanner state at EOF is observed # by tests, and encapsulating it in a rule would break the introspection. p = p - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 187 then # line 1479 "lib/parser/lexer.rl" begin @te = p p = p - 1; end when 188 then # line 1482 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 189 then # line 1482 "lib/parser/lexer.rl" begin begin p = (( @te))-1; end begin p = p - 1; begin @cs = 479 _trigger_goto = true _goto_level = _again break end end end when 190 then # line 1501 "lib/parser/lexer.rl" begin @act = 100; end when 191 then # line 1532 "lib/parser/lexer.rl" begin @act = 101; end when 192 then # line 1542 "lib/parser/lexer.rl" begin @act = 103; end when 193 then # line 1547 "lib/parser/lexer.rl" begin @act = 104; end when 194 then # line 1551 "lib/parser/lexer.rl" begin @act = 105; end when 195 then # line 1555 "lib/parser/lexer.rl" begin @act = 106; end when 196 then # line 1566 "lib/parser/lexer.rl" begin @act = 107; end when 197 then # line 1576 "lib/parser/lexer.rl" begin @act = 108; end when 198 then # line 1597 "lib/parser/lexer.rl" begin @act = 109; end when 199 then # line 1627 "lib/parser/lexer.rl" begin @act = 110; end when 200 then # line 1657 "lib/parser/lexer.rl" begin @act = 112; end when 201 then # line 1676 "lib/parser/lexer.rl" begin @act = 116; end when 202 then # line 1680 "lib/parser/lexer.rl" begin @act = 117; end when 203 then # line 1493 "lib/parser/lexer.rl" begin @te = p+1 begin emit_table(PUNCTUATION) @lambda_stack.push @paren_nest begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 204 then # line 1536 "lib/parser/lexer.rl" begin @te = p+1 begin emit(:kCLASS, 'class', @ts, @ts + 5) emit(:tLSHFT, '<<', @te - 2, @te) @cs = 479; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 205 then # line 1597 "lib/parser/lexer.rl" begin @te = p+1 begin digits = tok(@num_digits_s) if digits.end_with? '_' diagnostic :error, Parser::ERRORS[:trailing_underscore], range(@te - 1, @te) elsif digits.empty? && @num_base == 8 && version?(18) # 1.8 did not raise an error on 0o. digits = "0" elsif digits.empty? diagnostic :error, Parser::ERRORS[:empty_numeric] elsif @num_base == 8 && (invalid_idx = digits.index(/[89]/)) invalid_s = @num_digits_s + invalid_idx diagnostic :error, Parser::ERRORS[:invalid_octal], range(invalid_s, invalid_s + 1) end emit(:tINTEGER, digits.to_i(@num_base)) begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 206 then # line 1647 "lib/parser/lexer.rl" begin @te = p+1 begin type, delimiter = tok, tok[-1].chr begin @cs = (push_literal(type, delimiter, @ts)) _trigger_goto = true _goto_level = _again break end end end when 207 then # line 1665 "lib/parser/lexer.rl" begin @te = p+1 begin p = @ts - 1; begin @stack[ @top] = @cs @top+= 1 @cs = 302 _trigger_goto = true _goto_level = _again break end end end when 208 then # line 1672 "lib/parser/lexer.rl" begin @te = p+1 begin emit_table(PUNCTUATION) @cs = 423; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 209 then # line 1696 "lib/parser/lexer.rl" begin @te = p+1 begin emit_table(PUNCTUATION) @cond.lexpop; @cmdarg.lexpop begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 210 then # line 1701 "lib/parser/lexer.rl" begin @te = p+1 begin emit(:tOP_ASGN, tok(@ts, @te - 1)) @cs = 479; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 211 then # line 1705 "lib/parser/lexer.rl" begin @te = p+1 begin emit_table(PUNCTUATION) @cs = 676; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 212 then # line 1713 "lib/parser/lexer.rl" begin @te = p+1 begin emit_table(PUNCTUATION) @cs = 479; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 213 then # line 1720 "lib/parser/lexer.rl" begin @te = p+1 end when 214 then # line 1722 "lib/parser/lexer.rl" begin @te = p+1 begin diagnostic :error, Parser::ERRORS[:bare_backslash], range(@ts, @ts + 1) p = p - 1; end end when 215 then # line 1734 "lib/parser/lexer.rl" begin @te = p+1 begin begin @cs = 846 _trigger_goto = true _goto_level = _again break end end end when 216 then # line 1737 "lib/parser/lexer.rl" begin @te = p+1 begin emit_table(PUNCTUATION) @cs = 676; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 217 then # line 1741 "lib/parser/lexer.rl" begin @te = p+1 begin = Parser::ERRORS[:unexpected] % { :character => tok.inspect } diagnostic :fatal, end end when 218 then # line 375 "lib/parser/lexer.rl" begin @te = p+1 begin # Sit at EOF indefinitely. #advance would return $eof each time. # This allows to feed the lexer more data if needed; this is only used # in tests. # # Note that this action is not embedded into e_eof like e_nl and e_bs # below. This is due to the fact that scanner state at EOF is observed # by tests, and encapsulating it in a rule would break the introspection. p = p - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 219 then # line 1501 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin if @lambda_stack.last == @paren_nest @lambda_stack.pop if tok == '{' emit(:tLAMBEG) else # 'do' emit(:kDO_LAMBDA) end else if tok == '{' emit_table(PUNCTUATION) else # 'do' if @cond.active? emit(:kDO_COND) elsif @cmdarg.active? emit(:kDO_BLOCK) else emit(:kDO) end end end @cs = 676; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 220 then # line 1532 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit_table(KEYWORDS) @cs = 308; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 221 then # line 1547 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit_table(KEYWORDS) @cs = 676; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 222 then # line 1597 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin digits = tok(@num_digits_s) if digits.end_with? '_' diagnostic :error, Parser::ERRORS[:trailing_underscore], range(@te - 1, @te) elsif digits.empty? && @num_base == 8 && version?(18) # 1.8 did not raise an error on 0o. digits = "0" elsif digits.empty? diagnostic :error, Parser::ERRORS[:empty_numeric] elsif @num_base == 8 && (invalid_idx = digits.index(/[89]/)) invalid_s = @num_digits_s + invalid_idx diagnostic :error, Parser::ERRORS[:invalid_octal], range(invalid_s, invalid_s + 1) end emit(:tINTEGER, digits.to_i(@num_base)) begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 223 then # line 1627 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin if tok.start_with? '.' diagnostic :error, Parser::ERRORS[:no_dot_digit_literal] elsif tok =~ /^[eE]/ # The rule above allows to specify floats as just `e10', which is # certainly not a float. Send a patch if you can do this better. emit(:tIDENTIFIER, tok) begin p += 1 _trigger_goto = true _goto_level = _out break end end emit(:tFLOAT, tok.to_f) begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 224 then # line 1657 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tCONSTANT) begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 225 then # line 1661 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tCONSTANT, tok(@ts, tm), @ts, tm) p = tm - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 226 then # line 1665 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin p = @ts - 1; begin @stack[ @top] = @cs @top+= 1 @cs = 302 _trigger_goto = true _goto_level = _again break end end end when 227 then # line 1672 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit_table(PUNCTUATION) @cs = 423; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 228 then # line 1676 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tIDENTIFIER) @cs = 447; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 229 then # line 1680 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tFID, tok(@ts, tm), @ts, tm) p = tm - 1 @cs = 447; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 230 then # line 1692 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit_table(PUNCTUATION, @ts, tm) @cs = 479; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 231 then # line 1696 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit_table(PUNCTUATION) @cond.lexpop; @cmdarg.lexpop begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 232 then # line 1709 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit_table(PUNCTUATION) @cs = 479; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 233 then # line 1713 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit_table(PUNCTUATION) @cs = 479; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 234 then # line 1728 "lib/parser/lexer.rl" begin @te = p p = p - 1; end when 235 then # line 1731 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin @comments << tok(@ts, @te + 1) end end when 236 then # line 1741 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin = Parser::ERRORS[:unexpected] % { :character => tok.inspect } diagnostic :fatal, end end when 237 then # line 1547 "lib/parser/lexer.rl" begin begin p = (( @te))-1; end begin emit_table(KEYWORDS) @cs = 676; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 238 then # line 1741 "lib/parser/lexer.rl" begin begin p = (( @te))-1; end begin = Parser::ERRORS[:unexpected] % { :character => tok.inspect } diagnostic :fatal, end end when 239 then # line 1 "NONE" begin case @act when 100 then begin begin p = (( @te))-1; end if @lambda_stack.last == @paren_nest @lambda_stack.pop if tok == '{' emit(:tLAMBEG) else # 'do' emit(:kDO_LAMBDA) end else if tok == '{' emit_table(PUNCTUATION) else # 'do' if @cond.active? emit(:kDO_COND) elsif @cmdarg.active? emit(:kDO_BLOCK) else emit(:kDO) end end end @cs = 676; begin p += 1 _trigger_goto = true _goto_level = _out break end end when 101 then begin begin p = (( @te))-1; end emit_table(KEYWORDS) @cs = 308; begin p += 1 _trigger_goto = true _goto_level = _out break end end when 103 then begin begin p = (( @te))-1; end emit_table(KEYWORDS) @cs = 479; begin p += 1 _trigger_goto = true _goto_level = _out break end end when 104 then begin begin p = (( @te))-1; end emit_table(KEYWORDS) @cs = 676; begin p += 1 _trigger_goto = true _goto_level = _out break end end when 105 then begin begin p = (( @te))-1; end emit_table(KEYWORDS) @cs = 472; begin p += 1 _trigger_goto = true _goto_level = _out break end end when 106 then begin begin p = (( @te))-1; end emit_table(KEYWORDS) if version?(18) && tok == 'not' @cs = 479; begin p += 1 _trigger_goto = true _goto_level = _out break end else @cs = 447; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 107 then begin begin p = (( @te))-1; end if version?(18) emit(:tIDENTIFIER) else emit_table(KEYWORDS) end begin p += 1 _trigger_goto = true _goto_level = _out break end end when 108 then begin begin p = (( @te))-1; end emit_table(KEYWORDS) begin p += 1 _trigger_goto = true _goto_level = _out break end end when 109 then begin begin p = (( @te))-1; end digits = tok(@num_digits_s) if digits.end_with? '_' diagnostic :error, Parser::ERRORS[:trailing_underscore], range(@te - 1, @te) elsif digits.empty? && @num_base == 8 && version?(18) # 1.8 did not raise an error on 0o. digits = "0" elsif digits.empty? diagnostic :error, Parser::ERRORS[:empty_numeric] elsif @num_base == 8 && (invalid_idx = digits.index(/[89]/)) invalid_s = @num_digits_s + invalid_idx diagnostic :error, Parser::ERRORS[:invalid_octal], range(invalid_s, invalid_s + 1) end emit(:tINTEGER, digits.to_i(@num_base)) begin p += 1 _trigger_goto = true _goto_level = _out break end end when 110 then begin begin p = (( @te))-1; end if tok.start_with? '.' diagnostic :error, Parser::ERRORS[:no_dot_digit_literal] elsif tok =~ /^[eE]/ # The rule above allows to specify floats as just `e10', which is # certainly not a float. Send a patch if you can do this better. emit(:tIDENTIFIER, tok) begin p += 1 _trigger_goto = true _goto_level = _out break end end emit(:tFLOAT, tok.to_f) begin p += 1 _trigger_goto = true _goto_level = _out break end end when 112 then begin begin p = (( @te))-1; end emit(:tCONSTANT) begin p += 1 _trigger_goto = true _goto_level = _out break end end when 116 then begin begin p = (( @te))-1; end emit(:tIDENTIFIER) @cs = 447; begin p += 1 _trigger_goto = true _goto_level = _out break end end when 117 then begin begin p = (( @te))-1; end emit(:tFID, tok(@ts, tm), @ts, tm) p = tm - 1 @cs = 447; begin p += 1 _trigger_goto = true _goto_level = _out break end end end end when 240 then # line 1754 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; p = p - 1; begin @cs = 679 _trigger_goto = true _goto_level = _again break end end end when 241 then # line 1758 "lib/parser/lexer.rl" begin @te = p+1 begin emit(:tNL, nil, @newline_s, @newline_s + 1) @cs = 177; p = p - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 242 then # line 1758 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin emit(:tNL, nil, @newline_s, @newline_s + 1) @cs = 177; p = p - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 243 then # line 1758 "lib/parser/lexer.rl" begin begin p = (( @te))-1; end begin emit(:tNL, nil, @newline_s, @newline_s + 1) @cs = 177; p = p - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 244 then # line 1768 "lib/parser/lexer.rl" begin @te = p+1 begin @comments << tok begin @cs = 177 _trigger_goto = true _goto_level = _again break end end end when 245 then # line 1772 "lib/parser/lexer.rl" begin @te = p+1 begin @comments << tok end end when 246 then # line 1775 "lib/parser/lexer.rl" begin @te = p+1 begin # TODO better location information here diagnostic :fatal, Parser::ERRORS[:embedded_document], range(p - 1, p) end end when 247 then # line 1785 "lib/parser/lexer.rl" begin @te = p+1 begin @comments << tok p = p - 1; end end when 248 then # line 1789 "lib/parser/lexer.rl" begin @te = p+1 begin @comments << tok(@ts, @te) begin @cs = 849 _trigger_goto = true _goto_level = _again break end end end when 249 then # line 1793 "lib/parser/lexer.rl" begin @te = p+1 begin p = pe - 1 end end when 250 then # line 1796 "lib/parser/lexer.rl" begin @te = p+1 begin p = p - 1; begin @cs = 676 _trigger_goto = true _goto_level = _again break end end end when 251 then # line 375 "lib/parser/lexer.rl" begin @te = p+1 begin # Sit at EOF indefinitely. #advance would return $eof each time. # This allows to feed the lexer more data if needed; this is only used # in tests. # # Note that this action is not embedded into e_eof like e_nl and e_bs # below. This is due to the fact that scanner state at EOF is observed # by tests, and encapsulating it in a rule would break the introspection. p = p - 1; begin p += 1 _trigger_goto = true _goto_level = _out break end end end when 252 then # line 1782 "lib/parser/lexer.rl" begin @te = p p = p - 1; end when 253 then # line 1796 "lib/parser/lexer.rl" begin @te = p p = p - 1; begin p = p - 1; begin @cs = 676 _trigger_goto = true _goto_level = _again break end end end when 254 then # line 1796 "lib/parser/lexer.rl" begin begin p = (( @te))-1; end begin p = p - 1; begin @cs = 676 _trigger_goto = true _goto_level = _again break end end end # line 6846 "lib/parser/lexer.rb" end # action switch end end if _trigger_goto next end end if _goto_level <= _again _acts = _lex_to_state_actions[ @cs] _nacts = _lex_actions[_acts] _acts += 1 while _nacts > 0 _nacts -= 1 _acts += 1 case _lex_actions[_acts - 1] when 41 then # line 1 "NONE" begin @ts = nil; end # line 6866 "lib/parser/lexer.rb" end # to state action switch end if _trigger_goto next end if @cs == 0 _goto_level = _out next end p += 1 if p != pe _goto_level = _resume next end end if _goto_level <= _test_eof if p == eof if _lex_eof_trans[ @cs] > 0 _trans = _lex_eof_trans[ @cs] - 1; _goto_level = _eof_trans next; end end end if _goto_level <= _out break end end end # line 201 "lib/parser/lexer.rl" # % @p = p if @token_queue.any? @token_queue.shift elsif @cs == self.class.lex_error [ false, [ '$error', range(p - 1, p) ] ] else [ false, [ '$eof', range(p - 1, p) ] ] end end |
#clear_comments ⇒ Object
Return the current collected comment block and clear the storage.
6911 6912 6913 6914 6915 6916 |
# File 'lib/parser/lexer.rb', line 6911 def clear_comments comments = @comments @comments = "" comments end |
#reset(reset_state = true) ⇒ Object
2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 |
# File 'lib/parser/lexer.rb', line 2936 def reset(reset_state=true) # Ragel-related variables: if reset_state # Unit tests set state prior to resetting lexer. @cs = self.class.lex_en_line_begin @cond = StackState.new('cond') @cmdarg = StackState.new('cmdarg') end @p = 0 # stream position (saved manually in #advance) @ts = nil # token start @te = nil # token end @act = 0 # next action @stack = [] # state stack @top = 0 # state stack top pointer # Lexer state: @token_queue = [] @literal_stack = [] @comments = "" # collected comments @newline_s = nil # location of last encountered newline @num_base = nil # last numeric base @num_digits_s = nil # starting position of numeric digits @escape_s = nil # starting position of current sequence @escape = nil # last escaped sequence, as string # See below the section on parsing heredocs. @heredoc_e = nil @herebody_s = nil # Ruby 1.9 ->() lambdas emit a distinct token if do/{ is # encountered after a matching closing parenthesis. @paren_nest = 0 @lambda_stack = [] end |
#state ⇒ Object
3007 3008 3009 |
# File 'lib/parser/lexer.rb', line 3007 def state LEX_STATES.invert.fetch(@cs, @cs) end |
#state=(state) ⇒ Object
3011 3012 3013 |
# File 'lib/parser/lexer.rb', line 3011 def state=(state) @cs = LEX_STATES.fetch(state) end |