Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 769 Bytes

parser.md

File metadata and controls

27 lines (19 loc) · 769 Bytes

Parser

Directory: lib/shiika_parser/

Overview

  • Hand-written parser (i.e. no parser generator)
  • Stateful lexer (to allow omission of method call parentheses)

Lexer

File: lexer.rs

Lexer has a state (LexerState). Main purpose of this is to decide operators like - or + is whether unary or binary.

/// - `p(-x)`  # unary minus             ExprBegin
/// - `p(- x)` # unary minus             ExprBegin   
/// - `p( - x)`# unary minus             ExprBegin   
/// - `p- x`   # binary minus (unusual)  ExprEnd
/// - `p-x`    # binary minus            ExprEnd
/// - `p - x`  # binary minus            ExprArg
/// - `p -x`   # unary minus             ExprArg
/// - `1 -2`   # binary minus (unusual)  ExprArg  

This state is set by the parser.