Sha256: 805c1f37fd643b0d0cb286da153728bd699cc05786cef99cb14e06c12bf501e2

Contents?: true

Size: 1.28 KB

Versions: 13

Compression:

Stored size: 1.28 KB

Contents

# Rules

This document contains information related to the rules of the parser for Ruby source code.

As an example, in the documentation of many of the fields of nodes, it's mentioned that a field follows the lexing rules for `identifier` or `constant`. This document describes what those rules are.

## Constants

Constants in Ruby begin with an upper-case letter. This is followed by any number of underscores, alphanumeric, or non-ASCII characters. The definition of "alphanumeric" and "upper-case letter" are encoding-dependent.

## Non-void expression

Most expressions in CRuby are non-void. This means the expression they represent resolves to a value. For example, `1 + 2` is a non-void expression, because it resolves to a method call. Even things like `class Foo; end` is a non-void expression, because it returns the last evaluated expression in the body of the class (or `nil`).

Certain nodes, however, are void expressions, and cannot be combined to form larger expressions. For example, `BEGIN {}`, `END {}`, `alias foo bar`, and `undef foo`.

## Identifiers

Identifiers in Ruby begin with an underscore or lower-case letter. This is followed by any number of underscores, alphanumeric, or non-ASCII characters. The definition of "alphanumeric" and "lower-case letter" are encoding-dependent.

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
prism-1.0.0 docs/parsing_rules.md
prism-0.30.0 docs/parsing_rules.md
prism-0.28.0 docs/parsing_rules.md
prism-0.27.0 docs/parsing_rules.md
prism-0.26.0 docs/parsing_rules.md
prism-0.25.0 docs/parsing_rules.md
jruby-prism-parser-0.24.0-java docs/parsing_rules.md
jruby-prism-parser-0.23.0.pre.SNAPSHOT-java docs/parsing_rules.md
prism-0.24.0 docs/parsing_rules.md
prism-0.23.0 docs/parsing_rules.md
prism-0.22.0 docs/parsing_rules.md
prism-0.21.0 docs/parsing_rules.md
prism-0.20.0 docs/parsing_rules.md