2012-03-05 07:05:36 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2013-09-02 15:41:50 +00:00
|
|
|
import extras.pokemontools.config as conf
|
2013-08-29 03:48:44 +00:00
|
|
|
import extras.pokemontools.preprocessor as preprocessor
|
|
|
|
|
2013-08-03 21:25:14 +00:00
|
|
|
from extras.pokemontools.crystal import (
|
2013-01-10 21:07:36 +00:00
|
|
|
command_classes,
|
|
|
|
Warp,
|
|
|
|
XYTrigger,
|
|
|
|
Signpost,
|
|
|
|
PeopleEvent,
|
|
|
|
DataByteWordMacro,
|
|
|
|
text_command_classes,
|
|
|
|
movement_command_classes,
|
2013-01-27 23:45:23 +00:00
|
|
|
music_classes,
|
2013-03-29 22:54:13 +00:00
|
|
|
effect_classes,
|
2013-01-10 21:07:36 +00:00
|
|
|
)
|
2012-04-26 19:14:46 +00:00
|
|
|
|
2013-08-31 15:13:17 +00:00
|
|
|
def load_pokecrystal_macros():
|
|
|
|
"""
|
|
|
|
Construct a list of macros that are needed for pokecrystal preprocessing.
|
|
|
|
"""
|
|
|
|
ourmacros = []
|
|
|
|
|
|
|
|
even_more_macros = [
|
|
|
|
Warp,
|
|
|
|
XYTrigger,
|
|
|
|
Signpost,
|
|
|
|
PeopleEvent,
|
|
|
|
DataByteWordMacro,
|
|
|
|
]
|
2013-01-27 23:45:23 +00:00
|
|
|
|
2013-08-31 15:13:17 +00:00
|
|
|
ourmacros += command_classes
|
|
|
|
ourmacros += even_more_macros
|
|
|
|
ourmacros += [each[1] for each in text_command_classes]
|
|
|
|
ourmacros += movement_command_classes
|
|
|
|
ourmacros += music_classes
|
|
|
|
ourmacros += effect_classes
|
2012-04-26 19:14:46 +00:00
|
|
|
|
2013-08-31 15:13:17 +00:00
|
|
|
return ourmacros
|
2012-04-26 19:14:46 +00:00
|
|
|
|
2013-09-02 15:41:50 +00:00
|
|
|
def preprocess(config, macros, lines=None):
|
2013-03-21 20:15:42 +00:00
|
|
|
"""
|
2013-08-29 03:48:44 +00:00
|
|
|
Entry point for the preprocessor.
|
2012-04-26 19:14:46 +00:00
|
|
|
"""
|
2013-09-02 15:41:50 +00:00
|
|
|
processor = preprocessor.Preprocessor(config, macros)
|
|
|
|
return processor.preprocess(lines=lines)
|
2012-11-30 16:12:27 +00:00
|
|
|
|
2013-08-31 17:12:09 +00:00
|
|
|
def main():
|
2013-09-02 15:41:50 +00:00
|
|
|
config = conf.Config()
|
2013-08-31 16:04:27 +00:00
|
|
|
macros = load_pokecrystal_macros()
|
2013-09-02 15:41:50 +00:00
|
|
|
return preprocess(config, macros)
|
2012-11-30 16:12:27 +00:00
|
|
|
|
|
|
|
# only run against stdin when not included as a module
|
|
|
|
if __name__ == "__main__":
|
2013-08-31 17:12:09 +00:00
|
|
|
main()
|