Add first stage of a new single-file parser
This first stage consists of the general framework for the parser as a whole, a lexical analyzers to converts text into commands, and the semantic anlyzer to convert commands into a complete data structure representing the cumulative effect of running the commands.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#
|
||||
# Crafting Guide - item_pe_v1.coffee
|
||||
#
|
||||
# Copyright © 2014-2016 by Redwood Labs
|
||||
# All rights reserved.
|
||||
#
|
||||
|
||||
ParserExtension = require '../parser_extension'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
module.exports = class ItemParserExtensionV1 extends ParserExtension
|
||||
|
||||
# Command Methods ##############################################################################
|
||||
|
||||
_command_gatherable: (command)->
|
||||
return if @missingArgText command
|
||||
|
||||
return if @missingCurrent command, 'item'
|
||||
|
||||
item = @state.getCurrent 'item'
|
||||
return if @duplicateField command, 'gatherable', item
|
||||
|
||||
gatherable = @parseBoolean command, command.argText
|
||||
return unless gatherable?
|
||||
|
||||
item.gatherable = gatherable
|
||||
|
||||
_command_item: (command)->
|
||||
return if @missingArgText command
|
||||
return if @missingCurrent command, 'modVersion'
|
||||
return if @alreadyExists command, 'item', command.argText
|
||||
|
||||
item = @state.create command, 'item', command.argText
|
||||
item.name = command.argText
|
||||
|
||||
group = @state.getCurrent 'itemGroup'
|
||||
if group? then item.group = group
|
||||
|
||||
item.modVersion = @state.getCurrent 'modVersion'
|
||||
Reference in New Issue
Block a user