Module: Pione::Lang::CommonParser

Includes:
Parslet
Included in:
DocumentParser, PNML::Parser
Defined in:
lib/pione/lang/common-parser.rb

Overview

CommonParser provides a set of symbols, keywords, and utility parsers.

Constant Summary collapse

SYMBOLS =

symbols

{
  :squote => '\'',
  :dquote => '"',
  :backslash => "\\",
  :dot => '.',
  :comma => ',',
  :lparen => '(',
  :rparen =>')',
  :lbrace => '{',
  :rbrace => '}',
  :slash => '/',
  :plus => '+',
  :minus => '-',
  :question => '?',
  :vbar => '|',
  :ampersand => '&',
  :doller => '$',
  :colon => ':',
  :equals => '=',
  :exclamation => '!',
  :less_than => '<',
  :greater_than => '>',
  :asterisk => '*',
  :percent => '%',
  :atmark => '@',
  :hat => '^',
  :sharp => '#',
  :lsbracket => '[',
  :rsbracket => ']'
}
KEYWORDS =

keywords

{
  :keyword_Rule => 'Rule',
  :keyword_Flow => 'Flow',
  :keyword_Action => 'Action',
  :keyword_End => 'End',
  :keyword_input => 'input',
  :keyword_output => 'output',
  :keyword_param => 'param',
  :keyword_Param => 'Param',
  :keyword_basic => 'basic',
  :keyword_Basic => 'Basic',
  :keyword_advanced => 'advanced',
  :keyword_Advanced =>  'Advanced',
  :keyword_feature => 'feature',
  :keyword_rule => 'rule',
  :keyword_if => 'if',
  :keyword_else => 'else',
  :keyword_case => 'case',
  :keyword_when => 'when',
  :keyword_end => 'end',
  :keyword_package => 'package',
  :keyword_true => 'true',
  :keyword_false => 'false',
  :keyword_and => 'and',
  :keyword_or => 'or',
  :keyword_null => 'null',
  :keyword_constraint => 'constraint',
  :keyword_bind => 'bind'
}

Instance Method Summary collapse

Instance Method Details

#_line(content) ⇒ Object



201
202
203
# File 'lib/pione/lang/common-parser.rb', line 201

def _line(content)
  space? >> content >> line_end
end

#line(content) ⇒ Object

Create an atom that matches a line with the content.



198
199
200
# File 'lib/pione/lang/common-parser.rb', line 198

def line(content)
  space? >> content >> line_end.as(:tail)
end

#padded?(atom) ⇒ Boolean

Enclose the atom by "pad?".

Returns:

  • (Boolean)


193
194
195
# File 'lib/pione/lang/common-parser.rb', line 193

def padded?(atom)
  pad? >> atom >> pad?
end

#spaced?(atom) ⇒ Boolean

Enclose the atom by "space?".

Returns:

  • (Boolean)


188
189
190
# File 'lib/pione/lang/common-parser.rb', line 188

def spaced?(atom)
  space? >> atom >> space?
end