diff --git a/.gitignore b/.gitignore index c228184..7dfdb96 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ ## my ban out/ temp/ +NlpParser/* +!NlpParser/Nlp.g4 +!NlpParser/testbench.txt +!NlpParser/compile.bat .vscode/ diff --git a/NlpParser/Nlp.g4 b/NlpParser/Nlp.g4 new file mode 100644 index 0000000..002e784 --- /dev/null +++ b/NlpParser/Nlp.g4 @@ -0,0 +1,28 @@ +grammar Nlp; + +nlp_document: LANG_HEADER (section)* ; + +section: SECTION_HEAD (sub_section | entry)* ; + +sub_section: SUB_SECTION_HEAD (entry)* ; + +entry: ENTRY_STRING # entry_string_t +| ENTRY_STRING (LINE_CONCAT ENTRY_STRING)+ # entry_concated_string_t +| ENTRY_INTEGER # entry_integer_t +; + +LANG_HEADER: 'Language:' [a-zA-Z]+ ; + +SECTION_HEAD: '[' NAME_SECTION ']' ; +SUB_SECTION_HEAD: '<' NAME_SECTION '>' ; +fragment NAME_SECTION: [ a-zA-Z0-9]+ ; // section name are consisted of space, char and number + +ENTRY_STRING: '"' (STRING_ESC|.)*? '"' ; +fragment STRING_ESC: '\\"' | '\\\\' ; + +ENTRY_INTEGER: [1-9][0-9]+ ; + +SPLITTOR: [ ,;\r\n]+ -> skip; // ignore all splittor and space +LINE_CONCAT: '\\' ; +LINE_COMMENT: '//' ~[\r\n]* -> skip ; // consume all non-line-breaker. because we need line breaker. +BLOCK_COMMENT: '/*' .*? '*/' -> skip ; diff --git a/NlpParser/compile.bat b/NlpParser/compile.bat new file mode 100644 index 0000000..47af20c --- /dev/null +++ b/NlpParser/compile.bat @@ -0,0 +1,3 @@ +antlr4 Nlp.g4 +javac Nlp*.java +grun Nlp nlp_document < testbench.txt \ No newline at end of file diff --git a/NlpParser/testbench.txt b/NlpParser/testbench.txt new file mode 100644 index 0000000..b76e217 --- /dev/null +++ b/NlpParser/testbench.txt @@ -0,0 +1,71 @@ +Language:English + +/* + ----===[[[[ Virtools Language Pack File ]]]]===---- + + Rules: + First line must contain the string 'Language:' followed by the language name. + The file may be seen as sections, each section name is enclosed in brackets ([,]) + Sections can have sub-sections, with names enclosed in brackets (<,>) + For every section or sub-section, you can have as many entries as you want, + which can be: - strings (optionaly enclosed in quotes) + - numbers + Separators for entries are ',',';' or LF (line feed) + Entries belong to the last section or sub-section specified, until + a new section is reached. The first entry of the section has an index of 0, + the next one, an index of 1, and so on. + Comments can be added using the standard ANSI C++ scheme. + Also, dont remove %s,%d and %f tags, those will be replaced at runtime by strings or numbers. + A string can take multiple lines, adding \ at the end of the line means that the entry + continues on the next line. + + NOTE FOR TRANSLATORS: DO NOT CHANGE ENTRIES ORDER IN THIS FILE!!! + +*/ + +[Version] +"Virtools Dev","Virtools Crea" +"Virtools Dev Evaluation","Virtools Crea Evaluation" +"Virtools Dev Education","Virtools Crea Education" + + +[Profiler] +"Profiler" + +"Database","Framerate","Objects Drawn","Faces Drawn","Lines Drawn" +"Behavior Code Execution Details...","Collisions Management","Parametric Operations", +"IK","Floors Management","Other Code" + +[Common] + +"MultiSelection" + +// -- DONT CHANGE THIS + + +"Software\\Virtools\\Global","Usage Count" + + +"Key1","Key2","Key3","SYSINFO.SysInfo32\\CLSID","\\csrsrv32.dll" + +// -- ENDOF DONT CHANGE + + +"Your license has expired.\n\nYou must either stop evaluating Virtools or\nextend it by clicking the 'Extend' button and following the instructions.\n\nAlso, check out our web resources for more information:" +"- Main Web Site","- Virtools mailing list, additional resources, discussions and more." +"Customer Key:","Check Key:" +"HOWTO:\n\t- A new customer key will be generated.\n\t- Send it by e-mail to our support service at: support@Virtools.com\n"\ +"\t You will receive back a valid check key according to your customer key.\n\t- Copy/Paste the key into corresponding field above.\n"\ +"\t- Your license will be extended to as many days as specified in your agreement.\n\n"\ +"WARNING: Once generated, the customer key is valid for 5 days only." + + +[3D Layout] +"3D Layout" + + +"New 3D Frame","New 2D Frame","New Camera","New Light","New Curve","New Grid","New Material","New Texture","New Portal" + + +"--- Out of range ---" +"%s '%s' created." // on creation (ie. TargetLight 'light0000' created.)