Module: ANTLR3

Includes:
AST, Constants, Error
Defined in:
lib/antlr3.rb,
lib/antlr3/dot.rb,
lib/antlr3/dfa.rb,
lib/antlr3/task.rb,
lib/antlr3/util.rb,
lib/antlr3/tree.rb,
lib/antlr3/main.rb,
lib/antlr3/error.rb,
lib/antlr3/token.rb,
lib/antlr3/debug.rb,
lib/antlr3/profile.rb,
lib/antlr3/streams.rb,
lib/antlr3/version.rb,
lib/antlr3/template.rb,
lib/antlr3/constants.rb,
lib/antlr3/tree/debug.rb,
lib/antlr3/recognizers.rb,
lib/antlr3/tree/wizard.rb,
lib/antlr3/modes/filter.rb,
lib/antlr3/debug/socket.rb,
lib/antlr3/tree/visitor.rb,
lib/antlr3/token/linked.rb,
lib/antlr3/test/grammar.rb,
lib/antlr3/streams/rewrite.rb,
lib/antlr3/streams/unicode.rb,
lib/antlr3/test/functional.rb,
lib/antlr3/debug/event-hub.rb,
lib/antlr3/modes/ast-builder.rb,
lib/antlr3/debug/rule-tracer.rb,
lib/antlr3/template/parameter.rb,
lib/antlr3/streams/interactive.rb,
lib/antlr3/template/group-file.rb,
lib/antlr3/template/group-file-lexer.rb,
lib/antlr3/template/group-file-parser.rb,
lib/antlr3/debug/trace-event-listener.rb,
lib/antlr3/debug/record-event-listener.rb

Overview

author: Kyle Yetter <kcy5b@yahoo.com> created on: October 22, 2011 purpose: (program | library | utility script | ?) summary: loads: files required by this autoloads: autoload entries in this (e.g. YAML(yaml))

Defined Under Namespace

Modules: AST, ASTBuilder, CharacterStream, ClassMacros, Constants, DOT, Debug, Error, FilterMode, Main, Profile, Rewrite, Stream, Template, Test, Token, TokenFactory, TokenSource, TokenStream, Util Classes: Bug, ChainedToken, ChainedTokenStream, CommonToken, CommonTokenStream, CompileTask, DFA, FileStream, InteractiveStringStream, Lexer, Parser, Recognizer, RecognizerSharedState, Scope, StringStream, TokenRewriteStream, TokenScheme, UnicodeStream

Constant Summary

LIBRARY_PATH =

:stopdoc: BEGIN PATHS – do not modify

::File.expand_path( ::File.dirname( __FILE__ ) ).freeze
PROJECT_PATH =
::File.dirname( LIBRARY_PATH ).freeze
DATA_PATH =
::File.join( PROJECT_PATH, 'java' ).freeze
ANTLR_MAJOR_VERSION =

The version of the ANTLR tool used while designing and testing the current version of this library

3
ANTLR_MINOR_VERSION =
5
ANTLR_PATCH_VERSION =
0
ANTLR_VERSION =
[ ANTLR_MAJOR_VERSION, ANTLR_MINOR_VERSION, ANTLR_PATCH_VERSION ].freeze
ANTLR_VERSION_STRING =
ANTLR_VERSION.join( '.' )
MAJOR_VERSION =

The version data for the current state the library itself

1
MINOR_VERSION =
10
PATCH_VERSION =
0
VERSION =
[ MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION ]
VERSION_STRING =
VERSION.join( '.' ).freeze
BaseRecognizer =

constant alias for compatibility with older versions of the runtime library

Recognizer

Constants included from Constants

Constants::BUILT_IN_TOKEN_NAMES, Constants::DEFAULT, Constants::DOWN, Constants::EOF, Constants::EOF_TOKEN, Constants::EOR_TOKEN_TYPE, Constants::HIDDEN, Constants::INVALID, Constants::INVALID_TOKEN, Constants::MEMO_RULE_FAILED, Constants::MEMO_RULE_UNKNOWN, Constants::MIN_TOKEN_TYPE, Constants::SKIP_TOKEN, Constants::UP

Class Method Summary collapse

Methods included from Error

EarlyExit, FailedPredicate, MismatchedNotSet, MismatchedRange, MismatchedSet, MismatchedToken, MismatchedTreeNode, MissingToken, NoViableAlternative, RewriteCardinalityError, RewriteEarlyExit, RewriteEmptyStream, UnwantedToken

Class Method Details

.antlr_jarObject



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/antlr3.rb', line 144

def self.antlr_jar
  @antlr_jar and return( @antlr_jar )
  
  path = data_path "antlr-full-#{ ANTLR_VERSION_STRING }.jar"
  if env_path = ENV[ 'RUBY_ANTLR_JAR' ]
    if File.file?( env_path ) then return File.expand_path( env_path ) end
    
    warn( 
      "#{ __FILE__ }:#{ __LINE__ }: " <<
      "ignoring environmental variable RUBY_ANTLR_JAR (=%p) " % env_path <<
      "as it is not the path to an existing file\n" <<
      "  -> trying default jar path %p instead" % path
    )
  end
  
  File.exists?( path ) ? path : nil
end

.antlr_jar=(path) ⇒ Object



140
141
142
# File 'lib/antlr3.rb', line 140

def self.antlr_jar=( path )
  @antlr_jar = path ? File.expand_path( path.to_s ) : path
end

.bug!(message = nil) ⇒ Object

This is used internally in a handful of locations in the runtime library where assumptions have been made that a condition will never happen under normal usage conditions and thus an ANTLR3::Bug error will be raised if the condition does occur.



132
133
134
135
136
# File 'lib/antlr3.rb', line 132

def self.bug!( message = nil )
  bug = Bug.new( message )
  bug.set_backtrace( caller )
  raise( bug )
end

.data_path(*args) ⇒ Object

Returns the lpath for the module. If any arguments are given, they will be joined to the end of the path using File.join.



124
125
126
# File 'lib/antlr3.rb', line 124

def self.data_path( *args )
  ::File.expand_path( ::File.join( DATA_PATH, *args ) )
end

.library_path(*args) ⇒ Object

Returns the library path for the module. If any arguments are given, they will be joined to the end of the libray path using File.join.



116
117
118
# File 'lib/antlr3.rb', line 116

def self.library_path( *args )
  ::File.expand_path( ::File.join( LIBRARY_PATH, *args ) )
end