Project

General

Profile

Actions

Misc #20035

closed

Command-line settings move from parser to compiler

Added by kddnewton (Kevin Newton) 6 months ago. Updated 3 months ago.

Status:
Closed
Assignee:
-
[ruby-core:115569]

Description

Right now, when you pass -n, -p, -l, or -a, these options are all passed to the parser to manipulate the parse tree into giving you the desired behavior. For example:

$ ruby --dump=parsetree -p -e "foo"

###########################################################
## Do NOT use this node dump for any purpose other than  ##
## debug and research.  Compatibility is not guaranteed. ##
###########################################################

# @ NODE_SCOPE (id: 1, line: 1, location: (1,0)-(1,3))
# +- nd_tbl: (empty)
# +- nd_args:
# |   (null node)
# +- nd_body:
#     @ NODE_WHILE (id: 10, line: 1, location: (1,0)-(1,0))
#     +- nd_state: 1 (while-end)
#     +- nd_cond:
#     |   @ NODE_FCALL (id: 9, line: 1, location: (1,0)-(1,0))
#     |   +- nd_mid: :gets
#     |   +- nd_args:
#     |       @ NODE_LIST (id: 8, line: 1, location: (1,0)-(1,0))
#     |       +- nd_alen: 1
#     |       +- nd_head:
#     |       |   @ NODE_GVAR (id: 7, line: 1, location: (1,0)-(1,0))
#     |       |   +- nd_entry: :$/
#     |       +- nd_next:
#     |           (null node)
#     +- nd_body:
#         @ NODE_BLOCK (id: 5, line: 1, location: (1,0)-(1,0))
#         +- nd_head (1):
#         |   @ NODE_VCALL (id: 0, line: 1, location: (1,0)-(1,3))*
#         |   +- nd_mid: :foo
#         +- nd_head (2):
#             @ NODE_FCALL (id: 4, line: 1, location: (1,0)-(1,0))
#             +- nd_mid: :print
#             +- nd_args:
#                 @ NODE_LIST (id: 3, line: 1, location: (1,0)-(1,0))
#                 +- nd_alen: 1
#                 +- nd_head:
#                 |   @ NODE_GVAR (id: 2, line: 1, location: (1,0)-(1,0))
#                 |   +- nd_entry: :$_
#                 +- nd_next:
#                     (null node)

Could this mutation be moved into the compiler? That way it could be shared by prism, but also because it would make it less confusing when people are running --dump=parsetree as to why a loop is being inserted.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0