851 questions
Score of 0
9 answers
5912 views
In writing a scanner in C: is my approach right and optimal? Should I continue writing it in C? Any references or guidelines?
code for identifying header files
As you can see in the image, the scanner function is the main function which starts from the first character in the input till the end. if the identified character is ...
Score of 1
1 answer
72 views
Why am i getting an error when reading ";" 'SEMI tokens
This is a homework assignment so I'm only looking to get unstuck. We are tasked with filling out a parser and lexical analyzer. This was going fine until I ran into an issue reading ";".
As ...
Score of 0
1 answer
83 views
How do I use the "built-in" yyerror() function from flex/bison?
I created my own. It works fine. However, I want to use the default yyerror() function provided by flex/bison. I am using GNU C on Windows 11.
Score of 0
0 answers
90 views
How to match keywords as standalone words in Flex without capturing substrings?
I'm writing a flex lexer to recognize specific keywords only when they appear as standalone words (not as part of larger words). For example, if I'm looking for the keyword "in", it should ...
Score of 0
1 answer
99 views
How to pass a file pointer by reference for writing in a flex lexer?
I need help with a flex program. The program must analyze a string entered by the user and define if they are constants, identifiers, numerals or if there are no errors, these results need to be ...
Score of 0
0 answers
88 views
Azure AI Search - singular vs plural search terms
I have a search index in Azure AI Search using the newest version of the API (2024-07-01).
I have added searchable text fields with analyzer and synonymMaps. I am using the "en.microsoft" ...
Score of 0
1 answer
103 views
identify a comment between /* and */ that may contain */ inside of it only if it's inside ""
I am working on a lexical analyser but i am struggling on how to identify the comments as below:
A comment is a sequence of characters (even space) between /* and */; it may not contain the sub-...
Score of 0
1 answer
85 views
Error regarding my Python ANTLR parser code
I am trying to parse the contents of my test case files to output files to where the token type and the production rules are displayed.
My test case is this:
[* operator test *] = != > < <= =&...
Score of 0
0 answers
95 views
Syntactic or Lexical Error in writing an interpret
For a school project I have to write an interpret in C for programming languge similar to Swift. I'm encountering an issue in my code, and I'm not sure if it's a syntactic or lexical error. In the ...
Score of 0
1 answer
88 views
Parse an expression with non whitespace seperated operators
I am currently working on a compiler. Recently, I stumbled upon an issue concerning the parsing of operators in an expression. Obviously I have not found this to be an issue in other languages, which ...
Score of 0
0 answers
30 views
C Lexical Analyzer Bug: Pointer Value Reset [duplicate]
Description of the Problem
I am working on implementing a lexical analyzer in C, and I have encountered an issue with a pointer variable (pos) that seems to be behaving unexpectedly. The problem ...
Score of 1
1 answer
476 views
Creating a static unordered_set from keys of a static unordered_map
I'm writing a front-end for a compiler and currently working on implementing punctuator scanning functionality. I've got a Punctuator class that I'd like to use to represent punctuators from the input ...
Score of 0
1 answer
61 views
ANTLR 4 lexer rule to skip combination of backslash and newline?
WS : [ \t]+ -> skip ; // skip spaces, tabs
Works well to ignore white space by preventing those characters from reaching the parser. I want to do the same thing with character pair of '/' and ...
Score of 0
2 answers
243 views
Regex to remove Key/Value in a JSON Object
I have a JSON like below:
{"queueNumber": "123","field":"name",UserId":[12,12,34],"cur":[{"objectName":"test","...
Score of 2
1 answer
429 views
How does tokenization relates to formalism, lexical grammar, and regular language?
I am reading Bob Nystrom Crafting Compiler's and in the chapter 5 it says this
In the last chapter, the formalism we used for defining the lexical grammar—
the rules for how characters get grouped ...