<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:re="http://purl.org/atompub/rank/1.0">
    <title type="text">Newest questions tagged jflex - Stack Overflow</title>
    <link rel="self" href="https://stackoverflow.com/feeds/tag?tagnames=jflex&amp;sort=newest" type="application/atom+xml" />
    <link rel="alternate" href="https://stackoverflow.com/questions/tagged?tagnames=jflex&amp;sort=newest" type="text/html" />
    <subtitle>most recent 30 from stackoverflow.com</subtitle>
    <updated>2026-05-07T17:36:06Z</updated>
    <id>https://stackoverflow.com/feeds/tag?tagnames=jflex&amp;sort=newest</id>
    <creativeCommons:license>https://creativecommons.org/licenses/by-sa/4.0/rdf</creativeCommons:license> 
    <entry>
        <id>https://stackoverflow.com/q/79491993</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">how to represent full Unicode range in regexp in JFlex?</title>
            <category scheme="https://stackoverflow.com/tags" term="java" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>Vlad</name>
            <uri>https://stackoverflow.com/users/11582827</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/79491993/how-to-represent-full-unicode-range-in-regexp-in-jflex" />
        <published>2025-03-07T10:34:47Z</published>
        <updated>2025-03-07T10:34:47Z</updated>
        <summary type="html">
            &lt;p&gt;Is it possible in the current version of JFlex (1.9.1) to represent a range of full Unicode values in a regular expression ?&lt;/p&gt;&#xA;&lt;p&gt;Something like this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;UnicodeIdentifier = [a-zA-Z_\u007F-\u10FFFF] [a-zA-Z0-9_\u007F-\u10FFFF]*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;except this does not work (and makes JFlex emit a warning) because Unicode escape sequences in Java must be 16 bits in hexadecimal so the high end would be treated as &lt;code&gt;\u10FF&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;a href=&quot;https://docs.oracle.com/javase/specs/jls/se17/html/jls-3.html#jls-3.3&quot; rel=&quot;nofollow noreferrer&quot;&gt;spec&lt;/a&gt; says that &lt;em&gt;representing supplementary characters in the range U&#x2B;010000 to U&#x2B;10FFFF requires two consecutive Unicode escapes&lt;/em&gt; however using this:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-none prettyprint-override&quot;&gt;&lt;code&gt;UnicodeIdentifier = [a-zA-Z_\u007F-\uDBFF\uDFFF] [a-zA-Z0-9_\u007F-\uDBFF\uDFFF]*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;does not work either.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/79059424</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">JFlex recognition conflict</title>
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
            <category scheme="https://stackoverflow.com/tags" term="cup" />
        <author>
            <name>user27644245</name>
            <uri>https://stackoverflow.com/users/27644245</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/79059424/jflex-recognition-conflict" />
        <published>2024-10-06T15:19:06Z</published>
        <updated>2024-10-06T19:37:07Z</updated>
        <summary type="html">
            &lt;p&gt;I&#x27;m developing a lexical analyzer and parser using JFlex and CUP. I&#x2019;m running into a conflict in my lexer, and I&#x2019;m having trouble understanding why it&#x2019;s happening.&lt;/p&gt;&#xA;&lt;p&gt;Here&#x2019;s my lexer:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-java prettyprint-override&quot;&gt;&lt;code&gt;import java_cup.runtime.Symbol;&#xA;%%&#xA;%unicode&#xA;%cup&#xA;%line&#xA;%column&#xA;&#xA;%eof{&#xA;    System.out.println(&amp;quot;End of file&amp;quot;);&#xA;%eof}&#xA;&#xA;companyName = [A-Z][a-zA-Z0-9]*[0-9][a-zA-Z0-9]*&#xA;weekdays = Lundi|Mardi|Mercredi|Jeudi|Vendredi|Samedi|Dimanche|lundi|mardi|mercredi|jeudi|vendredi|samedi|dimanche&#xA;hours = [0-9]{1,2}h([0-9]{1,2})?&#xA;city = [A-Z][a-zA-Z -]&#x2B;&#xA;number = [0-9]&#x2B;&#xA;&#xA;%%&#xA;&#xA;Compagnie {&#xA;    System.out.println(&amp;quot;Compagnie&amp;quot;);&#xA;    return new Symbol(sym.COMPAGNIE);&#xA;}&#xA;&#xA;{companyName} {&#xA;    System.out.println(&amp;quot;Company name: &amp;quot; &#x2B; yytext());&#xA;    return new Symbol(sym.COMPANY_NAME, yytext());&#xA;}&#xA;&#xA;{weekdays} {&#xA;    System.out.println(&amp;quot;Weekday: &amp;quot; &#x2B; yytext());&#xA;    return new Symbol(sym.WEEKDAY, yytext());&#xA;}&#xA;&#xA;&amp;quot;au depart de&amp;quot; {&#xA;    System.out.println(&amp;quot;Departure&amp;quot;);&#xA;    return new Symbol(sym.DEPART);&#xA;}&#xA;&#xA;pour {&#xA;    System.out.println(&amp;quot;For&amp;quot;);&#xA;    return new Symbol(sym.FOR);&#xA;}&#xA;&#xA;par {&#xA;    System.out.println(&amp;quot;By&amp;quot;);&#xA;    return new Symbol(sym.BY);&#xA;}&#xA;&#xA;Fin {&#xA;    System.out.println(&amp;quot;End&amp;quot;);&#xA;    return new Symbol(sym.FIN);&#xA;}&#xA;&#xA;==== {&#xA;    System.out.println(&amp;quot;Separator&amp;quot;);&#xA;    return new Symbol(sym.SEPARATOR);&#xA;}&#xA;&#xA;: {&#xA;    System.out.println(&amp;quot;Colon&amp;quot;);&#xA;    return new Symbol(sym.COLON);&#xA;}&#xA;&#xA;car {&#xA;    System.out.println(&amp;quot;Car&amp;quot;);&#xA;    return new Symbol(sym.CAR);&#xA;}&#xA;&#xA;= {&#xA;    System.out.println(&amp;quot;Equal&amp;quot;);&#xA;    return new Symbol(sym.EQUAL);&#xA;}&#xA;&#xA;, {&#xA;    System.out.println(&amp;quot;Comma&amp;quot;);&#xA;    return new Symbol(sym.COMMA);&#xA;}&#xA;&#xA;&amp;quot;(&amp;quot; {&#xA;    System.out.println(&amp;quot;Open parenthesis&amp;quot;);&#xA;    return new Symbol(sym.OPEN_PARENTHESIS);&#xA;}&#xA;&#xA;&amp;quot;)&amp;quot; {&#xA;    System.out.println(&amp;quot;Close parenthesis&amp;quot;);&#xA;    return new Symbol(sym.CLOSE_PARENTHESIS);&#xA;}&#xA;&#xA;{hours} {&#xA;    System.out.println(&amp;quot;Hours: &amp;quot; &#x2B; yytext());&#xA;    return new Symbol(sym.HOURS, yytext());&#xA;}&#xA;&#xA;{number} {&#xA;    System.out.println(&amp;quot;Number: &amp;quot; &#x2B; yytext());&#xA;    return new Symbol(sym.NUMBER, Integer.parseInt(yytext()));&#xA;}&#xA;&#xA;{city} {&#xA;    System.out.println(&amp;quot;City: &amp;quot; &#x2B; yytext());&#xA;    return new Symbol(sym.CITY, yytext());&#xA;}&#xA;&#xA;[\n\t\r\s]&#x2B; {}  // Skip whitespace&#xA;&#xA;. {&#xA;    System.out.println(&amp;quot;Error: &amp;quot; &#x2B; yytext() &#x2B; &amp;quot; at line &amp;quot; &#x2B; yyline &#x2B; &amp;quot;, column &amp;quot; &#x2B; yycolumn);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here&#x2019;s the input I&#x2019;m testing:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Compagnie Bloblo007 au depart de Brest ====&#xA;Mardi :&#xA;    8h = car 2733 pour Nantes (par Quimper),&#xA;    15h10 = car 902 pour Rennes (par Morlaix, Saint-Brieuc, Montauban-de-Bretagne),&#xA;    09h00 = car 1203 pour Saint-Malo&#xA;&#xA;lundi :&#xA;    12h = car 80862 pour Landerneau,&#xA;    8h5 = car 70 pour Bordeaux (par Vannes, La Roche-Bernard, Nantes,&#xA;    La Roche-sur-Yon, Niort),&#xA;    15h15 = car 82019 pour Paris (par Quimper, Nantes)&#xA;&#xA;Fin&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The issue arises on the first line. Specifically, &lt;code&gt;Compagnie Bloblo007&lt;/code&gt; is not being correctly matched as &lt;code&gt;COMPAGNIE&lt;/code&gt; and &lt;code&gt;COMPANY_NAME&lt;/code&gt;. Instead, &lt;code&gt;Compagnie Bloblo&lt;/code&gt; is being recognized as a &lt;code&gt;CITY&lt;/code&gt; and &lt;code&gt;007&lt;/code&gt; as a &lt;code&gt;NUMBER&lt;/code&gt;. However, if I remove the &lt;code&gt;city&lt;/code&gt; and &lt;code&gt;number&lt;/code&gt; rules, &lt;code&gt;Compagnie&lt;/code&gt; and &lt;code&gt;companyName&lt;/code&gt; match correctly.&lt;/p&gt;&#xA;&lt;h3&gt;Question:&lt;/h3&gt;&#xA;&lt;p&gt;How can I adjust my lexer to correctly match the &lt;code&gt;Compagnie&lt;/code&gt; keyword and the entire company name (&lt;code&gt;Bloblo007&lt;/code&gt;) without mistakenly treating the text as a city or number?&lt;/p&gt;&#xA;&lt;p&gt;Thanks in advance for your help!&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/78289169</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Syntax fragment (include or import) in YACC</title>
            <category scheme="https://stackoverflow.com/tags" term="parsing" />
            <category scheme="https://stackoverflow.com/tags" term="yacc" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
            <category scheme="https://stackoverflow.com/tags" term="cup" />
        <author>
            <name>rfamm</name>
            <uri>https://stackoverflow.com/users/4114508</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/78289169/syntax-fragment-include-or-import-in-yacc" />
        <published>2024-04-07T20:18:26Z</published>
        <updated>2024-04-09T00:46:00Z</updated>
        <summary type="html">
            &lt;p&gt;Is it possible to include/import yacc fragment files from different files to a main YACC?&lt;/p&gt;&#xA;&lt;p&gt;Just to exemplify what I&#x27;m looking for, I would like to create 3 syntax parsers for 3 different files, but they&#x27;d share a common syntax block.&lt;/p&gt;&#xA;&lt;p&gt;So, I&#x27;d like to keep this syntax in only one yacc fragment file, so I could maintain it better.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/77091170</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">JFlex RE matching lookahead and precedence</title>
            <category scheme="https://stackoverflow.com/tags" term="regex" />
            <category scheme="https://stackoverflow.com/tags" term="xpath" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>keshlam</name>
            <uri>https://stackoverflow.com/users/3131203</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/77091170/jflex-re-matching-lookahead-and-precedence" />
        <published>2023-09-12T16:45:07Z</published>
        <updated>2023-09-12T22:26:59Z</updated>
        <summary type="html">
            &lt;p&gt;For XPath parsing, I need to distinguish the token type of &amp;quot;name&amp;quot; in the cases where it is followed by &amp;quot;::&amp;quot; (possibly after whitespace), followed by &amp;quot;(&amp;quot; (possibly after whitespace), or followed by neither.&lt;/p&gt;&#xA;&lt;p&gt;In JLex we did this with a routine that read ahead in the yy_* buffer, but that isn&#x27;t exposed in JFlex, and a lookahead RE should be a cleaner solution than handcoded lookahead.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately, my first attempt isn&#x27;t working as expected; it&#x27;s falling into the third category (standalone name) more often than I would have expected.&lt;/p&gt;&#xA;&lt;p&gt;What I&#x27;m trying is the following pattern, where &amp;quot;self&amp;quot; is the thing I&#x27;m trying to separate between the two cases. Please pardon the &amp;quot;GONK_&amp;quot; -- that&#x27;s my convention for debugging wrappers. And the wrappered newSymbol() is itself a wrapper for new Symbol() which has a side effect; sorry about that.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;self/\s*::&amp;quot;       { return GONK_newSymbol(sym.SELF); }&#xA;&amp;quot;self/\s*[(]&amp;quot;      { return GONK_newSymbol(sym.SELF); }&#xA;&amp;quot;self&amp;quot;             { return GONK_newSymbol(sym.QNAME,yytext()); }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;As I understand it, JFlex&#x27;s RE rules are &amp;quot;longest match wins, ties broken in favor of first match&amp;quot;, so I expected the lookaheads to take precedence. But putting a trace printout in the GONK_ functions tells me that the third case (sym.QNAME) is almost always being taken.&lt;/p&gt;&#xA;&lt;p&gt;I&#x27;m sure my error is obvious and I&#x27;m looking right at it, but... What did I miss?&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/76436743</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">How to set a package name for generated classes when using cup.gradle.cup-gradle-plugin?</title>
            <category scheme="https://stackoverflow.com/tags" term="gradle" />
            <category scheme="https://stackoverflow.com/tags" term="gradle-plugin" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
            <category scheme="https://stackoverflow.com/tags" term="cup" />
        <author>
            <name>Zhen</name>
            <uri>https://stackoverflow.com/users/8504216</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/76436743/how-to-set-a-package-name-for-generated-classes-when-using-cup-gradle-cup-gradle" />
        <published>2023-06-09T02:04:42Z</published>
        <updated>2023-06-11T09:41:59Z</updated>
        <summary type="html">
            &lt;p&gt;The cup arg: &lt;code&gt;-destdir&lt;/code&gt; does not work.&#xA;With or without this option, the generated source files (parser and symbols) always in the top folder (build/generated-src/cup).&lt;/p&gt;&#xA;&lt;p&gt;For example as below, the expected destination folder is &#x27;build/generated-src/cup/my/pkg&#x27; but actually it&#x27;s still &#x27;build/generated-src/cup&#x27;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cup {&#xA;   args = [&amp;quot;-destdir&amp;quot;, &amp;quot;build/generated-src/cup/my/pkg&amp;quot;, &amp;quot;-parser&amp;quot;, &amp;quot;my_parser&amp;quot;, &amp;quot;-symbols&amp;quot;, &amp;quot;my_sym&amp;quot;]&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The questions are:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;p&gt;How can I get the generated class in the right folder that matching the package name?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;p&gt;Is there a workaround to move the generated files by using a gradle task?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/75391125</id>
        <re:rank scheme="https://stackoverflow.com">-1</re:rank>
        <title type="text">How can I use JFlex if i&#xB4;m cloning a project from github [closed]</title>
            <category scheme="https://stackoverflow.com/tags" term="java" />
            <category scheme="https://stackoverflow.com/tags" term="github" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>Nicolas Bedoya</name>
            <uri>https://stackoverflow.com/users/20827745</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/75391125/how-can-i-use-jflex-if-i%c2%b4m-cloning-a-project-from-github" />
        <published>2023-02-08T19:57:48Z</published>
        <updated>2025-01-08T11:38:20Z</updated>
        <summary type="html">
            &lt;p&gt;i&#x27;m currently working on a Lexer in Java, i&#x27;m using jflex to do this, when my partner runs the code it works, he pushed it into a repo in github. I cloned it and when trying to run it, it says it cannot find a symbol which is Lexer, this is a class that jflex creates. I&lt;/p&gt;&#xA;&lt;p&gt;I was expecting to be able to use the jflex library, which is stored in the lib directory in the project, also, in the .vscode directory we created a settings.json in order to be able to use it, we thought it worked but apparently when someone clones the repo it doesn&#x27;t work. How can i solve this?&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/73155922</id>
        <re:rank scheme="https://stackoverflow.com">1</re:rank>
        <title type="text">JetBrains Language Support Plugin</title>
            <category scheme="https://stackoverflow.com/tags" term="intellij-idea" />
            <category scheme="https://stackoverflow.com/tags" term="plugins" />
            <category scheme="https://stackoverflow.com/tags" term="intellij-plugin" />
            <category scheme="https://stackoverflow.com/tags" term="bnf" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>Levan Apakidze</name>
            <uri>https://stackoverflow.com/users/13728460</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/73155922/jetbrains-language-support-plugin" />
        <published>2022-07-28T16:08:57Z</published>
        <updated>2023-05-06T19:30:16Z</updated>
        <summary type="html">
            &lt;p&gt;I am trying to implement language support plugin for a basic language. I am following jetbrains&#x27;s &lt;a href=&quot;https://plugins.jetbrains.com/docs/intellij/custom-language-support-tutorial.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;tutorial&lt;/a&gt; for simple language support (.properties file support basically) and on the side I have &lt;a href=&quot;https://github.com/intellij-rust/intellij-rust&quot; rel=&quot;nofollow noreferrer&quot;&gt;rust plugin&lt;/a&gt; for reference. However the complexity gap between them is huge so some questions are hard to find answers to from both sources.&lt;/p&gt;&#xA;&lt;p&gt;Here is my question: What is the best way to allow spaces between tokens which DO NOT require spaces, however force spacing between tokens which do?&lt;/p&gt;&#xA;&lt;p&gt;i.e. &lt;code&gt;class Foo{&lt;/code&gt; &amp;lt;- here first space is mandatory, but the second one (before &#x27;{&#x27; symbol) can be ommited.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/72711436</id>
        <re:rank scheme="https://stackoverflow.com">-1</re:rank>
        <title type="text">JFLEX regular expressions for string starts with</title>
            <category scheme="https://stackoverflow.com/tags" term="java" />
            <category scheme="https://stackoverflow.com/tags" term="regex" />
            <category scheme="https://stackoverflow.com/tags" term="flex-lexer" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>Mobinkh</name>
            <uri>https://stackoverflow.com/users/13143525</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/72711436/jflex-regular-expressions-for-string-starts-with" />
        <published>2022-06-22T07:39:47Z</published>
        <updated>2022-06-22T07:51:23Z</updated>
        <summary type="html">
            &lt;p&gt;I&#x27;m new with this jflex and regular expressions I read a lot even though I know I faced the solution in the manual but really I can&#x27;t understand these regular expressions. I want simple read a text file with jflex and return every line that starts with &lt;code&gt;name = &lt;/code&gt; or &lt;code&gt;name=&lt;/code&gt; but this was a pain for me for 1 week I&#x27;m reading all regular expressions in the jflex document but I can&#x27;t understand which one I can use to achieve it anyone can help me out? with jflex rules and any code to contain that?&lt;/p&gt;&#xA;&lt;p&gt;this is the example input and output&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;bla bla bla&#xA;bla bla bla&#xA;name=StackOverFlow&#xA;name = ThisIsGo&#xA;bla bla bla&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Output:&lt;/p&gt;&#xA;&lt;p&gt;StackOverFLow&lt;/p&gt;&#xA;&lt;p&gt;ThisIsGo&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/72703273</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Unexpected character JFLEX</title>
            <category scheme="https://stackoverflow.com/tags" term="compiler-construction" />
            <category scheme="https://stackoverflow.com/tags" term="lexical-analysis" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
            <category scheme="https://stackoverflow.com/tags" term="lexical" />
            <category scheme="https://stackoverflow.com/tags" term="jflex-maven-plugin" />
        <author>
            <name>coder123</name>
            <uri>https://stackoverflow.com/users/14002097</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/72703273/unexpected-character-jflex" />
        <published>2022-06-21T15:14:32Z</published>
        <updated>2022-06-21T15:33:31Z</updated>
        <summary type="html">
            &lt;p&gt;Hello i was watching a tutorial on youtube. It was the start of tutorial but when i tried to wrote the code and run this &lt;strong&gt;flex.l&lt;/strong&gt; file. The output show unexpected character  &lt;strong&gt;[a-z] {printf(&amp;quot;Single lowercase character\n&amp;quot;);}&lt;/strong&gt; . What should i do with this :(&lt;/p&gt;&#xA;&lt;p&gt;the youtube link  &lt;a href=&quot;https://www.youtube.com/watch?v=LpVufkH4gog&amp;amp;t=171s&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.youtube.com/watch?v=LpVufkH4gog&amp;amp;t=171s&lt;/a&gt;&#xA;time stamp 2:54&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   %{&#xA;    &#xA;     /* definitions*/&#xA;    &#xA;    %}&#xA;    &#xA;    /*rules*/&#xA;    &#xA;    %%&#xA;    &#xA;    [a-z] {printf(&amp;quot;Single lowercase character\n&amp;quot;);}&#xA;    . {printf(&amp;quot;Not a lowercase character\n&amp;quot;);}&#xA;    \n {return 0;}&#xA;    &#xA;    %%&#xA;    &#xA;    &#xA;    yywrap() {}&#xA;    &#xA;    int main() {&#xA;    &#xA;        printf(&amp;quot;Enter String:  &amp;quot;);&#xA;        yylex();&#xA;        &#xA;        return 0;&#xA;    &#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/72466138</id>
        <re:rank scheme="https://stackoverflow.com">-1</re:rank>
        <title type="text">Regular expression for email in flex</title>
            <category scheme="https://stackoverflow.com/tags" term="java" />
            <category scheme="https://stackoverflow.com/tags" term="lexical-analysis" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>coding2</name>
            <uri>https://stackoverflow.com/users/19090002</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/72466138/regular-expression-for-email-in-flex" />
        <published>2022-06-01T17:54:27Z</published>
        <updated>2022-06-01T18:38:50Z</updated>
        <summary type="html">
            &lt;p&gt;I am trying to wirte a regular expression for emails in JFlex. So far I tried with this&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;L=[a-zA-Z_]&#x2B;&#xA;D=[0-9]&#x2B;    &#xA;email=[^(.&#x2B;)@(\S&#x2B;)$]&#xA;%{&#xA;    public String lexeme;&#xA;%}&#xA;%%&#xA;{L}({L}|{D})* {lexeme=yytext(); return Identi;}&#xA;(&amp;quot;(-&amp;quot;{D}&#x2B;&amp;quot;)&amp;quot;)|{D}&#x2B; {lexeme=yytext(); return Number;}&#xA;{email} {lexeme=yytext(); return Email;}&#xA; . {return ERROR;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I test with an email, the lexer is not matching any email.&#xA;How to match email?&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/72164661</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Jflex ambiguity</title>
            <category scheme="https://stackoverflow.com/tags" term="compilation" />
            <category scheme="https://stackoverflow.com/tags" term="lexical-analysis" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>user14373483</name>
            <uri>https://stackoverflow.com/users/0</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/72164661/jflex-ambiguity" />
        <published>2022-05-08T19:58:20Z</published>
        <updated>2022-05-09T03:39:02Z</updated>
        <summary type="html">
            &lt;p&gt;I have these two rules from a jflex code:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-java prettyprint-override&quot;&gt;&lt;code&gt;Bool = true&#xA;Ident = [:letter:][:letterdigit:]*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;if I try for example to analyse the word &amp;quot;&lt;em&gt;trueStat&lt;/em&gt;&amp;quot;, it gets recognnized as an Ident expression and not Bool.&#xA;How can I avoid this type of ambiguity in Jflex?&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/71895140</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Why does my $1 operation not work with Java Bison?</title>
            <category scheme="https://stackoverflow.com/tags" term="java" />
            <category scheme="https://stackoverflow.com/tags" term="parsing" />
            <category scheme="https://stackoverflow.com/tags" term="bison" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>izash</name>
            <uri>https://stackoverflow.com/users/15590483</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/71895140/why-does-my-1-operation-not-work-with-java-bison" />
        <published>2022-04-16T15:23:01Z</published>
        <updated>2022-04-16T17:46:22Z</updated>
        <summary type="html">
            &lt;p&gt;When I have an abstract syntax tree in the Java Bison (.y) file with this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;string_op:&#xA;  SYMBOL_PLUS { $$ = $1; System.out.println(&amp;quot;this should print &#x2B; here: &amp;quot; &#x2B; $$);}&#xA;  | SYMBOL_DOUBLEEQ&#xA;  | SYMBOL_NOTEQ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I would expect it to print &amp;quot;this should print &#x2B; here:&#x2B;&amp;quot; whenever the parser comes across the &#x2B; token (i.e. SYMBOL_PLUS). However, I always get &amp;quot;this should print &#x2B; here:null&amp;quot;.&lt;/p&gt;&#xA;&lt;p&gt;I have already used the %type declarations and everything.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;%nterm &amp;lt;String&amp;gt; string_op&#xA;&#xA;%type&amp;lt;String&amp;gt; SYMBOL_PLUS&#xA;%type&amp;lt;String&amp;gt; RESERVED_BOOL&#xA;%type&amp;lt;String&amp;gt; RESERVED_STRING&#xA;%type&amp;lt;String&amp;gt; RESERVED_INT&#xA;%type&amp;lt;String&amp;gt; IDENTIFIER&#xA;%type&amp;lt;String&amp;gt; SYMBOL_DOUBLEEQ&#xA;%type&amp;lt;String&amp;gt; SYMBOL_NOTEQ&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It still gives the error. There is a massive lack of good, understandable, and clear documentation for java bison so it&#x27;s really frustrating. Please let me know if you can fix this issue. I&#x27;ve been on it for days.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/71680900</id>
        <re:rank scheme="https://stackoverflow.com">3</re:rank>
        <title type="text">JFlex complaining about caret character</title>
            <category scheme="https://stackoverflow.com/tags" term="java" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>beeblebrox</name>
            <uri>https://stackoverflow.com/users/18633904</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/71680900/jflex-complaining-about-caret-character" />
        <published>2022-03-30T16:31:29Z</published>
        <updated>2022-04-28T15:25:19Z</updated>
        <summary type="html">
            &lt;p&gt;I&#x27;m trying to produce a simple standalone scanner with the use of JFlex. What I want to do now is to simply recognize the beginning of a line with the use of the caret (&lt;code&gt;^&lt;/code&gt;) symbol.&lt;/p&gt;&#xA;&lt;p&gt;From the &lt;a href=&quot;https://jflex.de/manual.html#Semantics&quot; rel=&quot;nofollow noreferrer&quot;&gt;Semantics section of the user manual&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In a lexical rule, a regular expression r may be preceded by a ^ (the beginning of line operator).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This is my code right now:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// lexer.jflex&#xA;&#xA;%%&#xA;%standalone&#xA;%class Lexer&#xA;&#xA;beginning = ^&#xA;&#xA;%%&#xA;&#xA;{beginning}     { System.out.println(&amp;quot;beginning&amp;quot;); }&#xA;.                 { ; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The required behavior is very simple: it should only recognize the beginning of each input line and ignore everything else. However, for some reason, jflex complains about the caret symbol:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Error in file &amp;quot;lexer.jflex&amp;quot; (line 5):&#xA;Syntax error.&#xA;beginning = ^&#xA;            ^&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I also tried with some variations, for example with double quotes around the caret (&lt;code&gt;&amp;quot;^&amp;quot;&lt;/code&gt;) and escape character before it (&lt;code&gt;\^&lt;/code&gt;), but obviously this recognizes the caret symbol as a character itself, and not as a regular expression representing the beggining of a line.&lt;/p&gt;&#xA;&lt;p&gt;EDIT&lt;/p&gt;&#xA;&lt;p&gt;Problem solved: the caret symbol must not be used in the &lt;em&gt;options and macros&lt;/em&gt; section but instead in the &lt;em&gt;actions and rules&lt;/em&gt; section, i.e. the third one. For example, the following code matches the &lt;code&gt;#&lt;/code&gt; symbol at the beginning of a line:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// lexer.jflex&#xA;&#xA;%% &#xA;...&#xA;hash = &amp;quot;#&amp;quot;&#xA;&#xA;%%&#xA;&#xA;^{hash} { System.out.println(&amp;quot;hash found!&amp;quot;); }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/71538197</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Java Bison and Jflex error for redeclared/undeclared variables</title>
            <category scheme="https://stackoverflow.com/tags" term="parsing" />
            <category scheme="https://stackoverflow.com/tags" term="bison" />
            <category scheme="https://stackoverflow.com/tags" term="flex-lexer" />
            <category scheme="https://stackoverflow.com/tags" term="lexer" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>Chronicle</name>
            <uri>https://stackoverflow.com/users/18497248</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/71538197/java-bison-and-jflex-error-for-redeclared-undeclared-variables" />
        <published>2022-03-19T12:38:14Z</published>
        <updated>2022-03-21T07:04:10Z</updated>
        <summary type="html">
            &lt;p&gt;I am making a compiler with Jflex and Bison. Jflex does the lexical analysis. Bison does the parsing.&lt;/p&gt;&#xA;&lt;p&gt;The lexical analysis (in a .l file) is perfect. Tokenizes the input, and passes the input to the .y file for Bison to parse.&lt;/p&gt;&#xA;&lt;p&gt;I need the parser to print an error for redeclared/undeclared variables. My thought are that it would need some sort of memory to remember all the variables initialized so far, so that it can produce an error for those tokens coming in and when it sees an undeclared variable being used. For example, &#x27;&#x27;bool&amp;quot;, &amp;quot;test&amp;quot;, &amp;quot;=&amp;quot;, &amp;quot;true&amp;quot;, &amp;quot;;&amp;quot;, and on a new line, &amp;quot;test2&amp;quot;, &amp;quot;=&amp;quot;, &amp;quot;false&amp;quot;, &amp;quot;;&amp;quot;, the parser would need some sort of memory to remember &#x27;&#x27;test&amp;quot; and when it parses the second line it can access that memory again and say that &amp;quot;test2&amp;quot; is undeclared, hence it would print an error.&lt;/p&gt;&#xA;&lt;p&gt;What I&#x27;m confused about is how we can make a memory like that with bison using Java in the .y file. With C, you would use the -d flag and it would make 2 files with enum types and a header file which would keep track of the declared variables but in Java I&#x27;m not too sure if I can do the same as I can&#x27;t structure the grammar in any way so that it will remember variable names.&lt;/p&gt;&#xA;&lt;p&gt;I could make a symbol table in Java code to check for redeclared variables, but in the main() in the .y file I have&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; public static void main(String args[]) throws IOException {&#xA;    EXAMPLELexer lexer = new EXAMPLLexer(System.in);&#xA;    EXAMPLE parser = new EXAMPLE(lexer);&#xA;    if(parser.parse()){&#xA;      System.out.println(&amp;quot;VALID FROM PARSER&amp;quot;);&#xA;    }&#xA;    else{&#xA;      System.out.println(&amp;quot;ERROR FROM PARSER&amp;quot;);&#xA;    }&#xA;      &#xA;    return;&#xA;  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There is no way to get the tokens individually and pass them into another java instance or whatever.%union{} doesnt work with Java, so I dont know how this is even possible.&#xA;I can&#x27;t find a single piece of documentation explaining this so I would love some answers!&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/71518591</id>
        <re:rank scheme="https://stackoverflow.com">1</re:rank>
        <title type="text">How to make expression for grammar rule in Bison with Jflex</title>
            <category scheme="https://stackoverflow.com/tags" term="java" />
            <category scheme="https://stackoverflow.com/tags" term="parsing" />
            <category scheme="https://stackoverflow.com/tags" term="bison" />
            <category scheme="https://stackoverflow.com/tags" term="lex" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>Chronicle</name>
            <uri>https://stackoverflow.com/users/18497248</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/71518591/how-to-make-expression-for-grammar-rule-in-bison-with-jflex" />
        <published>2022-03-17T20:24:16Z</published>
        <updated>2023-09-07T11:20:38Z</updated>
        <summary type="html">
            &lt;p&gt;I&#x27;ve been trying to make a parser which takes tokens from a lexer (jflex), and ive used Java with bison for the parser. Here is my code so far for the parser:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;%define api.prefix {EXAMPLE}&#xA;%define api.parser.class {EXAMPLE}&#xA;%define api.parser.public&#xA;%define parse.error verbose&#xA;&#xA;%code imports{&#xA;  import java.io.InputStream;&#xA;  import java.io.InputStreamReader;&#xA;  import java.io.Reader;&#xA;  import java.io.IOException;&#xA;}&#xA;&#xA;%code {&#xA;  public static void main(String args[]) throws IOException {&#xA;    EXAMPLELexer lexer = new EXAMPLELexer(System.in);&#xA;    EXAMPLE parser = new EXAMPLE(lexer);&#xA;    if(parser.parse()){&#xA;      System.out.println(&amp;quot;VALID FROM PARSER&amp;quot;);&#xA;    }&#xA;    else{&#xA;      System.out.println(&amp;quot;ERROR FROM PARSER&amp;quot;);&#xA;    }&#xA;      &#xA;    return;&#xA;  }&#xA;}&#xA;&#xA;/* Bison Declarations */&#xA;%token &amp;lt;Integer&amp;gt; NUM&#xA;%type exp&#xA;%%&#xA;&#xA;input: line | input line;&#xA;line: &#x27;\n&#x27;&#xA;| exp &#x27;\n&#x27; { System.out.println($exp); }&#xA;| error &#x27;\n&#x27;&#xA;;&#xA;exp:&#xA; NUM { $$ = $1; }&#xA;| exp &#x27;=&#x27; exp { if ($1.intValue() != $3.intValue()) yyerror(&amp;quot;calc: error: &amp;quot; &#x2B; $1 &#x2B; &amp;quot; != &amp;quot; &#x2B; $3); }&#xA;| exp &#x27;&#x2B;&#x27; exp { $$ = $1 &#x2B; $3; }&#xA;| exp &#x27;-&#x27; exp { $$ = $1 - $3; }&#xA;| exp &#x27;*&#x27; exp { $$ = $1 * $3; }&#xA;| exp &#x27;/&#x27; exp { $$ = $1 / $3; }&#xA;| &#x27;-&#x27; exp %prec NEG { $$ = -$2; }&#xA;| exp &#x27;^&#x27; exp { $$ = (int) Math.pow($1, $3); }&#xA;| &#x27;(&#x27; exp &#x27;)&#x27; { $$ = $2; }&#xA;| &#x27;(&#x27; error &#x27;)&#x27; { $$ = 1111; }&#xA;| &#x27;!&#x27; { $$ = 0; return YYERROR; }&#xA;| &#x27;-&#x27; error { $$ = 0; return YYERROR; }&#xA;&#xA;%%&#xA;&#xA;class EXAMPLELexer implements EXAMPLE.Lexer {&#xA;  InputStreamReader it;&#xA;  Yylex yylex;&#xA;&#xA;  public EXAMPLELexer(InputStream is){&#xA;    it = new InputStreamReader(is);&#xA;    yylex = new Yylex(it);&#xA;  }&#xA;&#xA;  @Override&#xA;  public void yyerror (String s){&#xA;   &#xA;  }&#xA;&#xA;  @Override&#xA;  public Object getLVal() {&#xA;    return null;&#xA;  }&#xA;&#xA;  @Override&#xA;  public int yylex () throws IOException{&#xA;    return yylex.yylex();&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I try to use the jflex and bison commands I get this:&#xA;&lt;a href=&quot;https://i.sstatic.net/D0miV.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;$$ of &#x2018;exp&#x2019; has no declared type, same with $1, $3&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Please help, i&#x27;ve been stuck on this for a while! (p.s i&#x27;ve already tried %union{} and it just gave rise to more errors unfortunately, if you have any sample code that actually works with it, i&#x27;d love to learn as there seems to be a lack of documentation with Java and bison working with Jflex.)&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/71505109</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">How to use Jflex and Bison Together?</title>
            <category scheme="https://stackoverflow.com/tags" term="parsing" />
            <category scheme="https://stackoverflow.com/tags" term="bison" />
            <category scheme="https://stackoverflow.com/tags" term="flex-lexer" />
            <category scheme="https://stackoverflow.com/tags" term="lexer" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>izash</name>
            <uri>https://stackoverflow.com/users/15590483</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/71505109/how-to-use-jflex-and-bison-together" />
        <published>2022-03-16T22:47:26Z</published>
        <updated>2022-03-18T15:19:01Z</updated>
        <summary type="html">
            &lt;p&gt;I am really struggling to use Jflex and Bison together. For example, here&#x27;s some sample code:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://github.com/valecor95/bison-flex-jflex-examples/tree/master/Java/1_BalancedParentheses/BalPar1&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/valecor95/bison-flex-jflex-examples/tree/master/Java/1_BalancedParentheses/BalPar1&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;You run &lt;code&gt;make&lt;/code&gt;:&#xA;&lt;a href=&quot;https://i.sstatic.net/PZ1Dh.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/PZ1Dh.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It just makes a load of files, and then if I want to test to see if it succeeds with the parser (stuff in a file called test.txt), I just can&#x27;t. It&#x27;s forced to take in System.in. It&#x27;s really frustrating as there&#x27;s very little readable and simple documentation for JFLEX and bison.&lt;/p&gt;&#xA;&lt;p&gt;Any advice at all would be much appreciated.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/71204072</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Parsing grammar error with JCup and JFlex when run parser</title>
            <category scheme="https://stackoverflow.com/tags" term="java" />
            <category scheme="https://stackoverflow.com/tags" term="parsing" />
            <category scheme="https://stackoverflow.com/tags" term="lexer" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>Marco Osorio</name>
            <uri>https://stackoverflow.com/users/4173645</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/71204072/parsing-grammar-error-with-jcup-and-jflex-when-run-parser" />
        <published>2022-02-21T09:40:06Z</published>
        <updated>2022-02-21T12:16:37Z</updated>
        <summary type="html">
            &lt;p&gt;Continuing with the example that I am doing with JCup and JFlex &lt;a href=&quot;https://stackoverflow.com/questions/70627129/error-when-run-parsing-using-cup-and-jflex&quot;&gt;Error when run parsing using cup and jflex&lt;/a&gt;, I am getting an error when parsing the following statement.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Label(name=&amp;quot;Label1&amp;quot;, title=&amp;quot;Label title&amp;quot;);&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I don&#x27;t understand the reason for the error, but I have looked for examples of how it does it in java15.cup. I understand that it is not the same, but it seems to be an approximation.&#xA;When the Lexer is executed, when showing the tokens found by console, it does not print the COMMA token, I do not understand the reason if it has the same SEMMICOLON configuration.&#xA;I think there is something in the grammar that I don&#x27;t understand and so I ask for help to see if I can solve it or find another solution.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Macro declaration on jflex file&#xA;&#xA;LineTerminator = \r|\n|\r\n&#xA;InputCharacter = [^\r\n]&#xA;WhiteSpace     = {LineTerminator}&#x2B; | [ ,\t,\f]&#x2B;&#xA;&#xA;/* comments */&#xA;Comment = {TraditionalComment} | {EndOfLineComment} | {DocumentationComment}&#xA;&#xA;TraditionalComment   = &amp;quot;/*&amp;quot; [^*] ~&amp;quot;*/&amp;quot; | &amp;quot;/*&amp;quot; &amp;quot;*&amp;quot;&#x2B; &amp;quot;/&amp;quot;&#xA;// Comment can be the last line of the file, without line terminator.&#xA;EndOfLineComment     = &amp;quot;//&amp;quot; {InputCharacter}* {LineTerminator}?&#xA;DocumentationComment = &amp;quot;/**&amp;quot; {CommentContent} &amp;quot;*&amp;quot;&#x2B; &amp;quot;/&amp;quot;&#xA;CommentContent       = ( [^*] | \*&#x2B; [^/*] )*&#xA;&#xA;/* General identifiers */&#xA;Identifier          = [A-Za-z_$] [A-Za-z_$0-9]*&#xA;&#xA;StringConst         = \&amp;quot; ([^\&amp;quot;])* \&amp;quot;&#xA;&#xA;/*&#xA;    identifiers&#xA;*/&#xA;ComponentId     = \&amp;quot; {Identifier} \&amp;quot;&#xA;&#xA;/*&#xA;    string to assign values, title, etc&#xA;*/&#xA;StringLit           = {StringConst}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Some Terminal&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;[&amp;quot;             { return iSymbol(Token.LBRCKT.name(), Symbol.LBRCKT, yytext()); }&#xA;&amp;quot;]&amp;quot;             { return iSymbol(Token.RBRCKT.name(), Symbol.RBRCKT, yytext()); }&#xA;&amp;quot;;&amp;quot;             { return iSymbol(Token.SEMICOLON.name(), Symbol.SEMICOLON, yytext()); }&#xA;&amp;quot;,&amp;quot;             { return iSymbol(Token.COMMA.name(), Symbol.COMMA, yytext()); }&#xA;&amp;quot;.&amp;quot;             { return iSymbol(Token.DOT.name(), Symbol.DOT, yytext()); }&#xA;&amp;quot;=&amp;quot;             { return iSymbol(Token.ASSIGN.name(), Symbol.ASSIGN, yytext()); }&#xA;&amp;quot;:&amp;quot;             { return iSymbol(Token.COLON.name(), Symbol.COLON, yytext()); }&#xA;&amp;quot;(&amp;quot;             { return iSymbol(Token.LPAREN.name(), Symbol.LPAREN, yytext()); }&#xA;&amp;quot;)&amp;quot;             { return iSymbol(Token.RPAREN.name(), Symbol.RPAREN, yytext()); }&#xA;&amp;quot;{&amp;quot;             { return iSymbol(Token.LCBRACE.name(), Symbol.LCBRACE, yytext()); }&#xA;&amp;quot;}&amp;quot;             { return iSymbol(Token.RCBRACE.name(), Symbol.RCBRACE, yytext()); }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The grammar defined for the statement is as follows;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;name_property_def   ::= NAME ASSIGN STRING_ID ;&#xA;&#xA;title_property_def  ::= TITLE ASSIGN STRING_LIT ;&#xA;&#xA;&#xA;label_basic_declaration ::=&#xA;        IQ_LABEL LPAREN label_formal_parameter_list_opt RPAREN SEMICOLON &#xA;    ;&#xA;&#xA;label_formal_parameter_list_opt ::=&#xA;    |   label_formal_parameter_list&#xA;    ;&#xA;    &#xA;label_formal_parameter_list ::=&#xA;        label_formal_parameter_list COMMA label_formal_parameter&#xA;    |   label_formal_parameter&#xA;    ;&#xA;    &#xA;label_formal_parameter ::=&#xA;        name_property_def&#xA;    |   title_property_def&#xA;    ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;the values that go between parentheses are fixed, that is, they are the names of the &amp;quot;properties&amp;quot; that this object has.&#xA;I appreciate the help&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Lexer trace &#xA;Token: Symbol: LABEL (unknown:11/2(-1) - unknown:11/8(-1)) Label &#xA;Token: Symbol: LPAREN (unknown:11/9(-1) - unknown:11/9(-1)) (&#xA;Token: Symbol: NAME (unknown:11/10(-1) - unknown:11/13(-1)) name&#xA;Token: Symbol: ASSIGN (unknown:11/14(-1) - unknown:11/14(-1)) = &#xA;Token: Symbol: STRING_ID (unknown:11/15(-1) - unknown:11/24(-1)) &amp;quot;Label1&amp;quot;&#xA;Token: Symbol: TITLE (unknown:11/26(-1) - unknown:11/30(-1)) title&#xA;Token: Symbol: ASSIGN (unknown:11/31(-1) - unknown:11/31(-1)) = &#xA;Token: Symbol: STRING_LIT (unknown:11/32(-1) - unknown:11/46(-1)) &amp;quot;Label title&amp;quot;&#xA;Token: Symbol: RPAREN (unknown:11/47(-1) - unknown:11/47(-1)) )&#xA;Token: Symbol: SEMICOLON (unknown:11/48(-1) - unknown:11/48(-1)) ;&#xA;&#xA;# Initializing parser&#xA;# Current Symbol is #19&#xA;# Shift under term #19 to state #2&#xA;# Current token is Symbol: LPAREN (unknown:2/8(-1) - unknown:2/8(-1))&#xA;# Shift under term #3 to state #5&#xA;# Current token is Symbol: NAME (unknown:2/9(-1) - unknown:2/12(-1))&#xA;# Shift under term #33 to state #21&#xA;# Current token is Symbol: ASSIGN (unknown:2/13(-1) - unknown:2/13(-1))&#xA;# Shift under term #11 to state #25&#xA;# Current token is Symbol: STRING_ID (unknown:2/14(-1) - unknown:2/23(-1))&#xA;# Shift under term #15 to state #26&#xA;# Current token is Symbol: RPAREN (unknown:2/24(-1) - unknown:2/24(-1))&#xA;# Reduce with prod #10 [NT=6, SZ=3]&#xA;# Reduce rule: top state 5, lhs sym 6 -&amp;gt; state 40&#xA;# Goto state #40&#xA;# Reduce with prod #6 [NT=4, SZ=1]&#xA;# Reduce rule: top state 5, lhs sym 4 -&amp;gt; state 39&#xA;# Goto state #39&#xA;# Shift under term #4 to state #41&#xA;# Current token is Symbol: LCBRACE (unknown:2/26(-1) - unknown:2/26(-1))&#xA;# Reduce with prod #4 [NT=5, SZ=3]&#xA;# Reduce rule: top state 2, lhs sym 5 -&amp;gt; state 6&#xA;# Goto state #6&#xA;# Shift under term #5 to state #7&#xA;# Current token is Symbol: LABEL (unknown:11/2(-1) - unknown:11/8(-1))&#xA;# Shift under term #21 to state #9&#xA;# Current token is Symbol: LPAREN (unknown:11/9(-1) - unknown:11/9(-1))&#xA;# Shift under term #3 to state #15&#xA;# Current token is Symbol: NAME (unknown:11/10(-1) - unknown:11/13(-1))&#xA;# Shift under term #33 to state #21&#xA;# Current token is Symbol: ASSIGN (unknown:11/14(-1) - unknown:11/14(-1))&#xA;# Shift under term #11 to state #25&#xA;# Current token is Symbol: STRING_ID (unknown:11/15(-1) - unknown:11/24(-1))&#xA;# Shift under term #15 to state #26&#xA;# Current token is Symbol: TITLE (unknown:11/27(-1) - unknown:11/31(-1))&#xA;Compiler has detected a syntax error at line 0 column 0&#xA;# Attempting error recovery&#xA;# Finding recovery state on stack&#xA;# Pop stack by one, state was # 26&#xA;# Pop stack by one, state was # 25&#xA;# Pop stack by one, state was # 21&#xA;# Pop stack by one, state was # 15&#xA;# Pop stack by one, state was # 9&#xA;# Pop stack by one, state was # 7&#xA;# Pop stack by one, state was # 6&#xA;# Pop stack by one, state was # 2&#xA;# Pop stack by one, state was # 0&#xA;# No recovery state found on stack&#xA;# Error recovery fails&#xA;Couldn&#x27;t repair and continue parse for input symbol &amp;quot;TITLE&amp;quot; spanning from unknown:11/27(-1) to unknown:11/31(-1)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;It could be that the StringLit or ComponentId macro is causing the problem.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/71180011</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Jflex and CUP not working on vscode and mac</title>
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
            <category scheme="https://stackoverflow.com/tags" term="cup" />
        <author>
            <name>carlosdafield</name>
            <uri>https://stackoverflow.com/users/17028970</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/71180011/jflex-and-cup-not-working-on-vscode-and-mac" />
        <published>2022-02-18T21:24:58Z</published>
        <updated>2022-02-22T18:16:25Z</updated>
        <summary type="html">
            &lt;p&gt;I downloaded jflex by doing &lt;code&gt;brew install jflex&lt;/code&gt; everything worked the way it should.&lt;/p&gt;&#xA;&lt;p&gt;But now when I&#x27;m trying to make it work with &lt;code&gt;java_cup.runtime.*&lt;/code&gt;. And I keep getting the errors below&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Lexer.java:681: error: cannot find symbol&#xA;          { return new java_cup.runtime.Symbol(sym.EOF); }&#xA;                                               ^&#xA;  symbol:   variable sym&#xA;  location: class Lexer&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;My proffesor said,&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;&amp;quot;The Symbol class is&#xA;part of the parser (JavaCUP)&#x2019;s runtime jar file. You may use it in the lexer simply by&#xA;setting the classpath to include the jar file from JavaCUP and importing it&amp;quot;&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;So I made bash file below and did what he said and it is not working.&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-sh prettyprint-override&quot;&gt;&lt;code&gt;#!/bin/bash&#xA;jflex MiniJava.jflex&#xA;javac -cp &amp;quot;/Users/carlosfield/Desktop/School/csc453/java-cup-bin-11b-20160615/java-cup-11b.jar&amp;quot; Lexer.java&#xA;java -cp &amp;quot;/Users/carlosfield/Desktop/School/csc453/java-cup-bin-11b-20160615/java-cup-11b-runtime.jar&amp;quot;  Lexer Factorial.java&#xA;rm Lexer*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is my jflex file&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import java.util.*;&#xA;import java_cup.runtime.*;&#xA;%% &#xA;%class Lexer&#xA;%cup&#xA;%line&#xA;%column&#xA;%{&#xA;private Symbol symbol(int type) {&#xA;    return new Symbol(type, yyline, yycolumn);&#xA;}&#xA;private Symbol symbol(int type, Object value) { &#xA;    return new Symbol(type, yyline, yycolumn, value); &#xA;} &#xA;%} &#xA;WhiteSpace = [ \t\r\n]&#xA;Identifier = [a-zA-Z_][a-zA-Z0-9_]*&#xA;Integer = 0 | [1-9][0-9]* &#xA;%% &#xA;&#x201C;&#x2B;&#x201D; {  }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/71150773</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Jflex Regular expression for string with escaped characters</title>
            <category scheme="https://stackoverflow.com/tags" term="regex" />
            <category scheme="https://stackoverflow.com/tags" term="flex-lexer" />
            <category scheme="https://stackoverflow.com/tags" term="lex" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>izash</name>
            <uri>https://stackoverflow.com/users/15590483</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/71150773/jflex-regular-expression-for-string-with-escaped-characters" />
        <published>2022-02-16T23:53:30Z</published>
        <updated>2025-04-29T11:34:06Z</updated>
        <summary type="html">
            &lt;p&gt;I am generating lexical analyzer with JFLEX. I need to find all strings which containing escaped characters using regular expressions. I&#x27;m struggling with this. What could it be?&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/70627129</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Error when run parsing using cup and jflex</title>
            <category scheme="https://stackoverflow.com/tags" term="java" />
            <category scheme="https://stackoverflow.com/tags" term="abstract-syntax-tree" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
            <category scheme="https://stackoverflow.com/tags" term="cup" />
        <author>
            <name>Marco Osorio</name>
            <uri>https://stackoverflow.com/users/4173645</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/70627129/error-when-run-parsing-using-cup-and-jflex" />
        <published>2022-01-07T21:00:45Z</published>
        <updated>2022-01-10T16:17:32Z</updated>
        <summary type="html">
            &lt;p&gt;I am new to JFlex and CUP.&#xA;I am trying to do a simple example, but when I run the parser, it always gives the same error, it does not progress with the recognition of the statements.&#xA;I think the problem must be in the productions or rules.&#xA;I have defined as terminals the symbols that are always used in Java, for example:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;terminal LPAREN, RPAREN, RBRACE, LBRACE, LBRCKT, RBRCKT, COLON, SEMICOLON, ASSIGN, COMMA, DOT;&#xA;terminal PAGE, LABEL;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I define non-terminals as follows:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;nonterminal START_PAGE;&#xA;nonterminal page_body, page_body_declarations_opt, page_body_declarations, page_body_declaration;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The grammar like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;start with START_PAGE;&#xA;START_PAGE ::= PAGE page_body ;&#xA;&#xA;page_body ::= LBRACE page_body_declarations_opt RBRACE ;&#xA;page_body_declarations_opt ::= | page_body_declarations ;&#xA;page_body_declaration ;&#xA;page_body_declarations ::= page_body_declarations page_body_declaration ;&#xA;page_body_declaration ::= label_declaration ;&#xA;label_declaration ::= LABEL LPAREN RPAREN SEMICOLON ;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The input data or file contains the following from line 2:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;Page {&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I run the parser, I print the result of the lexer, then I run the parser getting the following result:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Token: # 2 Page&#xA;Token: # 51 {&#xA;Token: # 52}&#xA;Token: # 0&#xA;Compiler has detected a syntax error at line 2 column 8&#xA;Error in line 2, column 8: Couldn&#x27;t repair and continue parse&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The error is presented in the LBRACE.&lt;/p&gt;&#xA;&lt;p&gt;The version I am using for testing is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;lt;jflex.version&amp;gt;1.8.2&amp;lt;/jflex.version&amp;gt;&#xA;&amp;lt;cup.version&amp;gt;11b-20160615&amp;lt;/cup.version&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The general idea is:&lt;/p&gt;&#xA;&lt;p&gt;Define the page block and internally define other elements such as the label.&lt;/p&gt;&#xA;&lt;p&gt;I would be grateful if you would give me a hand to be able to carry out the example.&lt;/p&gt;&#xA;&lt;p&gt;The information that exists is very scarce for the definition of rules or productions and how the reductions in CUP should be made. All the examples that I have investigated are arithmetic expressions but I have not found more that can contribute to the resolution of the problem.&lt;/p&gt;&#xA;&lt;p&gt;This is my lexer file&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;// USER CODE&#xA;&#xA;package core;&#xA;&#xA;import java.io.Reader;&#xA;import java.io.FileReader;&#xA;import java.io.IOException;&#xA;import java.io.InputStream;&#xA;import java_cup.runtime.Symbol;&#xA;import java_cup.runtime.Scanner;&#xA;import java.nio.charset.StandardCharsets;&#xA;import java_cup.runtime.ComplexSymbolFactory;&#xA;import java_cup.runtime.ComplexSymbolFactory.Location;&#xA;import java_cup.runtime.ComplexSymbolFactory.ComplexSymbol;&#xA;&#xA;&#xA;/**&#xA; * Lexer class.&#xA; */&#xA;&#xA;%% /*----------------------------------------------------------*/&#xA;&#xA;%public&#xA;// Lexer class to generate&#xA;%class Lexer&#xA;%cupsym MSymbol&#xA;%function next_token&#xA;%implements MSymbol, Scanner&#xA;%type java_cup.runtime.Symbol&#xA;&#xA;%unicode&#xA;&#xA;%cupdebug&#xA;&#xA;%char&#xA;%full&#xA;&#xA;%line&#xA;%column&#xA;&#xA;%eofval{&#xA;    &#xA;    return mSymbol(MSymbol.EOF);&#xA;&#xA;%eofval}&#xA;&#xA;&#xA;/*--------------------------------------------------------------&#xA;    CODE COPIED INTO LEXER&#xA;  --------------------------------------------------------------*/&#xA;%{ &#xA;&#xA;    ComplexSymbolFactory symbolFactory;&#xA;    &#xA;    StringBuffer string = new StringBuffer();&#xA;&#xA;    public Lexer(Reader in, ComplexSymbolFactory sf){&#xA;        this(in);&#xA;        symbolFactory = sf;&#xA;    }&#xA;    &#xA;    private Symbol mSymbol(int type) {&#xA;        return new Symbol(type, yyline, yycolumn);&#xA;    }&#xA;    &#xA;    private Symbol mSymbol(int type, Object value) {&#xA;        return new Symbol(type, yyline, yycolumn, value);&#xA;    }&#xA;    private void error(String message) {&#xA;        System.out.println(&amp;quot;Error at line &amp;quot;&#x2B;(yyline&#x2B;1)&#x2B;&amp;quot;, column &amp;quot;&#x2B;(yycolumn&#x2B;1)&#x2B;&amp;quot; : &amp;quot; &#x2B; message);&#xA;    }&#xA;&#xA;%}&#xA;&#xA;/*--------------------------------------------------------------&#xA;    MACRO DECLARATIONS&#xA;  --------------------------------------------------------------*/&#xA;LineTerminator = \r|\n|\r\n&#xA;InputCharacter = [^\r\n]&#xA;//WhiteSpace     = {LineTerminator} | [\ ,\t,\f]&#xA;WhiteSpace     = [\ ,\t,\f,\t] | {LineTerminator}&#xA;&#xA;/* comments */&#xA;Comment = {TraditionalComment} | {EndOfLineComment} | {DocumentationComment}&#xA;&#xA;TraditionalComment   = &amp;quot;/*&amp;quot; [^*] ~&amp;quot;*/&amp;quot; | &amp;quot;/*&amp;quot; &amp;quot;*&amp;quot;&#x2B; &amp;quot;/&amp;quot;&#xA;// Comment can be the last line of the file, without line terminator.&#xA;EndOfLineComment     = &amp;quot;//&amp;quot; {InputCharacter}* {LineTerminator}?&#xA;DocumentationComment = &amp;quot;/**&amp;quot; {CommentContent} &amp;quot;*&amp;quot;&#x2B; &amp;quot;/&amp;quot;&#xA;CommentContent       = ( [^*] | \*&#x2B; [^/*] )*&#xA;&#xA;&#xA;%state STRING&#xA;&#xA;%% /*----------------------------------------------------------*/&#xA;&#xA;/* Keywords */&#xA;&#xA;&amp;lt;YYINITIAL&amp;gt; {&#xA;&#xA;/*-------------------------------------------------------------&#xA;    KEYWORDS&#xA;  -------------------------------------------------------------*/&#xA;    &amp;quot;Page&amp;quot;      { &#xA;                    return mSymbol(MSymbol.PAGE, yytext()); &#xA;                }&#xA;    &#xA;}   //------&amp;gt; End of Keywords&#xA;&#xA;&#xA;&amp;lt;YYINITIAL&amp;gt; {&#xA;    /* separators */&#xA;    &amp;quot;(&amp;quot;             { return mSymbol(MSymbol.LPAREN, yytext()); }&#xA;    &amp;quot;)&amp;quot;             { return mSymbol(MSymbol.RPAREN, yytext()); }&#xA;    &amp;quot;{&amp;quot;             { return mSymbol(MSymbol.RBRACE, yytext()); }&#xA;    &amp;quot;}&amp;quot;             { return mSymbol(MSymbol.LBRACE, yytext()); }&#xA;    &amp;quot;[&amp;quot;             { return mSymbol(MSymbol.LBRCKT, yytext()); }&#xA;    &amp;quot;]&amp;quot;             { return mSymbol(MSymbol.RBRCKT, yytext()); }&#xA;    &amp;quot;;&amp;quot;             { return mSymbol(MSymbol.SEMICOLON, yytext()); }&#xA;    &amp;quot;,&amp;quot;             { return mSymbol(MSymbol.COMMA, yytext()); }&#xA;    &amp;quot;.&amp;quot;             { return mSymbol(MSymbol.DOT, yytext()); }&#xA;    &amp;quot;=&amp;quot;             { return mSymbol(MSymbol.ASSIGN, yytext()); }&#xA;    &amp;quot;:&amp;quot;             { return mSymbol(MSymbol.COLON, yytext()); }&#xA;&#xA;    \&amp;quot;              { yybegin(STRING); string.setLength(0); }&#xA;    &#xA;&#xA;    /* WHITESPACE */&#xA;    {WhiteSpace}    { /* ignore */ }&#xA;&#xA;    /* comments */&#xA;    {Comment}       { /* ignore */ }&#xA;}&#xA;&#xA;&amp;lt;STRING&amp;gt; {&#xA;    \&amp;quot;              {   &#xA;                        yybegin(YYINITIAL);&#xA;                        return mSymbol(MSymbol.STRING_LITERAL, string.toString()); &#xA;                    }&#xA;    &#xA;}&#xA;&#xA;/* error fallback */&#xA;[^]                 { &#xA;                        this.error(&amp;quot;Illegal character [ &amp;quot; &#x2B; yytext() &#x2B; &amp;quot; ]&amp;quot;);&#xA;                    }&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When run the parser, the lexer detect tokens. I don&#x27;t know what happens with space.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Token: #2 Page&#xA;Token: #51 {&#xA;Token: #52 }&#xA;Token: #0 &#xA;Compiler has detected a syntax error at line 2 column 8&#xA;Error in line 2, column 8 : Couldn&#x27;t repair and continue parse&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The text &lt;em&gt;Couldn&#x27;t repair and continue parse&lt;/em&gt; is set by parser cup.&lt;/p&gt;&#xA;&lt;p&gt;This is the result when generating parser&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;------- CUP v0.11b 20160615 (GIT 4ac7450) Parser Generation Summary -------&#xA;  0 errors and 54 warnings&#xA;  62 terminals, 7 non-terminals, and 8 productions declared, &#xA;  producing 15 unique parse states.&#xA;  54 terminals declared but not used.&#xA;  0 non-terminals declared but not used.&#xA;  0 productions never reduced.&#xA;  0 conflicts detected (0 expected).&#xA;  Code written to &amp;quot;Parser.java&amp;quot;, and &amp;quot;MSymbol.java&amp;quot;.&#xA;---------------------------------------------------- (CUP v0.11b 20160615 (GIT 4ac7450))&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Code to run parser&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    ComplexSymbolFactory csf = new ComplexSymbolFactory();&#xA;    Lexer lexer = new Lexer(new BufferedReader(new FileReader(args[0], StandardCharsets.UTF_8)), csf);&#xA;    ScannerBuffer lxrBuff = new ScannerBuffer(lexer);&#xA;    Parser mParser = new Parser(lxrBuff, csf);&#xA;    mParser.parse();&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Thanks in advance&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/70137182</id>
        <re:rank scheme="https://stackoverflow.com">1</re:rank>
        <title type="text">Regular expressions representing BNF</title>
            <category scheme="https://stackoverflow.com/tags" term="regex" />
            <category scheme="https://stackoverflow.com/tags" term="compiler-construction" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>komal khan</name>
            <uri>https://stackoverflow.com/users/17525630</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/70137182/regular-expressions-representing-bnf" />
        <published>2021-11-27T17:33:39Z</published>
        <updated>2021-11-27T19:19:38Z</updated>
        <summary type="html">
            &lt;p&gt;I am working on a lexer. I need to identify patterns in BNF and specify them using Regular expressions. I know there are TOKENS  e.g. keywords, identifiers, operators etc. So far I have defined Regular expressions:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; digit=[0-9]&#xA;    integer={digit}&#x2B;&#xA;    letter=[a-zA-Z]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;But the given BNF rule for Identifier is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;   &amp;lt; id &amp;gt; ::= &amp;lt; letter &amp;gt;&#xA;                | &amp;quot;_&amp;quot;&#xA;                | &amp;lt; id &amp;gt; &amp;lt; digit &amp;gt;&#xA;                | &amp;lt; id &amp;gt; &amp;lt; letter &amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Since the &amp;lt;id&amp;gt; is defined by Recursive pattern, how can I express this pattern using Regular expression.&#xA;I tried this Regular expression: &lt;code&gt;id={letter}&#x2B;|&amp;quot;_&amp;quot;|{id}{digit}&#x2B;&lt;/code&gt; for the above BNF rule but it is giving me error that Regular expression contains cycle.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/69603028</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">check if condition is met before executing the action in JFlex</title>
            <category scheme="https://stackoverflow.com/tags" term="flex-lexer" />
            <category scheme="https://stackoverflow.com/tags" term="lexer" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>mrjamaisvu</name>
            <uri>https://stackoverflow.com/users/14217346</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/69603028/check-if-condition-is-met-before-executing-the-action-in-jflex" />
        <published>2021-10-17T09:39:06Z</published>
        <updated>2021-10-17T11:06:08Z</updated>
        <summary type="html">
            &lt;p&gt;I am writing a lexical analyzer using JFlex. When the word &lt;code&gt;co&lt;/code&gt; is matched, we have to ignore what comes after until the end of the line (because it&#x27;s a comment). For the moment, I have a boolean variable that changes to &lt;code&gt;true&lt;/code&gt; whenever this word is matched and if an identifier or an operator is matched after &lt;code&gt;co&lt;/code&gt; until the end of the line, I simply ignore it because I have an &lt;code&gt;if&lt;/code&gt; condition in my &lt;code&gt;Identifier&lt;/code&gt; and &lt;code&gt;Operator&lt;/code&gt; token identification.&lt;br /&gt;&#xA;I am wondering if there is better way to do this and get rid of this &lt;code&gt;if&lt;/code&gt; statement that appears everywhere?&lt;/p&gt;&#xA;&lt;p&gt;Here is the code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;%% // Options of the scanner&#xA;&#xA;%class Lexer     &#xA;%unicode        &#xA;%line      &#xA;%column      &#xA;%standalone &#xA;&#xA;%{&#xA;    private boolean isCommentOpen = false;&#xA;    private void toggleIsCommentOpen() {&#xA;        this.isCommentOpen = ! this.isCommentOpen;&#xA;    }&#xA;    private boolean getIsCommentOpen() {&#xA;        return this.isCommentOpen;&#xA;    }&#xA;%} &#xA;&#xA;Operators           = [\&#x2B;\-]&#xA;Identifier          = [A-Z]*&#xA;&#xA;EndOfLine           = \r|\n|\r\n&#xA;&#xA;%%&#xA;{Operators}         {&#xA;                        if (! getIsBlockCommentOpen() &amp;amp;&amp;amp; ! getIsCommentOpen()) {&#xA;                            // Do Code&#xA;                        }&#xA;                    }  &#xA; &#xA;{Identifier}        {&#xA;                        if (! getIsBlockCommentOpen() &amp;amp;&amp;amp; ! getIsCommentOpen()) {&#xA;                            // Do Code&#xA;                        }&#xA;                    }&#xA;&#xA;&amp;quot;co&amp;quot;                {&#xA;                        toggleIsCommentOpen();&#xA;                    }&#xA;&#xA;.                   {}&#xA;&#xA;{EndOfLine}         {&#xA;                        if (getIsCommentOpen()) {&#xA;                            toggleIsCommentOpen();&#xA;                        }&#xA;                    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/68963182</id>
        <re:rank scheme="https://stackoverflow.com">-2</re:rank>
        <title type="text">JFlex - lex structured document</title>
            <category scheme="https://stackoverflow.com/tags" term="flex-lexer" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>LppEdd</name>
            <uri>https://stackoverflow.com/users/1392277</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/68963182/jflex-lex-structured-document" />
        <published>2021-08-28T09:50:26Z</published>
        <updated>2021-08-29T01:49:16Z</updated>
        <summary type="html">
            &lt;p&gt;The following image represents code that I need to lex.&lt;br /&gt;&#xA;The document has the following format (in columns term):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; 1 -  5:     comment&#xA; 6 - 79:     actual code&#xA;80 - ..:     comment&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.sstatic.net/0SdlM.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/0SdlM.png&quot; alt=&quot;RPG free-form code&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;If I only had to lex the middle part, there would be no issues at all.&lt;br /&gt;&#xA;Unfortunately, the initial and terminating comment are always present in the document.&lt;/p&gt;&#xA;&lt;p&gt;Any ideas on how this could be implemented?&lt;br /&gt;&#xA;I was thinking about implementing a two-phases lexer, but my thoughts are a bit confused still.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/68560856</id>
        <re:rank scheme="https://stackoverflow.com">1</re:rank>
        <title type="text">Highlight / parse PSI elements inside another PSI element</title>
            <category scheme="https://stackoverflow.com/tags" term="parsing" />
            <category scheme="https://stackoverflow.com/tags" term="intellij-plugin" />
            <category scheme="https://stackoverflow.com/tags" term="bnf" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>schmidt9</name>
            <uri>https://stackoverflow.com/users/3004003</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/68560856/highlight-parse-psi-elements-inside-another-psi-element" />
        <published>2021-07-28T12:58:51Z</published>
        <updated>2021-07-28T12:58:51Z</updated>
        <summary type="html">
            &lt;p&gt;I developed a Custom Language plugin based on this &lt;a href=&quot;https://plugins.jetbrains.com/docs/intellij/custom-language-support-tutorial.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;this tutorial&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;My plugin parses key/value language files with format like below. Values can contain some HTML tags like &lt;code&gt;&amp;lt;br&amp;gt;, &amp;lt;i&amp;gt;, &amp;lt;b&amp;gt;, &amp;lt;span&amp;gt;&lt;/code&gt; and &lt;code&gt;\n&lt;/code&gt;. So I want to highlight these tags as separate PSI elements inside green PSI elements (values) (see pic). How can I overwrite my rules to get this?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#Section header&#xA;&#xA;KEY1 = First&amp;lt;br&amp;gt;Value&#xA;KEY2 = Second\nValue&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.sstatic.net/2fIur.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/2fIur.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Bnf rules I use&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;lngFile ::= item_*&#xA;&#xA;private item_ ::= (property|header|COMMENT|CRLF)&#xA;&#xA;property ::= (KEY? SEPARATOR VALUE?) | KEY {&#xA;  mixin=&amp;quot;someClass&amp;quot;&#xA;  implements=&amp;quot;someClass&amp;quot;&#xA;  methods=[getKey getValue getName setName getNameIdentifier getPresentation]&#xA;}&#xA;&#xA;header ::= HEADER {&#xA;  mixin=&amp;quot;someClass&amp;quot;&#xA;  implements=&amp;quot;someClass&amp;quot;&#xA;  methods=[getName setName getNameIdentifier getPresentation]&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Flex&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;%%&#xA;&#xA;%class LngLexer&#xA;%implements FlexLexer&#xA;%unicode&#xA;%function advance&#xA;%type IElementType&#xA;%eof{  return;&#xA;%eof}&#xA;&#xA;CRLF=\R&#xA;WHITE_SPACE=[\ \n\t\f]&#xA;FIRST_VALUE_CHARACTER=[^ \n\f\\] | &amp;quot;\\&amp;quot;{CRLF} | &amp;quot;\\&amp;quot;.&#xA;VALUE_CHARACTER=[^\n\f\\] | &amp;quot;\\&amp;quot;{CRLF} | &amp;quot;\\&amp;quot;.&#xA;END_OF_LINE_COMMENT=(&amp;quot;//&amp;quot;)[^\r\n]*&#xA;HEADER=(&amp;quot;#&amp;quot;)[^\r\n]*&#xA;SEPARATOR=[:=]&#xA;KEY_CHARACTER=[^:=\ \n\t\f\\] | &amp;quot;\\ &amp;quot;&#xA;&#xA;%state WAITING_VALUE&#xA;&#xA;%%&#xA;&#xA;&amp;lt;YYINITIAL&amp;gt; {END_OF_LINE_COMMENT}                           { yybegin(YYINITIAL); return LngTypes.COMMENT; }&#xA;&#xA;&amp;lt;YYINITIAL&amp;gt; {HEADER}                                        { yybegin(YYINITIAL); return LngTypes.HEADER; }&#xA;&#xA;&amp;lt;YYINITIAL&amp;gt; {KEY_CHARACTER}&#x2B;                                { yybegin(YYINITIAL); return LngTypes.KEY; }&#xA;&#xA;&amp;lt;YYINITIAL&amp;gt; {SEPARATOR}                                     { yybegin(WAITING_VALUE); return LngTypes.SEPARATOR; }&#xA;&#xA;&amp;lt;WAITING_VALUE&amp;gt; {CRLF}({CRLF}|{WHITE_SPACE})&#x2B;               { yybegin(YYINITIAL); return TokenType.WHITE_SPACE; }&#xA;&#xA;&amp;lt;WAITING_VALUE&amp;gt; {WHITE_SPACE}&#x2B;                              { yybegin(WAITING_VALUE); return TokenType.WHITE_SPACE; }&#xA;&#xA;&amp;lt;WAITING_VALUE&amp;gt; {FIRST_VALUE_CHARACTER}{VALUE_CHARACTER}*   { yybegin(YYINITIAL); return LngTypes.VALUE; }&#xA;&#xA;({CRLF}|{WHITE_SPACE})&#x2B;                                     { yybegin(YYINITIAL); return TokenType.WHITE_SPACE; }&#xA;&#xA;[^]                                                         { return TokenType.BAD_CHARACTER; }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/67661631</id>
        <re:rank scheme="https://stackoverflow.com">1</re:rank>
        <title type="text">Explanation of JFlex Block Comment rule</title>
            <category scheme="https://stackoverflow.com/tags" term="flex-lexer" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>Elizabeth Fransen</name>
            <uri>https://stackoverflow.com/users/9366856</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/67661631/explanation-of-jflex-block-comment-rule" />
        <published>2021-05-23T15:48:49Z</published>
        <updated>2021-05-23T20:49:25Z</updated>
        <summary type="html">
            &lt;p&gt;I was looking on how to implement block comments in JFlex for custom language support in intellij and found that it can be described as&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;quot;/*&amp;quot; !([^]* &amp;quot;*/&amp;quot; [^]*) (&amp;quot;*/&amp;quot;)?&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I don&#x27;t quite understand how to read this and would like it if it were explained in plain English.&lt;/p&gt;&#xA;&lt;p&gt;At the moment I&#x27;m reading this as&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;first expect a &lt;code&gt;/*&lt;/code&gt; then&lt;/li&gt;&#xA;&lt;li&gt;expect not&#xA;&lt;ul&gt;&#xA;&lt;li&gt;any character? (Not sure why they used &lt;code&gt;[^]&lt;/code&gt;) zero or more times&lt;/li&gt;&#xA;&lt;li&gt;followed &lt;code&gt;*/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Any character zero or more&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;An optional &lt;code&gt;*/&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/67558980</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">JFlex maximum read length</title>
            <category scheme="https://stackoverflow.com/tags" term="flex-lexer" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>LppEdd</name>
            <uri>https://stackoverflow.com/users/1392277</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/67558980/jflex-maximum-read-length" />
        <published>2021-05-16T16:15:55Z</published>
        <updated>2021-05-17T03:53:45Z</updated>
        <summary type="html">
            &lt;p&gt;Given a positional language like the old &lt;a href=&quot;https://en.wikipedia.org/wiki/IBM_RPG&quot; rel=&quot;nofollow noreferrer&quot;&gt;IBM RPG&lt;/a&gt;, we can have a line such as&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;CCCCCDIDENTIFIER     E S             10&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Where characters&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt; 1-5:  comment&#xA;   6:  specification type&#xA;7-21:  identifier name&#xA;...And so on&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Now, given that JFlex is based on RegExp, we would have a RegExp such as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[a-zA-Z][a-zA-Z0-9]{0,14} {0,14}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;for the &lt;code&gt;identifier name&lt;/code&gt; token.&lt;br /&gt;&#xA;This RegExp however &lt;strong&gt;can match tokens longer than the 15 characters&lt;/strong&gt; possible for &lt;code&gt;identifier name&lt;/code&gt;, requiring &lt;code&gt;yypushback&lt;/code&gt;s.&lt;/p&gt;&#xA;&lt;p&gt;Thus, is there a way to limit how many characters JFlex reads for a particular token?&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/67377172</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Ambiguous Context-free grammar? / Shift/Reduce conflict in CUP</title>
            <category scheme="https://stackoverflow.com/tags" term="parsing" />
            <category scheme="https://stackoverflow.com/tags" term="compiler-construction" />
            <category scheme="https://stackoverflow.com/tags" term="grammar" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
            <category scheme="https://stackoverflow.com/tags" term="cup" />
        <author>
            <name>R&#xF4;mulo Borges</name>
            <uri>https://stackoverflow.com/users/8136917</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/67377172/ambiguous-context-free-grammar-shift-reduce-conflict-in-cup" />
        <published>2021-05-03T23:59:02Z</published>
        <updated>2021-05-04T02:50:59Z</updated>
        <summary type="html">
            &lt;p&gt;I have the following context-free grammar for a simplified version of C&#x2B;&#x2B;. When I run it with JFLEX and CUP I get a list of errors like that:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Warning : *** Reduce/Reduce conflict found in state #173&#xA;  between especificador ::= (*) &#xA;  and     programa ::= (*) &#xA;  under symbols: {VOID, CHAR, FLOAT, DOUBLE, SIGNED, UNSIGNED, INT, SHORT, LONG}&#xA;  Resolved in favor of the second production.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I think the problem is with instrucoesIf but I can&#x27;t figure it out&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;start with programa;&#xA;&#xA;programa ::= especificador tipo ID programa2 | DEFINE ID num CRLF programa | ; verificar depois o ERRO&#xA;especificador ::= AUTO | STATIC | EXTERN | CONST | ;&#xA;tipo ::= VOID | CHAR | FLOAT | DOUBLE | SIGNED inteiro | UNSIGNED inteiro | inteiro;&#xA;&#xA;inteiro ::= SHORT | INT | LONG;&#xA;programa2 ::= SEMICOLON programa | LBRACK num RBRACK SEMICOLON programa | LPAREN listaParametros RPAREN bloco programa | COMMA listaID programa;&#xA;&#xA;listaID ::= ID declaracaoParam2 listaIDTail;&#xA;listaIDTail ::= SEMICOLON | COMMA listaID;&#xA;listaParametros ::= listaParamRestante | ;&#xA;listaParamRestante ::= declaracaoParam declParamRestante;&#xA;declaracaoParam ::= tipo ID declaracaoParam2;&#xA;declaracaoParam2 ::= LBRACK num RBRACK | ;&#xA;declParamRestante ::= COMMA listaParamRestante | ;&#xA;bloco ::= LBRACE conjuntoInst RBRACE | SEMICOLON conjuntoInst ;&#xA;conjuntoInst ::= programa conjuntoInst | instrucoes conjuntoInst | ;&#xA;instrucoes ::= ID expressao SEMICOLON | RETURN expr SEMICOLON | PRINTF LPAREN expr RPAREN SEMICOLON | SCANF LPAREN ID RPAREN SEMICOLON | BREAK SEMICOLON | IF LPAREN expr RPAREN instrucoes instrucoesIf;&#xA;&#xA;instrucoesIf ::= ELSE instrucoes | ;&#xA;expressao ::= atribuicao | LBRACK expr RBRACK atribuicao | LPAREN exprList RPAREN | ;&#xA;atribuicao ::= operadorAtrib expr;&#xA;operadorAtrib ::= EQ | MULTEQ | DIVEQ | MODEQ | PLUSEQ | MINUSEQ;&#xA;expr ::= exprAnd exprOr;&#xA;exprList ::= expr exprListTail | ;&#xA;exprListTail ::= COMMA exprList | ;&#xA;exprOr ::= OR exprAnd exprOr | ;&#xA;exprAnd ::= exprEqual exprAnd2;&#xA;exprAnd2 ::= AND exprEqual exprAnd2 | ;&#xA;exprEqual ::= exprRelational exprEqual2;&#xA;exprEqual2 ::= EQEQ exprRelational exprEqual2 | NOTEQ exprRelational exprEqual2 | ;&#xA;exprRelational ::= exprPlus exprRelational2;&#xA;exprRelational2 ::= LT exprPlus exprRelational2 | LTEQ exprPlus exprRelational2 | GT exprPlus exprRelational2 | GTEQ exprPlus exprRelational2 | ;&#xA;&#xA;exprPlus ::= exprMult exprPlus2;&#xA;exprPlus2 ::= PLUS exprMult exprPlus2 | MINUS exprMult exprPlus2 | ;&#xA;exprMult ::= exprUnary exprMult2;&#xA;exprMult2 ::= MULT exprUnary exprMult2 | DIV exprUnary exprMult2 | ;&#xA;exprUnary ::= PLUS exprParenthesis | MINUS exprParenthesis | exprParenthesis;&#xA;exprParenthesis ::= LPAREN expr RPAREN | primary;&#xA;primary ::= ID primaryID | num | literal;&#xA;primaryID ::= LBRACK primary RBRACK | LPAREN exprList RPAREN | ;&#xA;&#xA;literal ::= STRING | CHAR;&#xA;num ::= NUM_INT | NUM_FLOAT;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/67094598</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">OCaml parser for ANTLR or JFlex</title>
            <category scheme="https://stackoverflow.com/tags" term="ocaml" />
            <category scheme="https://stackoverflow.com/tags" term="antlr" />
            <category scheme="https://stackoverflow.com/tags" term="antlr4" />
            <category scheme="https://stackoverflow.com/tags" term="lexer" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>Nathan Fallet</name>
            <uri>https://stackoverflow.com/users/8261566</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/67094598/ocaml-parser-for-antlr-or-jflex" />
        <published>2021-04-14T15:25:23Z</published>
        <updated>2021-04-14T15:25:23Z</updated>
        <summary type="html">
            &lt;p&gt;I&#x27;m looking for grammar files of the OCaml language written in ANTLR4 or JFlex.&lt;/p&gt;&#xA;&lt;p&gt;If they already exist somewhere, where I can find them? Else, how can I generate or write one of them by myself?&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/67083803</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Is there an alternative to \b and/or negative lookahead for JFLEX?</title>
            <category scheme="https://stackoverflow.com/tags" term="java" />
            <category scheme="https://stackoverflow.com/tags" term="regex" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
            <category scheme="https://stackoverflow.com/tags" term="word-boundary" />
        <author>
            <name>JoseSG</name>
            <uri>https://stackoverflow.com/users/10341204</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/67083803/is-there-an-alternative-to-b-and-or-negative-lookahead-for-jflex" />
        <published>2021-04-13T23:59:12Z</published>
        <updated>2021-04-14T13:30:37Z</updated>
        <summary type="html">
            &lt;p&gt;I am building a Scanner and can&#x27;t seem to find a way to identify operators like &amp;quot;if&amp;quot; or &amp;quot;else&amp;quot; using JFlex &amp;amp; Regex. Since JFlex &lt;em&gt;doesn&#x27;t fully conform&lt;/em&gt; I can&#x27;t use word-boundary or (?&amp;lt;=\s|^) &#x2B; (?=\s|$) because neither ? or $ are allowed.&#xA;The idea is to find the correctly written operators not ifo or elso. Thanks in advance.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/66934058</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Jflex get input filename</title>
            <category scheme="https://stackoverflow.com/tags" term="java" />
            <category scheme="https://stackoverflow.com/tags" term="compiler-construction" />
            <category scheme="https://stackoverflow.com/tags" term="filenames" />
            <category scheme="https://stackoverflow.com/tags" term="jflex" />
        <author>
            <name>Heinrich</name>
            <uri>https://stackoverflow.com/users/13128763</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/66934058/jflex-get-input-filename" />
        <published>2021-04-03T17:34:02Z</published>
        <updated>2021-04-08T22:08:52Z</updated>
        <summary type="html">
            &lt;p&gt;In Jflex, how does one extract the input filename?&lt;/p&gt;&#xA;&lt;p&gt;DisplayFilename.jflex:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;%%&#xA;&#xA;%class DisplayFilename&#xA;&#xA;%eof{&#xA;    /* code to print the input filename goes here */&#xA;%eof}&#xA;&#xA;%%&#xA;&#xA;\n { /* do nothing */ }&#xA;. { /* do nothing */ }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Commands ran&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;jflex DisplayFilename&#xA;javac DisplayFilename.java&#xA;java DisplayFilename someinputfile.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;desired output:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;someinputfile.txt&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
</feed>