It seems that the default installation directories are missing somehow.
/usr/bin/time lpg2 LEGLexer.gi
Options in effect for LEGKWLexer.gi:
ACTION-BLOCK=("LEGKWLexer.h","/.","./")
AST-DIRECTORY="" AST-TYPE="Ast" NOATTRIBUTES NOAUTOMATIC-AST NOBACKTRACK
BYTE CONFLICTS DAT-DIRECTORY="" DAT-FILE="LEGKWLexerdcl.data"
DCL-FILE="LEGKWLexerprs.cpp" NODEBUG DEF-FILE="LEGKWLexerdef.cpp"
DIRECTORY-PREFIX="" NOEDIT NOERROR-MAPS ESCAPE='$'
EXPORT-TERMINALS=("LEGLexerexp.h","","") EXTENDS-PARSETABLE FACTORY="new "
FILE-PREFIX="LEGKWLexer" NOFIRST NOFOLLOW NOGLR NOGOTO-DEFAULT
GRM-FILE="LEGKWLexer.gi" IMP-FILE="LEGKWLexerimp.h" INCLUDE-DIRECTORY=""
LALR=1 LEGACY NOLIST MARGIN=4 MAX-CASES=1024 NAMES=OPTIMIZED
NONT-CHECK OR_MARKER='|' OUT-DIRECTORY=""
PACKAGE="org.eclipse.imp.leg.parser" NOPARENT-SAVE
PARSETABLE-INTERFACES="ParseTable" PREFIX="Char_" PRIORITY
PROGRAMMING_LANGUAGE=RT_CPP PRS-FILE="LEGKWLexerprs.h" NOQUIET
READ-REDUCE REMAP-TERMINALS RULE_CLASSNAMES=SEQUENTIAL NOSCOPES
NOSERIALIZE NOSHIFT-DEFAULT SINGLE-PRODUCTIONS NOSOFT-KEYWORDS NOSTATES
SUFFIX="" SYM-FILE="LEGKWLexersym.h" TAB-FILE="LEGKWLexer.t" TABLE
TEMPLATE="KeywordTemplateF.gi" TRACE=CONFLICTS NOVARIABLES NOVERBOSE
NOVISITOR VISITOR-TYPE="Visitor" WARNINGS NOXREF
LEGKWLexer.gi:8:5:8:27:128:150: Warning: Some options may have been imported from the included file "KWLexerLowerCaseMapF.gi"
KWLexerLowerCaseMapF.gi:16:24:16:24:379:379: Warning: The macro "$" is undefined. No substitution made
KWLexerLowerCaseMapF.gi:2:5:2:14:16:25: Informative: The terminal DollarSign is useless.
KWLexerLowerCaseMapF.gi:3:5:3:11:39:45: Informative: The terminal Percent is useless.
KWLexerLowerCaseMapF.gi:4:5:4:5:59:59: Informative: The terminal _ is useless.
KWLexerLowerCaseMapF.gi:6:15:6:15:80:80: Informative: The terminal c is useless.
KWLexerLowerCaseMapF.gi:6:35:6:35:100:100: Informative: The terminal g is useless.
KWLexerLowerCaseMapF.gi:6:50:6:50:115:115: Informative: The terminal j is useless.
KWLexerLowerCaseMapF.gi:6:55:6:55:120:120: Informative: The terminal k is useless.
KWLexerLowerCaseMapF.gi:6:65:6:65:130:130: Informative: The terminal m is useless.
KWLexerLowerCaseMapF.gi:7:15:7:15:146:146: Informative: The terminal p is useless.
KWLexerLowerCaseMapF.gi:7:20:7:20:151:151: Informative: The terminal q is useless.
KWLexerLowerCaseMapF.gi:7:55:7:55:186:186: Informative: The terminal x is useless.
KWLexerLowerCaseMapF.gi:7:60:7:60:191:191: Informative: The terminal y is useless.
KWLexerLowerCaseMapF.gi:7:65:7:65:196:196: Informative: The terminal z is useless.
LEGKWLexer.gi:32:5:32:11:556:562: Informative: Grammar is LR(0).
Number of Terminals: 30
Number of Nonterminals: 1
Number of Productions: 11
Number of Single Productions: 0
Number of Items: 58
Number of States: 37
Number of Shift actions: 35
Number of Goto actions: 1
Number of Shift/Reduce actions: 10
Number of Goto/Reduce actions: 0
Number of Reduce actions: 1
Number of Shift-Reduce conflicts: 0
Number of Reduce-Reduce conflicts: 0
Number of entries in base Action Table: 38
Additional space required for compaction of Action Table: 2.6%
Number of unique terminal states: 37
Number of Shift actions saved by merging: 0
Number of Conflict points saved by merging: 0
Number of Reduce actions saved by merging: 0
Number of Reduce saved by default: 0
Number of entries in Terminal Action Table: 83
Additional space required for compaction of Terminal Table: 6.0%
Actions in Compressed Tables:
Number of Shifts: 35
Number of Shift/Reduces: 10
Number of Gotos: 1
Number of Goto/Reduces: 0
Number of Reduces: 1
Number of Defaults: 0
Parsing Tables storage:
Storage required for BASE_CHECK: 11 Bytes
Storage required for BASE_ACTION: 51 Bytes
Storage required for TERM_CHECK: 114 Bytes
Storage required for TERM_ACTION: 89 Bytes
The LALR Parser Generator Version 2.2.01 (Feb 26 2025)
(C) Copyright LPG Group. 1984, 2021.
Options in effect for LEGLexer.gi:
ACTION-BLOCK=("LEGLexer.h","/.","./")
AST-DIRECTORY="" AST-TYPE="Ast" NOATTRIBUTES NOAUTOMATIC-AST NOBACKTRACK
BYTE CONFLICTS DAT-DIRECTORY="" DAT-FILE="LEGLexerdcl.data"
DCL-FILE="LEGLexerprs.cpp" NODEBUG DEF-FILE="LEGLexerdef.cpp"
DIRECTORY-PREFIX="" NOEDIT NOERROR-MAPS ESCAPE='$'
EXPORT-TERMINALS=("LEGLexerexp.h","","") EXTENDS-PARSETABLE FACTORY="new "
FILE-PREFIX="LEGLexer" FILTER="LEGKWLexer.gi" NOFIRST NOFOLLOW NOGLR
NOGOTO-DEFAULT GRM-FILE="LEGLexer.gi" IMP-FILE="LEGLexerimp.h"
INCLUDE-DIRECTORY="" LALR=1 LEGACY NOLIST MARGIN=4 MAX-CASES=1024
NAMES=OPTIMIZED NONT-CHECK OR_MARKER='|' OUT-DIRECTORY=""
PACKAGE="org.eclipse.imp.leg.parser" NOPARENT-SAVE
PARSETABLE-INTERFACES="ParseTable" PREFIX="Char_" PRIORITY
PROGRAMMING_LANGUAGE=RT_CPP PRS-FILE="LEGLexerprs.h" NOQUIET READ-REDUCE
REMAP-TERMINALS RULE_CLASSNAMES=SEQUENTIAL NOSCOPES NOSERIALIZE
NOSHIFT-DEFAULT NOSINGLE-PRODUCTIONS NOSOFT-KEYWORDS NOSTATES SUFFIX=""
SYM-FILE="LEGLexersym.h" TAB-FILE="LEGLexer.t" TABLE
TEMPLATE="LexerTemplateF.gi" TRACE=CONFLICTS NOVARIABLES NOVERBOSE
NOVISITOR VISITOR-TYPE="Visitor" WARNINGS NOXREF
LEGLexer.gi:54:5:54:16:1032:1043: Informative: The terminal CtlCharNotWS is useless.
LEGLexer.gi:67:5:67:14:1397:1406: Informative: The terminal AfterASCII is useless.
LEGLexer.gi:107:5:107:9:2370:2374: Informative: Grammar is LALR(1).
Number of Terminals: 102
Number of Nonterminals: 40
Number of Productions: 172
Number of Items: 363
Number of States: 20
Number of Shift actions: 7
Number of Goto actions: 13
Number of Shift/Reduce actions: 359
Number of Goto/Reduce actions: 102
Number of Reduce actions: 20
Number of Shift-Reduce conflicts: 0
Number of Reduce-Reduce conflicts: 0
Number of entries in base Action Table: 135
Additional space required for compaction of Action Table: 14.0%
Number of unique terminal states: 18
Number of Shift actions saved by merging: 20
Number of Conflict points saved by merging: 0
Number of Reduce actions saved by merging: 0
Number of Reduce saved by default: 19
Number of entries in Terminal Action Table: 365
Additional space required for compaction of Terminal Table: 11.5%
Actions in Compressed Tables:
Number of Shifts: 7
Number of Shift/Reduces: 339
Number of Gotos: 13
Number of Goto/Reduces: 102
Number of Reduces: 1
Number of Defaults: 13
Parsing Tables storage:
Storage required for BASE_CHECK: 172 Bytes
Storage required for BASE_ACTION: 654 Bytes
Storage required for TERM_CHECK: 472 Bytes
Storage required for TERM_ACTION: 816 Bytes
0.00user 0.00system 0:00.01elapsed 90%CPU (0avgtext+0avgdata 7288maxresident)k
0inputs+168outputs (0major+581minor)pagefaults 0swaps
---------------------------- lpg2/include/buffer.h ----------------------------
index f184c12..25af425 100644
@@ -268,6 +268,13 @@ public:
}
}
+ void Close()
+ {
+ Flush();
+ fclose(file);
+ file = NULL;
+ }
+
//
// Write whatever information that is in the buffer out to file.
//
---------------------------- lpg2/include/symbol.h ----------------------------
index 69eb8a7..b50fd68 100644
@@ -244,9 +244,9 @@ private:
{
return (cursor[0] == (char) 0xEF &&
cursor[1] == (char) 0xBB &&
- cursor[2] == (char) 0xBF
+ cursor[2] == (char) 0xBF)
? 3
- : 0);
+ : 0;
}
};
----------------------------- lpg2/include/tuple.h -----------------------------
index 5732819..eb25df6 100644
@@ -50,7 +50,8 @@ public:
{
if(info != nullptr){
T *old_info = info;
- info = (T *) memmove(new T[new_size], old_info, size * sizeof(T));
+ info = new T[new_size];
+ memmove(info, old_info, size * sizeof(T));
delete [] old_info;
}else{
info =new T[new_size];
--------------------------- lpg2/src/CSharpTable.cpp ---------------------------
index 8ea20f9..c6e38ba 100644
@@ -684,7 +684,7 @@ void CSharpTable::exit_parser_files(void)
//
void CSharpTable::print_symbols(void) {
- fprintf(syssym, "");
+ fprintf(syssym, "\n");
if (strlen(option->package) > 0) {
fprintf(syssym, "namespace ");
fprintf(syssym,"%s", option->package);
---------------------------- lpg2/src/CppTable2.cpp ----------------------------
index c4966d1..48594e1 100644
@@ -304,7 +304,7 @@ void CppTable2::exit_parser_files(void)
//
void CppTable2::print_symbols(void)
{
- fprintf(syssym, "");
+ fprintf(syssym, "\n");
fprintf(syssym, "#pragma once\n #include <vector>\n#include<string>\n ");
fprintf(syssym, " struct ");
---------------------------- lpg2/src/DartTable.cpp ----------------------------
index 44ce11e..089bd59 100644
@@ -325,7 +325,7 @@ void DartTable::exit_parser_files(void)
//
void DartTable::print_symbols(void) {
- fprintf(syssym, "");
+ fprintf(syssym, "\n");
fprintf(syssym, "class ");
fprintf(syssym,"%s", option->sym_type);
fprintf(syssym, " {\n");
---------------------------- lpg2/src/JavaTable.cpp ----------------------------
index 0b8c558..0f10e36 100644
@@ -671,7 +671,7 @@ void JavaTable::exit_parser_files(void)
//
void JavaTable::print_symbols(void) {
- fprintf(syssym, "");
+ fprintf(syssym, "\n");
if (strlen(option->package) > 0) {
fprintf(syssym, "package ");
fprintf(syssym, "%s",option->package);
-------------------------- lpg2/src/Python2Table.cpp --------------------------
index c7a131d..da2c33c 100644
@@ -314,7 +314,7 @@ void Python2Table::exit_parser_files(void)
//
void Python2Table::print_symbols(void)
{
- fprintf(syssym, "");
+ fprintf(syssym, "\n");
fprintf(syssym, "class ");
fprintf(syssym,"%s", option -> sym_type);
-------------------------- lpg2/src/Python3Table.cpp --------------------------
index a6b3498..538c19c 100644
@@ -316,7 +316,7 @@ void Python3Table::exit_parser_files(void)
//
void Python3Table::print_symbols(void)
{
- fprintf(syssym, "");
+ fprintf(syssym, "\n");
fprintf(syssym, "class ");
fprintf(syssym, "%s",option -> sym_type);
------------------------- lpg2/src/TypeScriptTable.cpp -------------------------
index 83219d8..4116ff6 100644
@@ -318,7 +318,7 @@ void TypeScriptTable::exit_parser_files(void)
//
//
void TypeScriptTable::print_symbols(void) {
- fprintf(syssym, "");
+ fprintf(syssym, "\n");
fprintf(syssym, "export namespace ");
fprintf(syssym, "%s",option->sym_type);
----------------------------- lpg2/src/control.cpp -----------------------------
index da45e53..43dc502 100644
@@ -333,8 +333,7 @@ void Control::InvalidateFile(const char *filename, const char *filetype)
break;
}
- buffer.Flush();
- fclose(file);
+ buffer.Close();
return;
}
----------------------------- lpg2/src/option.cpp -----------------------------
index 13cf33c..f90c724 100644
@@ -305,6 +305,12 @@ Option::Option(int argc_, const char **argv_)
throw 12;
}
}
+ if(include_search_directory.Length() == 0) {
+ include_search_directory.Next() = "";
+ }
+ if(template_search_directory.Length() == 0) {
+ template_search_directory.Next() = "";
+ }
}
Option::~Option()
----------------------------- lpg2/src/symbol.cpp -----------------------------
index 5554a53..59e6d35 100644
@@ -23,7 +23,9 @@ InputFileSymbol::ReadInput()
FILE *srcfile = fopen(filename, "rb");
if (srcfile != NULL)
{
- buffer = new char[status.st_size + 4];
+ size_t bsz = status.st_size + 4;
+ buffer = new char[bsz];
+ memset(buffer, 0, bsz);
size_t file_size = fread(buffer + 1, sizeof(char), status.st_size, srcfile);
fclose(srcfile);
int mark_size = ByteOrderMarkSize(buffer + 1);
I'm building on Ubuntu 18.04 64 bits with
g++-9with a custom script that builds thelpg2binary, to be able to build/run I needed to make the changes shown bellow.Now I can run
lpg2but it doesn't find the template files and I need to put all files on the same folder (I'm not using any extra command line parameters, not even-include-directory=semicolon-separated-strings), it seems that it expect the template files to be in some specific places but I can't find where they are specified, when I build it usinglpg2/CMakeLists.txtthere is no install option likemake install.I'm following the https://github.com/A-LPG/LPG2/blob/main/lpg-generator-templates-2.1.00/docs/Getting%20Started%20with%20LPG.pdf .
It seems that the default installation directories are missing somehow.
Can anyone give some clues here ?