I am having trouble translating an EBNF grammar to an Antlr4 grammar












2















I have the following EBNF grammar:



StringConstructor      ::=      "``[" StringConstructorContent "]``"
StringConstructorContent ::= StringConstructorChars (StringConstructorInterpolation StringConstructorChars)*
StringConstructorChars ::= (Char* - (Char* ('`{' | ']``') Char*))
StringConstructorInterpolation ::= "`{" Expr? "}`"
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]


And am trying the following in Antlr4 at xqDoc GitHub repository:



XQueryParser.g4



stringConstructor: '`' '`' '[' stringConstructorContent ']' '`' '`' ;

stringConstructorContent: stringConstructorChars (stringConstructorInterpolation stringConstructorChars)* ;

stringConstructorChars: ( CHAR* ~ ( CHAR* (('`' '{') | (']' '`' '`')) CHAR* ) ) ;

stringConstructorInterpolation: '`' '{' expr '}' '`' ;


XQueryLexer.g4



CHAR:   ( 't' | 'n' | 'r' | 'u0020'..'u0039' | 'u003B'..'uD7FF' | 'uE000'..'uFFFD' ) ;


It is for parsing the following:



for $s in ("one", "two", "red", "blue")
return ``[`{$s}` fish]``


and evaluates to the sequence ("one fish", "two fish", "red fish", "blue fish").



I am getting the following errors:



error(50): :494:38: syntax error: missing RPAREN at '*' while looking for rule element
error(50): :494:70: syntax error: extraneous input ')' expecting SEMI while matching a rule


Does anyone have a suggestion to fix this? I have commented out that section of the grammar so that it compiles.










share|improve this question























  • Are those errors referring to line 494 at columns 38 and 70? If so, which line in the code you provided is line 494 in your file?

    – Tomer Aberbach
    Nov 29 '18 at 18:33











  • line 494 is the stringConstructorChars in the XQueryParser.g4

    – Loren Cahlander
    Dec 19 '18 at 10:00
















2















I have the following EBNF grammar:



StringConstructor      ::=      "``[" StringConstructorContent "]``"
StringConstructorContent ::= StringConstructorChars (StringConstructorInterpolation StringConstructorChars)*
StringConstructorChars ::= (Char* - (Char* ('`{' | ']``') Char*))
StringConstructorInterpolation ::= "`{" Expr? "}`"
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]


And am trying the following in Antlr4 at xqDoc GitHub repository:



XQueryParser.g4



stringConstructor: '`' '`' '[' stringConstructorContent ']' '`' '`' ;

stringConstructorContent: stringConstructorChars (stringConstructorInterpolation stringConstructorChars)* ;

stringConstructorChars: ( CHAR* ~ ( CHAR* (('`' '{') | (']' '`' '`')) CHAR* ) ) ;

stringConstructorInterpolation: '`' '{' expr '}' '`' ;


XQueryLexer.g4



CHAR:   ( 't' | 'n' | 'r' | 'u0020'..'u0039' | 'u003B'..'uD7FF' | 'uE000'..'uFFFD' ) ;


It is for parsing the following:



for $s in ("one", "two", "red", "blue")
return ``[`{$s}` fish]``


and evaluates to the sequence ("one fish", "two fish", "red fish", "blue fish").



I am getting the following errors:



error(50): :494:38: syntax error: missing RPAREN at '*' while looking for rule element
error(50): :494:70: syntax error: extraneous input ')' expecting SEMI while matching a rule


Does anyone have a suggestion to fix this? I have commented out that section of the grammar so that it compiles.










share|improve this question























  • Are those errors referring to line 494 at columns 38 and 70? If so, which line in the code you provided is line 494 in your file?

    – Tomer Aberbach
    Nov 29 '18 at 18:33











  • line 494 is the stringConstructorChars in the XQueryParser.g4

    – Loren Cahlander
    Dec 19 '18 at 10:00














2












2








2








I have the following EBNF grammar:



StringConstructor      ::=      "``[" StringConstructorContent "]``"
StringConstructorContent ::= StringConstructorChars (StringConstructorInterpolation StringConstructorChars)*
StringConstructorChars ::= (Char* - (Char* ('`{' | ']``') Char*))
StringConstructorInterpolation ::= "`{" Expr? "}`"
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]


And am trying the following in Antlr4 at xqDoc GitHub repository:



XQueryParser.g4



