lib/facets/more/stateparser.rb in facets-1.3.3 vs lib/facets/more/stateparser.rb in facets-1.4.0

- old
+ new

@@ -1,42 +1,29 @@ -#-- -# StateParser +# = stateparser.rb # -# Copyright (c) 2005 Thomas Sawyer +# == Copyright (c) 2005 Thomas Sawyer # -# Ruby License +# Ruby License # -# This module is free software. You may use, modify, and/or redistribute this -# software under the same terms as Ruby. +# This module is free software. You may use, modify, and/or redistribute this +# software under the same terms as Ruby. # -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. # -# ========================================================================== -# Revision History -# ========================================================================== +# == Author(s) # -# 5.6.05 v3.0 trans -# * Third major rewrite. This improves the system substantially. -# -# 5.2.06 v2.0 trans -# - Removed raw tokens. Raw text is now available to every regular -# token, so the end application can decided how to treat it. -# -# 5.1.27 v1.0 trans -# - Removed priority. Order of tokens when parser is initialized -# now determines precedence. -# - If first argument to Parser.new is not a kind of AbstractToken -# it is assumed to be the reentrant parser, otherwise the parser -# itself is considered the reentrant parser. Having this allows raw -# tokens to parse embedded content (among other things). -# -# ========================================================================== -#++ +# * Thomas Sawyer -#:title: StateParser +# Author:: Thomas Sawyer +# Copyright:: Copyright (c) 2005 Thomas Sawyer +# License:: Ruby License + +require 'ostruct' + +# = StateParser # # Gerenal purpose stack-based parser. Define custom tokens # and the parser will build a parse tree from them. # # == Synopsis @@ -109,25 +96,28 @@ # in that it decides token precedence on a first-is-highest basis. # # [Note: There are a few other subtilties to go over that I haven't yet # documented, primarily related to creating more elaborate custom tokens. TODO!] # -# == Author(s) +# Removed raw tokens. Raw text is now available to every regular +# token, so the end application can decided how to treat it. # -# * Thomas Sawyer +# Removed priority. Order of tokens when parser is initialized +# now determines precedence. # +# If first argument to Parser.new is not a kind of AbstractToken +# it is assumed to be the reentrant parser, otherwise the parser +# itself is considered the reentrant parser. Having this allows raw +# tokens to parse embedded content (among other things). -require 'ostruct' - class StateParser ; end module StateParser::Constants MATCH = "match" ENDMATCH = "end_match" CALLBACK = "callback" ENDCALLBACK = "end_callback" end - # StateMachine Class class StateMachine class << self