StringState w/Empty StringBody

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by Jason Tobiasz
Avatar
In a document where there is an empty string, I get a squiggly under the string and when you hover over it it says: "unexpected token".

I thought modifying the language as to what was is described in the post: http://www.actiprosoftware.com/Support/Forums/ViewForumTopic.aspx?ForumTopicID=2938#10849 and in the help file to where PatternValue="[^\"]+" to PatternValue="[^\"]*" would resolve this issue, but it does not.

Below is what I'm using:


<State Key="StringState" Style="StringStyle">
  <Scopes>
    <Scope>
      <ExplicitPatternGroup Type="StartScope" TokenKey="StringStartToken" PatternValue="&quot;"/>
      <ExplicitPatternGroup Type="EndScope" TokenKey="StringEndToken" PatternValue="&quot;"/>
    </Scope>
  </Scopes>
  <PatternGroups>
    <RegexPatternGroup TokenKey="StringBody" PatternValue="[^\&quot;]*" />
  </PatternGroups>
</State>

Any thoughts?

Comments (4)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
That is coming from the semantic parser. If you are using our grammar designer and built a grammar that doesn't properly handle an empty document, that can show up.

To solve it you'd need to modify your root grammar production to be ok when there are no tokens to read.


Actipro Software Support

Posted 15 years ago by Jason Tobiasz
Avatar
I've just started working on an existing project at my company and the grammar for this project is rather large. I feel sort of lost.

I'm not really sure what it means by 'modify your root grammar production to be ok when there are no tokens to read'. Does that mean that I'm handling this at a non-terminal for 'LiteralString' and say that empty strings are acceptable?

More clarification would be appreciated.
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Jason,

Your root non-terminal production in the grammar (generally a compilation unit) is probably set up to require a certain non-terminal or token to be there. Look in our Simple language's grammar file for this:

<NonTerminal Key="CompilationUnit">

See how our call to FunctionDeclaration is wrapped in a {...}? That means zero or more.

If we instead would have just called:

"FunctionDeclaration<- ->"

Without wrapping it with a {...} then it would have generated a message like what you see when it parsed an empty document because you are telling it that the FunctionDeclaration must be there.


Actipro Software Support

Posted 15 years ago by Jason Tobiasz
Avatar
Thanks, that did the trick.

I apologize for my ignorance. I am just getting my feet wet.
The latest build of this product (v24.1.0) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.