Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
Motto Rabbu!
Browse files Browse the repository at this point in the history
 - Bump Git version
 - Fixed cmake bat file to disable startup log
 - Prep work for expanding lexer
 - Removed BOM tag
 - Video Box now shows the duration of the line.
 - Added "mixin" as a valid template line
  • Loading branch information
Ristellise committed Aug 23, 2020
1 parent 8aaf21c commit f18ec97
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 65 deletions.
4 changes: 2 additions & 2 deletions build/git_version.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define BUILD_GIT_VERSION_NUMBER 9205
#define BUILD_GIT_VERSION_STRING "9205"
#define BUILD_GIT_VERSION_NUMBER 9206
#define BUILD_GIT_VERSION_STRING "9206"
#define TAGGED_RELEASE 0
#define INSTALLER_VERSION '2.0.0'
#define RESOURCE_BASE_VERSION 2, 0, 0
125 changes: 68 additions & 57 deletions libaegisub/common/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,69 +111,76 @@ struct dialogue_tokens final : lex::lexer<Lexer> {
int paren_depth;

template<typename KT>
void init(KT &&kara_templater) {
void init(KT &&kara_templater, bool onlyKT = false) {
using lex::_state;
using lex::char_;
using lex::string;
using namespace boost::phoenix;
using namespace agi::ass::DialogueTokenType;

this->self
= string("\\\\[nNh]", LINE_BREAK)
| char_('{', OVR_BEGIN)[ref(paren_depth) = 0, _state = "OVR"]
| kara_templater
| string(".", TEXT)
;

this->self("OVR")
= char_('{', ERROR)
| char_('}', OVR_END)[_state = "INITIAL"]
| char_('\\', TAG_START)[_state = "TAGSTART"]
| string("\\s+", WHITESPACE)
| kara_templater
| string(".", COMMENT)
;

this->self("ARG")
= char_('{', ERROR)
| char_('}', OVR_END)[_state = "INITIAL"]
| char_('(', OPEN_PAREN)[++ref(paren_depth)]
| char_(')', CLOSE_PAREN)[--ref(paren_depth), if_(ref(paren_depth) == 0)[_state = "OVR"]]
| char_('\\', TAG_START)[_state = "TAGSTART"]
| char_(',', ARG_SEP)
| string("\\s+", WHITESPACE)
| string(".", ARG)
| kara_templater
;

this->self("TAGSTART")
= string("\\s+", WHITESPACE)
| string("r|fn", TAG_NAME)[_state = "ARG"]
| char_('\\', TAG_START)
| char_('}', OVR_END)[_state = "INITIAL"]
| string("[a-z0-9]", TAG_NAME)[_state = "TAGNAME"]
| string(".", COMMENT)[_state = "OVR"]
| kara_templater
;

this->self("TAGNAME")
= string("[a-z]+", TAG_NAME)[_state = "ARG"]
| char_('(', OPEN_PAREN)[++ref(paren_depth), _state = "ARG"]
| char_(')', CLOSE_PAREN)[--ref(paren_depth), if_(ref(paren_depth) == 0)[_state = "OVR"]]
| char_('}', OVR_END)[_state = "INITIAL"]
| char_('\\', TAG_START)[_state = "TAGSTART"]
| string(".", ARG)[_state = "ARG"]
| kara_templater
;
if (onlyKT)
{
}
else
{
this->self
= string("\\\\[nNh]", LINE_BREAK)
| char_('{', OVR_BEGIN)[ref(paren_depth) = 0, _state = "OVR"]
| kara_templater
| string(".", TEXT)
;

this->self("OVR")
= char_('{', ERROR)
| char_('}', OVR_END)[_state = "INITIAL"]
| char_('\\', TAG_START)[_state = "TAGSTART"]
| string("\\s+", WHITESPACE)
| kara_templater
| string(".", COMMENT)
;

this->self("ARG")
= char_('{', ERROR)
| char_('}', OVR_END)[_state = "INITIAL"]
| char_('(', OPEN_PAREN)[++ref(paren_depth)]
| char_(')', CLOSE_PAREN)[--ref(paren_depth), if_(ref(paren_depth) == 0)[_state = "OVR"]]
| char_('\\', TAG_START)[_state = "TAGSTART"]
| char_(',', ARG_SEP)
| string("\\s+", WHITESPACE)
| string(".", ARG)
| kara_templater
;

this->self("TAGSTART")
= string("\\s+", WHITESPACE)
| string("r|fn", TAG_NAME)[_state = "ARG"]
| char_('\\', TAG_START)
| char_('}', OVR_END)[_state = "INITIAL"]
| string("[a-z0-9]", TAG_NAME)[_state = "TAGNAME"]
| string(".", COMMENT)[_state = "OVR"]
| kara_templater
;

this->self("TAGNAME")
= string("[a-z]+", TAG_NAME)[_state = "ARG"]
| char_('(', OPEN_PAREN)[++ref(paren_depth), _state = "ARG"]
| char_(')', CLOSE_PAREN)[--ref(paren_depth), if_(ref(paren_depth) == 0)[_state = "OVR"]]
| char_('}', OVR_END)[_state = "INITIAL"]
| char_('\\', TAG_START)[_state = "TAGSTART"]
| string(".", ARG)[_state = "ARG"]
| kara_templater
;
}

}

dialogue_tokens(bool karaoke_templater) : paren_depth(0) {
dialogue_tokens(int lexer_type) : paren_depth(0) {
using lex::string;
using namespace agi::ass::DialogueTokenType;

if (karaoke_templater)
if (lexer_type == 1)
init(string("![^!]*!", KARAOKE_TEMPLATE) | string("\\$[A-Za-z_]+", KARAOKE_VARIABLE));
else
else if (lexer_type == 0)
init(lex::char_('\1'));
}
};
Expand Down Expand Up @@ -205,15 +212,19 @@ namespace parser {
}

namespace ass {
std::vector<DialogueToken> TokenizeDialogueBody(std::string const& str, bool karaoke_templater) {
static const dialogue_tokens<lex::lexertl::actor_lexer<>> kt(true);
static const dialogue_tokens<lex::lexertl::actor_lexer<>> not_kt(false);
auto const& tokenizer = karaoke_templater ? kt : not_kt;

std::vector<DialogueToken> TokenizeDialogueBody(std::string const& str, int lexer_type) {
static dialogue_tokens<lex::lexertl::actor_lexer<>> lua_lexer(2);
static dialogue_tokens<lex::lexertl::actor_lexer<>> kara_lexer(1);
static dialogue_tokens<lex::lexertl::actor_lexer<>> ass_lexer(0);
auto* tokenizer = &ass_lexer;
if (lexer_type == 1) // karaoke lexer
tokenizer = &kara_lexer;
else if (lexer_type == 2) // lua code lexer
tokenizer = &lua_lexer;
char const *first = str.c_str();
char const *last = first + str.size();
std::vector<DialogueToken> data;
auto it = tokenizer.begin(first, last), end = tokenizer.end();
auto it = (*tokenizer).begin(first, last), end = (*tokenizer).end();

for (; it != end && token_is_valid(*it); ++it) {
int id = it->id();
Expand Down
4 changes: 2 additions & 2 deletions scripts/createcmake.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake -S . -B build-dir -G "Visual Studio 16 2019" -A x64 ^
-DWITH_AVISYNTH=OFF -DWITH_BUILD_CREDIT=ON -DWITH_CSRI=ON -DWITH_DIRECTSOUND=ON ^
-DWITH_AVISYNTH=OFF -DWITH_CSRI=ON -DWITH_DIRECTSOUND=ON ^
-DWITH_FFMS2=ON -DWITH_FFTW3=ON -DWITH_HUNSPELL=ON -DWITH_UCHARDET=ON ^
-DWITH_XAUDIO2=ON -DWITH_STARTUPLOG=ON -DWITH_BUILD_CREDIT=ON ^
-DWITH_XAUDIO2=ON -DWITH_BUILD_CREDIT=ON -DWITH_STARTUPLOG=OFF ^
-DBUILD_CREDIT="\"Daydream Cafe Edition [Shinon]\"" ^
-Dass_INCLUDE_DIRS="%cd%/vendor/exten/libass/libass" -Dass_LIBRARIES="%cd%/vendor/exten/libass/bin/Release_x64/libass.lib" ^
-DIconv_INCLUDE_DIR="%cd%/vendor/exten/libiconv/include" -DIconv_LIBRARY="%cd%/vendor/exten/libiconv/lib/iconv.lib" ^
Expand Down
2 changes: 1 addition & 1 deletion src/subs_edit_ctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void SubsTextEditCtrl::SetStyles() {

void SubsTextEditCtrl::UpdateStyle() {
AssDialogue *diag = context ? context->selectionController->GetActiveLine() : nullptr;
bool template_line = diag && diag->Comment && boost::istarts_with(diag->Effect.get(), "template");
bool template_line = diag && diag->Comment && (boost::istarts_with(diag->Effect.get(), "template") || boost::istarts_with(diag->Effect.get(), "mixin"));

tokenized_line = agi::ass::TokenizeDialogueBody(line_text, template_line);
agi::ass::SplitWords(line_text, tokenized_line);
Expand Down
2 changes: 1 addition & 1 deletion src/text_file_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TextFileWriter::TextFileWriter(agi::fs::path const& filename, std::string encodi

try {
// Write the BOM
WriteLineToFile("\xEF\xBB\xBF", false);
WriteLineToFile("", false);
}
catch (agi::charset::ConversionFailure&) {
// If the BOM could not be converted to the target encoding it isn't needed
Expand Down
4 changes: 2 additions & 2 deletions src/video_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ void VideoBox::UpdateTimeBoxes() {
VideoSubsPos->SetValue("");
else {
VideoSubsPos->SetValue(fmt_wx(
"%+dms; %+dms",
"%+dms; %+dms; %+dms",
time - active_line->Start,
time - active_line->End));
time - active_line->End,std::abs((time - active_line->End) - (time - active_line->Start))));
}
}

0 comments on commit f18ec97

Please sign in to comment.