Why is .NET exception not caught by try/catch block?

I'm working on a project using the ANTLR parser library for C#. I've built a grammar to parse some text and it works well. However, when the parser comes across an illegal or unexpected token,...

How can I modify the text of tokens in a CommonTokenStream with ANTLR?

I'm trying to learn ANTLR and at the same time use it for a current project. I've gotten to the point where I can run the lexer on a chunk of code and output it to a CommonTokenStream. This is...

Is there an alternative for flex/bison that is usable on 8-bit embedded systems?

I'm writing a small interpreter for a simple BASIC like language as an exercise on an AVR microcontroller in C using the avr-gcc toolchain. However, I'm wondering if there are any open source...

Basic Lex file for Hoc1 in book "Unix Programming Environment"

In the book "Unix Programming Environment" the book relies on writing its own lexer for all but one of the examples in the chapter on writing "hoc". I would really like to see the use of lex for...

How would I go about Implementing A Simple Stack-Based Programming Language

I am interested in extending my knowledge of computer programming by implementing a stack-based programming language. I am seeking out advice on where to begin, as I intend for it to have...

Code replacement with an annotation processor

I'm trying to write an annotation processor to insert methods and fields on a class... and the documentation is so sparse. I'm not getting far and I don't know if I'm approaching it correctly. The...

Lexer for Parsing to the end of a line

If I have a keyword, how can I get it to, once it encounters a keyword, to just grab the rest of the line and return it as a string? Once it encounters an end of line, return everything on that...

Setting up Cup/JLex parsing properly

I have a very basic lexer here: import java_cup.runtime.*; import java.io.IOException; %% %class AnalyzerLex %function next_token %type java_cup.runtime.Symbol %unicode //%line //%column //...

How Get error messages of antlr parsing?

I wrote a grammar with antlr 4.4 like this : grammar CSV; file : row+ EOF ; row : value (Comma value)* (LineBreak | EOF) ; value : SimpleValueA | QuotedValue ; Comma : ...

OperationalError, no such column. Django

I am very new to django and was able to finish the tutorial on djangoproject.com without any errors. I am now going through the Django REST framework tutorial found at...

direct-coded vs table-driven lexer?

I'm new in compiler construction world , I want to know what are the differences between direct-coded vs table-driven lexer analyzer ? Please use simple source code example if it's...

Generate an AST in C++

I'm making an interpreter in C++, so far I've got my lexer to generate tokens. The problem is I'm not sure how to generate an "walk" a parse tree. I was thinking of making my parse tree using an...

Find the Range of the Nth word in a String

What I want is something like "word1 word2 word3".rangeOfWord(2) => 6 to 10 The result could come as a Range or a tuple or whatever. I'd rather not do the brute force of iterating over the...

How to recognize that an application is running in dark theme on Linux?

I've developed an application which uses qscintilla as a text editor. I also implemented custom lexer to highlight language specific keywords. So far styles for highlighted keywords are hardcoded...

General language parser as a finite state machine

I've written very low performance descent recursion parser for general language (open source, for EBNF grammars). And I want to fix its performance by rewriting parser. I read about lexical...

Xtext indentation with single line comment

I was having problems with indentation and single line comments in my xtext grammar. I tried the same thing in xtext example project org.eclipse.xtext.example.homeautomation (with Xtext...

How to do semantic analysis using Antlr?

I am currently trying to implement a ruby compiler.To create the parser and lexer I used Antlr4. Now i am unable to figure out how to implement semantic analysis into the parser.Can someone...

Is there any formal explanation, why a lexer rule defined first is not visible to a parser rule defined later?

The initial title question was: Why does my lexer rule not work, until I change it to a parser rule? The contents below are related to this question. Then I found new information and changed the...

antlr4/java: pretty print parse tree to stdout

Beginners question: how do I print a readable version of the parse tree to stdout? CharStream input = CharStreams.fromFileName("testdata/test.txt"); MyLexer lexer = new...

How to get the source text from line number using clang?

I am using clang matcher to obtain the result nodes. From the result nodes, I am able to get the line number, let us say 17. Now, I would like to get the entire source code in that line. Please...

Nearley Moo - Grammar does not work with Moo lexer used

I'm using the nearley.js grammar (and parser) with the moo.js tokeniser. My grammar.ne file is the following: @{% const moo = require('moo') let lexer = moo.compile({ number:...

Where are the default snippets for C++ stored in VS Code?

So I've been using VS Code for a while now and I noticed that for some reason it started having extra snippets which I did not make come up in options, while they are useful I would like to edit...

How to set User to Login using Remember Me in Angular?

I want to set the 'Remember Me' in my Login page.I set the localstorage session but I think, I miss a part in the service file that's why my service didn't response. I try the...

How to use moo lexer (and nearley) with large files

I am trying to find something that will parse very large files (PGN files, basically.) I started using antlr4, but even though they claim that their classes are "streams", they aren't. antlr4...

Python3.8 JSON module not working on Ubuntu 20.04 LTS

File "/usr/lib/python3/dist-packages/jmespath/__init__.py", line 1, in <module> from jmespath import parser File "/usr/lib/python3/dist-packages/jmespath/parser.py", line 30, in <module> ...

Accessing tokenization of a C++ source file

My understanding is that one step of the compilation of a program (irrespective of the language, I guess) is parsing the source file into some kind of space separated tokens (this tokenization...

How do I initialize non-nullable members in a constructor body?

I've created my class in Dart this way, but I'm getting the Non-nullable instance field 'text' must be initialized. Try adding an initializer expression, or add a field initializer in this...

RangeError: WebAssembly.instantiate(): Out of memory: wasm memory

I am getting this error while starting my node js app in my cpanel. RangeError: WebAssembly.instantiate(): Out of memory: wasm memory at internal/deps/cjs-module-lexer/dist/lexer.js:1:33573 but...

How do I collect chars into a string in C?

I need to collect some chars into the buffer for my lexer, but I don't know how. I've read some answers on stackoverflow, but those are different cases. I have a while loop that reads next char...

PIP failed to build package cytoolz

I'm trying to install eth-brownie using 'pipx install eth-brownie' but I get an error saying pip failed to build package: cytoolz Some possibly relevant errors from pip install: ...