SceneMaker / VisualSceneMaker

Visual SceneMaker is an authoring tool for creating interactive presentations aimed to non-programming experts. It supports the modeling of verbal and non-verbal behavior of Virtual Characters and robots. Therefore, it provides users with a graphical interface and a simple scripting language that allows them to create rich and compelling content.
http://scenemaker.dfki.de
Other
18 stars 11 forks source link

Expanding the scene script parser #273

Closed fnunnari closed 1 year ago

fnunnari commented 1 year ago

I need to support more characters (e.g., ù) in the scene scripts.

The supported symbols are listed in the lexer configuration: de/dfki/vsm/model/scenescript/lexxer.jflex , line 164.

I tried to modify it, but the parser ScriptParser.java  is not rebuilt. I guess that the invoking of JCup is missing from the Gradle build system. Somebody knows how to re-generate the parser? Or are we stuck with the old grammar?

fnunnari commented 1 year ago

Short answer:

#!/usr/bin/env sh
java -cp lib/JFlex.jar JFlex.Main core/src/main/java/de/dfki/vsm/model/scenescript/lexxer.jflex
java -cp lib/JCup.jar java_cup.Main -progress -time -interface -parser ScriptParser -symbols ScriptFields -destdir core/src/main/java/de/dfki/vsm/model/scenescript/ core/src/main/java/de/dfki/vsm/model/scenescript/parser.jcup

Long answer. Details found in the old ant build configuration file (Attached).

Some more details:

Stuff for the Scene Scripts (scngendir --> src/de/dfki/vsm/model/scenescript)

    <!-- Define Destination Directory For Parser -->
    <property name="scngendir"
              value="${basedir}${file.separator}src${file.separator}de${file.separator}dfki${file.separator}vsm${file.separator}model${file.separator}scenescript"/>
    <!-- Define Script Lex File -->
    <property name="scnlexfile" value="${scngendir}${file.separator}lexxer.jflex"/>
    <!-- Define Script Cup File -->
    <property name="scncupfile" value="${scngendir}${file.separator}parser.jcup"/>

Stuff for the expressions in the nodes (math operations)

    <!-- Define Destination Directory For Parser -->
    <property name="sflgendir"
              value="${basedir}${file.separator}src${file.separator}de${file.separator}dfki${file.separator}vsm${file.separator}model${file.separator}sceneflow${file.separator}glue"/>
        <!-- Define Scenes Lex File -->
    <property name="sfllexfile" value="${sflgendir}${file.separator}lexxer.jflex"/>
    <!-- Define Scenes Cup File -->
    <property name="sflcupfile" value="${sflgendir}${file.separator}parser.cup"/>

Focus on the scene script. Three files are generated from the parser:

    <!-- Define Script Scanner File -->
    <property name="scnscnfile" value="${scngendir}${file.separator}ScriptLexxer.java"/>
    <!-- Define Script Token File -->
    <property name="scntknfile" value="${scngendir}${file.separator}ScriptFields.java"/>
    <!-- Define Script Parser File -->
    <property name="scnprsfile" value="${scngendir}${file.separator}ScriptParser.java"/>

Target using the lex source lexxer.jflex, to generate ScriptLexxer.java

        <!-- <echo message="Generating '${sflscnfile}' ${line.separator}      from '${sfllexfile}'"/> -->
        <java classname="JFlex.Main">
            <arg file="${sfllexfile}"/>
            <classpath refid="clspath"/>
        </java>

Similarly, target using the cup source scncupfile (parser.cup), to generate ScriptFields.java and ScriptParser.java:

        <!-- <echo message="Generating '${scnprsfile}' ${line.separator}      from '${scncupfile}'"/> -->
        <java classname="java_cup.Main">
            <arg line="-progress -time -interface -parser ScriptParser -symbols ScriptFields -destdir '${scngendir}'"/>
            <arg file="${scncupfile}"/>
            <classpath refid="clspath"/>
        </java>

Reconstruction of the equivalent command lines is straightforward:

java -cp lib/JFlex.jar JFlex.Main core/src/main/java/de/dfki/vsm/model/scenescript/lexxer.jflex
java -cp lib/JCup.jar java_cup.Main -progress -time -interface -parser ScriptParser -symbols ScriptFields -destdir core/src/main/java/de/dfki/vsm/model/scenescript/ core/src/main/java/de/dfki/vsm/model/scenescript/parser.jcup

build.xml.txt

fnunnari commented 1 year ago

Close by commit bbc0fe7e1d2a2a28b548830afbd286554e696161