Ruby 4.0

出典: parse.y @ v4.0.0 (553f167) / lrama 0.8.0 / 2025-12-25

この図はパーサ向けの文法を表しています。言語仕様そのものではなく、字句解析器の状態や意味検査による制約は図に表れません。

Ruby 3.4以降の既定パーサはPrismです。この図はparse.y(--parser=parse.y)の文法であり、Prismと受理する構文が異なる場合があります。

BSD-2-Clause

読みやすい表示 原文どおり

$accept

$@1

option_terms

compstmt_top_stmts

program

top_stmts

top_stmt

block_open

begin_block

compstmt_stmts

$@2

$@3

bodystmt

$@4

stmts

stmt_or_begin

$@5

allow_exits

k_END

$@6

stmt

asgn_mrhs

asgn_command_rhs

command_asgn

op_asgn_command_rhs

def_endless_method_endless_command

endless_command

option_'\n'

command_rhs

expr

$@7

$@8

def_name

defn_head

$@9

defs_head

value_expr_expr

expr_value

$@10

$@11

expr_value_do

command_call

value_expr_command_call

command_call_value

block_command

cmd_brace_block

fcall

command

mlhs

mlhs_inner

mlhs_basic

mlhs_items_mlhs_item

mlhs_item

mlhs_head

mlhs_node

lhs

cname

cpath

fname

fitem

undef_list

$@12

op

reswords

asgn_arg_rhs

arg

op_asgn_arg_rhs

range_expr_arg

def_endless_method_endless_arg

ternary

endless_arg

relop

rel_expr

lex_ctxt

begin_defined

after_rescue

value_expr_arg

arg_value

aref_args

arg_rhs

paren_args

opt_paren_args

opt_call_args

value_expr_command

call_args

$@13

command_args

block_arg

opt_block_arg

args

arg_splat

mrhs_arg

mrhs

primary

$@14

$@15

@16

@17

$@18

$@19

$@20

$@21

$@22

$@23

$@24

value_expr_primary

primary_value

k_begin

k_if

k_unless

k_while

k_until

k_case

k_for

k_class

k_module

k_def

k_do

k_do_block

k_rescue

k_ensure

k_when

k_else

k_elsif

k_end

k_return

k_yield

then

do

if_tail

opt_else

for_var

f_marg

mlhs_items_f_marg

f_margs

f_rest_marg

f_any_kwrest

$@25

f_eq

f_kw_primary_value

f_kwarg_primary_value

args_tail_basic_primary_value

block_args_tail

excessed_comma

f_opt_primary_value

f_opt_arg_primary_value

opt_args_tail_block_args_tail

block_param

opt_block_param_def

block_param_def

opt_block_param

opt_bv_decl

bv_decls

bvar

max_numparam

numparam

it_id

@26

$@27

lambda

f_larglist

lambda_body

$@28

do_block

block_call

method_call

brace_block

@29

brace_body

@30

do_body

case_args

case_body

cases

p_pvtbl

p_pktbl

p_in_kwarg

$@31

p_case_body

p_cases

p_top_expr

p_top_expr_body

p_expr

p_as

$@32

p_alt

p_lparen

p_lbracket

p_expr_basic

$@33

p_args

p_args_head

p_args_tail

p_find

p_rest

p_args_post

p_arg

p_kwargs

p_kwarg

p_kw

p_kw_label

p_kwrest

p_kwnorest

p_any_kwrest

p_value

range_expr_p_primitive

p_primitive

p_variable

p_var_ref

p_expr_ref

p_const

opt_rescue

exc_list

exc_var

opt_ensure

literal

strings

string

string1

xstring

regexp

nonempty_list_' '

words_tWORDS_BEG_word_list

words

word_list

word

words_tSYMBOLS_BEG_symbol_list

symbols

symbol_list

words_tQWORDS_BEG_qword_list

qwords

words_tQSYMBOLS_BEG_qsym_list

qsymbols

qword_list

qsym_list

string_contents

xstring_contents

regexp_contents

string_content

@34

@35

@36

@37

string_dend

string_dvar

symbol

ssym

sym

dsym

numeric

simple_numeric

nonlocal_var

user_variable

keyword_variable

var_ref

var_lhs

backref

$@38

superclass

f_opt_paren_args

f_paren_args

f_arglist

@39

f_kw_arg_value

f_kwarg_arg_value

args_tail_basic_arg_value

args_tail

f_opt_arg_value

f_opt_arg_arg_value

opt_args_tail_args_tail

f_args

args_forward

f_bad_arg

f_norm_arg

f_arg_asgn

f_arg_item

f_arg

f_label

kwrest_mark

f_no_kwarg

f_kwrest

restarg_mark

f_rest_arg

blkarg_mark

f_block_arg

opt_f_block_arg

value_expr_singleton_expr

singleton

singleton_expr

$@40

assoc_list

assocs

assoc

operation2

operation3

dot_or_colon

call_op

call_op2

rparen

rbracket

rbrace

trailer

term

terms

none

キーボード操作

/で検索、jとkで前後の規則へ移動、?でこのヘルプを表示します。Escapeで閉じます。