lexical-analysis Questions

3

Solved

I was reading the answer to this question. I can't seem to find the answer to why someone would need a lexer separately Is it one of the steps a program goes through during compilation? Can some...
Snuffy asked 7/7, 2012 at 15:7

2

Solved

How, in C and C++ languages, can the compiler distinguish * when used as a pointer (MyClass* class) and when used as a multiply operator (a * b) or when is a dereferencing operator (*my_var)?
Cinthiacintron asked 8/10, 2020 at 7:28

2

Solved

I'm doing a lexer as a part of a university course. One of the brain teasers (extra assignments that don't contribute to the scoring) our professor gave us is how could we implement comments inside...
Heeled asked 5/10, 2020 at 14:37

5

Solved

int main() { i/*nt*/a = 10; return 0; } If I have the above code and I want to count the tokens, will it be 14 or 13 tokens? Is it valid to write a comment within a variable name? You can assume...
Usurer asked 27/8, 2020 at 4:14

4

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 wor...
Invoice asked 9/2, 2010 at 11:57

2

I want to understand how a transpiler works. The best to do this is to write one ofcourse. I've been looking into a few resources to understand how this works, theoretically. And i understand the ...

3

Solved

I know that C is not a context-free language, a famous example is: int foo; typedef int foo; foo x; In this case the lexer doesn't know, whether foo in the 3rd line, is an identifier, or typedef...
Laundress asked 23/5, 2017 at 17:45

4

Solved

I know question Lex and Yacc in PHP was asked before but 1 year ago. Is there any new mature PHP parser generator now? My searches drove me to the following ones, what do you think about the...
Forth asked 3/11, 2011 at 22:18

2

Solved

I understand the theory behind separating parser rules and lexer rules in theory, but what are the practical differences between these two statements in ANTLR: my_rule: ... ; MY_RULE: ... ; Do ...
Client asked 28/11, 2010 at 16:30

2

Solved

I try to make lemmatization, ie identifying the lemma and possibly the Arabic root of a verb, for example: يتصل ==> lemma (infinitive of the verb) ==> اتصل ==> root (triliteral root / Jidr thoulath...
Seldun asked 19/3, 2015 at 17:33

1

Solved

The lexical grammar of ECMAScript lists the following token classes for lexical analyzer (lexer): InputElementDiv:: WhiteSpace LineTerminator Comment CommonToken DivPunctuator RightBracePunc...

12

I'm trying to find out if there is a known algorithm that can detect the "key concept" of a sentence. The use case is as follows: User enters a sentence as a query (Does chicken taste like turke...
Greenberg asked 4/4, 2011 at 21:19

1

How does a simple 2 ++ 2 work behind the scenes in the Python language? If we type this in Python interpreter: >>> 2+++--2 4 >>> 2+++*2 File "<stdin>", line 1 2++*2 ^ S...

3

How should I do program in lex (or flex) for removing nested comments from text and print just the text which is not in comments? I should probably somehow recognize states when I am in comment and...
Laubin asked 17/10, 2012 at 20:56

3

I'm trying to write a lexer in JavaScript for finding tokens of a simple domain-specific language. I started with a simple implementation which just tries to match subsequent regexps from the curre...
Oft asked 23/5, 2014 at 22:59

5

Solved

Can someone tell me how I can install flex (lexical analyzer) on my Mac? I searched everywhere on google and I can't find it. I have the universal binary and I extracted it to my desktop but I have...
Melancholia asked 7/3, 2011 at 1:46

3

Solved

I want to pass the actual string of a token. If I have a token called ID, then I want my yacc file to actually know what ID is called. I thing I have to pass a string using yylval to the yacc file ...
Heteromerous asked 5/12, 2009 at 10:35

2

Introduction Looking at the documentation, ANTLR 2 used to have something called predicated lexing, with examples like this one (inspired by Pascal): RANGE_OR_INT : ( INT ".." ) => INT { $set...
Otranto asked 1/3, 2016 at 13:20

2

Solved

I am writing lex for a specific language where operations are carried out in prefix notation : (+ a b) --> (a + b) An integer is defined as follows : An integer can have a negative sign (–) bu...
Helix asked 13/2, 2016 at 23:44

7

Solved

I don't know a whole lot about C, but I understand the basics and as far as I can tell: int main() { if (1 == 1) printf("Hello World!\n"); return 0; } and int main() { if (1 == 1) printf(...
Abattoir asked 16/1, 2016 at 20:8

1

Solved

I'm using the Python module re to write regular expressions for lexical analysis. I've been looking for a comprehensive list of which special characters must be escaped in order to be recognized by...
Sigfrid asked 11/1, 2016 at 1:27

1

What does this instructions mean in flex (lex) : #define yywrap() 1 and this [ \t]+$ i find it in the code below: (%% [ \t]+ putchar('_'); [ \t]+% %% input "hello world" output "hello_world" ...
Consternation asked 27/12, 2015 at 11:19

2

Solved

I'm trying for the moment to keep my lexer and parser separate, based on the vague advice of the book Prolog and Natural Language Analysis, which really doesn't go into any detail about lexing/toke...
Janeth asked 14/12, 2015 at 23:5

7

Solved

I realize this is a broad topic, but I'm looking for a good primer on parsing meaning from text, ideally in Python. As an example of what I'm looking to do, if a user makes a blog post like: "Mann...
Empoverish asked 17/7, 2009 at 0:5

1

Solved

What is the meaning of yytext[0]? And why should we use in the lex and yacc program? I'm learner so don't mind if it is a silly question.
Intercommunicate asked 21/11, 2015 at 11:33

© 2022 - 2024 — McMap. All rights reserved.