stringConstructor: '`' '`' '[' stringConstructorContent ']' '`' '`' ;

stringConstructorContent: stringConstructorChars (stringConstructorInterpolation stringConstructorChars)* ;

stringConstructorChars: ( CHAR* ~ ( CHAR* (('`' '{') | (']' '`' '`')) CHAR* ) ) ;

stringConstructorInterpolation: '`' '{' expr '}' '`' ;


XQueryLexer.g4



CHAR:   ( 't' | 'n' | 'r' | 'u0020'..'u0039' | 'u003B'..'uD7FF' | 'uE000'..'uFFFD' ) ;


It is for parsing the following:



for $s in ("one", "two", "red", "blue")
return ``[`{$s}` fish]``


and evaluates to the sequence ("one fish", "two fish", "red fish", "blue fish").



I am getting the following errors:



error(50): :494:38: syntax error: missing RPAREN at '*' while looking for rule element
error(50): :494:70: syntax error: extraneous input ')' expecting SEMI while matching a rule


Does anyone have a suggestion to fix this? I have commented out that section of the grammar so that it compiles.










share|improve this question














I have the following EBNF grammar:



StringConstructor      ::=      "``[" StringConstructorContent "]``"
StringConstructorContent ::= StringConstructorChars (StringConstructorInterpolation StringConstructorChars)*
StringConstructorChars ::= (Char* - (Char* ('`{' | ']``') Char*))
StringConstructorInterpolation ::= "`{" Expr? "}`"
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]


And am trying the following in Antlr4 at xqDoc GitHub repository:



XQueryParser.g4



stringConstructor: '`' '`' '[' stringConstructorContent ']' '`' '`' ;

stringConstructorContent: stringConstructorChars (stringConstructorInterpolation stringConstructorChars)* ;

stringConstructorChars: ( CHAR* ~ ( CHAR* (('`' '{') | (']' '`' '`')) CHAR* ) ) ;

stringConstructorInterpolation: '`' '{' expr '}' '`' ;


XQueryLexer.g4



CHAR:   ( 't' | 'n' | 'r' | 'u0020'..'u0039' | 'u003B'..'uD7FF' | 'uE000'..'uFFFD' ) ;


It is for parsing the following:



for $s in ("one", "two", "red", "blue")
return ``[`{$s}` fish]``


and evaluates to the sequence ("one fish", "two fish", "red fish", "blue fish").



I am getting the following errors:



error(50): :494:38: syntax error: missing RPAREN at '*' while looking for rule element
error(50): :494:70: syntax error: extraneous input ')' expecting SEMI while matching a rule


Does anyone have a suggestion to fix this? I have commented out that section of the grammar so that it compiles.







xquery antlr antlr4






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 20:22









Loren CahlanderLoren Cahlander

568315




568315













  • Are those errors referring to line 494 at columns 38 and 70? If so, which line in the code you provided is line 494 in your file?

    – Tomer Aberbach
    Nov 29 '18 at 18:33











  • line 494 is the stringConstructorChars in the XQueryParser.g4

    – Loren Cahlander
    Dec 19 '18 at 10:00



















  • Are those errors referring to line 494 at columns 38 and 70? If so, which line in the code you provided is line 494 in your file?

    – Tomer Aberbach
    Nov 29 '18 at 18:33











  • line 494 is the stringConstructorChars in the XQueryParser.g4

    – Loren Cahlander
    Dec 19 '18 at 10:00

















Are those errors referring to line 494 at columns 38 and 70? If so, which line in the code you provided is line 494 in your file?

– Tomer Aberbach
Nov 29 '18 at 18:33





Are those errors referring to line 494 at columns 38 and 70? If so, which line in the code you provided is line 494 in your file?

– Tomer Aberbach
Nov 29 '18 at 18:33













line 494 is the stringConstructorChars in the XQueryParser.g4

– Loren Cahlander
Dec 19 '18 at 10:00





line 494 is the stringConstructorChars in the XQueryParser.g4

– Loren Cahlander
Dec 19 '18 at 10:00












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462040%2fi-am-having-trouble-translating-an-ebnf-grammar-to-an-antlr4-grammar%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462040%2fi-am-having-trouble-translating-an-ebnf-grammar-to-an-antlr4-grammar%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

To store a contact into the json file from server.js file using a class in NodeJS

Redirect URL with Chrome Remote Debugging Android Devices

Dieringhausen