How do you load g4 grammars with inmemantlr? - antlr4

Sticking to the sample code in the readme of inmemantlr, I can't get any of the grammars-v4 to work. When initializing GenericParser with java8.g4, for instance, it says:
error(50): :1426:3: syntax error: 'lL' came as a complete surprise to me while matching a lexer rule
error(50): :1448:3: syntax error: '1-9' came as a complete surprise to me while matching a lexer rule
error(50): :1469:7: syntax error: 'xX' came as a complete surprise to me while looking for lexer rule element
error(50): :1479:3: syntax error: '0-9a-fA-F' came as a complete surprise to me while matching a lexer rule
error(50): :1505:3: syntax error: '0-7' came as a complete surprise to me while matching a lexer rule
error(50): :1521:7: syntax error: 'bB' came as a complete surprise to me while looking for lexer rule element
error(50): :1531:3: syntax error: '01' came as a complete surprise to me while matching a lexer rule
error(50): :1567:3: syntax error: 'eE' came as a complete surprise to me while matching a lexer rule
error(50): :1577:3: syntax error: '+-' came as a complete surprise to me while matching a lexer rule
error(50): :1582:3: syntax error: 'fFdD' came as a complete surprise to me while matching a lexer rule
error(50): :1593:7: syntax error: 'xX' came as a complete surprise to me while looking for lexer rule element
error(50): :1603:3: syntax error: 'pP' came as a complete surprise to me while matching a lexer rule
error(50): :1622:4: syntax error: ''\\\r\n]\n\t;\n\n// §3.10.5 String Literals\n\nStringLiteral\n\t:\t'"' StringCharacters? '"'\n\t;\n\nfragment\nStringCharacters\n\t:\tStringCharacter+\n\t;\n\nfragment\nStringCharacter\n\t:\t~["\\\r\n]\n\t|\tEscapeSequence\n\t;\n\n// §3.10.6 Escape Sequences for Character and String Literals\n\nfragment\nEscapeSequence\n\t:\t'\\' [btnfr"'\\' came as a complete surprise to me while looking for lexer rule element
error(50): :1660:3: syntax error: '0-3' came as a complete surprise to me while matching a lexer rule
error(50): :1735:3: syntax error: 'a-zA-Z$_' came as a complete surprise to me while matching a lexer rule
error(50): :1737:3: syntax error: '\u0000-\u007F\uD800-\uDBFF' came as a complete surprise to me while looking for lexer rule element
error(50): :1740:2: syntax error: '\uD800-\uDBFF' came as a complete surprise to me while matching a lexer rule
error(50): :1746:3: syntax error: 'a-zA-Z0-9$_' came as a complete surprise to me while matching a lexer rule
error(50): :1748:3: syntax error: '\u0000-\u007F\uD800-\uDBFF' came as a complete surprise to me while looking for lexer rule element
error(50): :1751:2: syntax error: '\uD800-\uDBFF' came as a complete surprise to me while matching a lexer rule
error(50): :1766:7: syntax error: ' \t\r\n\u000C' came as a complete surprise to me while matching a lexer rule
error(50): :1774:14: syntax error: '\r\n' came as a complete surprise to me while looking for lexer rule element
The line producing the output above is simply:
this.parser = new GenericParser(grammarFile);
where grammarFile is the java8.g4 file.
Ignoring the messages above and going on with the following:
this.parser.setListener(new ParserListener());
this.parser.compile();
fails with this exception:
org.snt.inmemantlr.exceptions.CompilationException: No string code pipeline availabe
at org.snt.inmemantlr.GenericParser.compile(GenericParser.java:313)
Using version 1.4 of inmemantlr (for compatibility with Java 8). Any pointers are appreciated.

Related

DBPedia FactExtractor: fails on extract-pacges

I'm using the fact-extractor (link) to run their example of extracting info from the football wiki pages. I've installed and tested all dependencies on windows and when I execute "make extract-pages", i get the following error:
(dbpenv) C:\dbpedia\fact-extractor-master>make extract-pages
mkdir workspace-en
bzcat enwiki-latest-pages-articles.xml.bz2 | python lib/WikiExtractor.py -o workspace-en/pages
File "lib/WikiExtractor.py", line 598
print id, title.encode('utf-8')
^
SyntaxError: invalid syntax
bzcat: I/O or other error, bailing out. Possible reason follows.
bzcat: Invalid argument
Input file = enwiki-latest-pages-articles.xml.bz2, output file = (stdout)
make: *** [Makefile:39: extract-pages] Error 1
I can't make sense of the error. This is an as-is codebase from their repo so I'm not really sure how to fix this.

Parsing error: Invalid regular expression: /\p{Lu}/: Invalid escape (Unicode general category properties)

ESLint 7.0.0 appears to have a problem with Unicode general category properties in regular expressions.
In one file, I'm getting this error message:
Parsing error: Invalid regular expression: /\p{Lu}/: Invalid escape
I'm getting it in other files as well, but this is the most simple expression on which I'm getting it.
It's a valid expression. Works just fine when I run the code. But it's breaking my ESLint run.
What setting do I use to get ESLint to accept these expressions?
Problem seems to disappear by adjusting .eslintrc.json slightly:
"parserOptions": {
"ecmaVersion": 2019
}

Validation error if Import is not present in xtext

In my xtext grammar file to support wildcard import support, i have the following grammar rule.
Import:
'import' importedNamespace= QualifiedNameWithWildcard ';'
My requirement is i need to display the validation error if required dependency is not imported. for that i have added following code in grammar but while opening the project the validation error is displayed and disappeared in seconds.
TypeRef:
type=[Type | QualifiedName ]
But if i have changed the QualifiedNameWithWildcard with QualifiedName , i am able to show the validation error but wildcard import support is breaking. I have tried the following code it is not working.
Import:
'import' importedNamespace= QualifiedName ';'
Import:
'import' importedNamespace= QualifiedName | importedNamespace= QualifiedNameWithWildcard ';'
Where am i going wrong?
can anyone please explain the following link:
Eclipse Xtext Naming where they have mentioned the follwing code is working. Import returns EuclidImport :
'import' (
importedNamespace=QualifiedName
| importedNamespace=QualifiedNameWithWildCard) ';'?
;

Getting "Parsing error: 'return' outside of function"

I am trying to lint and I am getting...
Parsing error: 'return' outside of function
This is in a markdown document so it should be ignored. How do I explicitly ignore this rule?

How to add sound in the beginning of android app?

It shows error when i use media player during runtime when i use this code :-
this is the code:-MediaPlayer mp3=MediaPlayer.create(this,R.raw.ShootToThrill);
mp3.start();
Here are the errors :-
C:\Users\Admin\AndroidStudioProjects\Quiz\app\src\main\res\raw\ShootToThrill.mp3
Error:Error: Invalid file name: must contain only lowercase letters and digits ([a-z0-9_.])
Error:Execution failed for task ':app:mergeDebugResources'.
C:\Users\Admin\AndroidStudioProjects\Quiz\app\src\main\res\raw\ShootToThrill.mp3: Error: Invalid file name: must contain only lowercase letters and digits ([a-z0-9_.])
You have to rename your file, for example : shoot_to_thrill.mp3

Resources