How can I show this grammar is ambiguous? - language-concepts

T-->iSS |iS
S--> n | T
I tried to show like this
T->iSS->inS->inn
T->iS->iT->iiSS->iinS->iinn
how can I fix this?

T
iS
iT
iiSS
iinn
T
iSS
iTS
iiSS
iinn

Related

If statement and split function

My memo line that looks something like this:
Return: #999 100.00\NSF|Balance=$242.00. Available Balance=$50.00`
or
Return: #888 45.90\WD REST.
I need it to return everything before the | if there is one, or the whole memo line if there isn't a |. Right now I have two formulas that give everything before the | or nothing if there isn't a |
memo1: left({table.memo},instr(table.memo},"|"))
memo2: replace({#Memo1},"|"," ")
How can I configure this such that if a | is present, return #Memo2, else return {table.memo}?
If I understand correctly, just make one more formula like this:
IF instr({table.memo},"|")>0
THEN {#Memo2}
ELSE {table.memo}
This displays one formula or the other based on the presence of that vertical line character.
I would use an if statement with instr:
memo1: left({table.memo},instr(table.memo},"|"))
memo2: replace({#Memo1},"|"," ")
if instr(table.memo} > 0
left({table.memo},instr(table.memo},"|"))
else
replace({#Memo1},"|"," ")
Please try something like that. (I did not check the syntax, so please check my work.)
Example for if

How to export a org-mode table to LaTeX with the correct placement [h]?

I'm trying to export a table to LaTeX form my org-file which looks like this:
#+LATEX_HEADER: \usepackage{adjustbox}
* table test
#+begin_table
#+LATEX: \caption{my caption}
label:tab:mylabel
#+ATTR_LATEX: :placement [h]
#+LATEX: \centering
#+LATEX: \adjustbox{max width=\linewidth}{
#+ATTR_LATEX: :center nil
| | |
| id | Question |
|----+--------------------------|
| | |
| 1 | Does it export with [h]? |
#+end_table
I want to get the exported TeX to look like this:
...
\begin{table}[h]
\caption{my caption}
\label{tab:mylabel}
\centering
\adjustbox{max width=\linewidth}{
\begin{tabular}{ll}
& \\
id & Question\\
\hline
& \\
1 & Does it export with [h]?\\
\end{tabular}
\end{table}
...
but I'm just getting
...
\begin{table}
\caption{my caption}
\label{tab:mylabel}
\centering
\adjustbox{max width=\linewidth}{
\begin{tabular}{ll}
& \\
id & Question\\
\hline
& \\
1 & Does it export with [h]?\\
\end{tabular}
\end{table}
...
using the following versions
GNU Emacs 25.1.1 (x86_64-apple-darwin15.5.0, NS appkit-1404.47 Version 10.11.5 (Build 15F34)) of 2017-01-06
Org mode version 9.0.5 (release_9.0.5-444-g998576 # ~/git/org-mode/lisp/)
I also tried
#+ATTR_LATEX: :float t :placement [h]
#+ATTR_LATEX: :center nil :float t :placement [h]
#+ATTR_LATEX: :center nil :placement [h]
#+begin_table :placement [h]
#+begin_table :float t :placement [h]
My search on the internet only found some emails from 2010, when org-latex.el existed. Since it still exists in the documentation I thought it should work somehow.
So can anyone help me? Or leak the magic words I have to feed Google with to find my answer?
Thx #Nick, we're on the right way but sadly not at the end of it.
Well I did not want to break the parsing, it explains some things.
I've got some more requirements and things to explain.
At First some of my tables are a bit wider like this:
| id | Question |
|----+---------------------------------------------------------------------------------------------------------------------------|
| 1 | Does it export with [h]? |
| 2 | I have some tables witch are very wide so What if you have a really wide table wich needs to be shrinked to the right size |
The Adjustbox package is the first I found that shrinks the whole table to the correct width. I tried your suggested tabularx but it's not shrinking the contents of the table. Without the shrinking most of my tables look weird.
The second Thing, I'm using org-ref. With your version (which I would prefer when the 2 probs are gone) exports to:
\caption{\label{tab:org56e3a68}
My caption}
I added #+label: tab:my-label as intended in the documentation. Added it before and after #+caption: and #+name: but it does not change anything in the .tex file.
any idea?
I can do everything you want, except the adjustbox stuff with this:
#+BIND: org-latex-prefer-user-labels t
* table test
#+caption: My caption
#+name:my-label
#+ATTR_LATEX: :placement [h] :center t
| | |
| id | Question |
|----+--------------------------|
| | |
| 1 | Does it export with [h]? |
I don't know what \adjustbox does or how it has to be used and where it has to be placed; however, you can't add #+LATEX: lines in between the #+caption and the table: they apparently break the parsing.
You could add another attribute to the ATTR_LATEX line:
#+ATTR_LATEX: :placement [h] :center t :width \linewidth
but it's not clear that does what you want. Also, I just tested and it does not do anything: that's because the standard environment is tabular which does not take a width argument. The following works:
#+ATTR_LATEX: :environment tabularx :placement [h] :center t :width \linewidth
but you also have to add
#+LATEX_HEADER: \usepackage{tabularx}
at the top of the file.

Creating macros in netbeans

I wish to create macro in Netbeans to put block comment over function. I have preference of code formatting over file save. So When I close file it saves code automatically and format it.
Issue is when I create function and comment it. It unformatted my whole block of code like this.
/**
*function abc(){
*var a, b = 50;
*}
*/
I wish to create comment like this. so it keep my coding properly formatted as well.
/*
|
| function abc(){
| var a, b = 50;
| }
|
*/
You can add your own macro by Following this instructions:
Edit->Start Macro Recording
Edit->Stop Macro Recirding
It Will pop-up one Box For Editor Macros->Add Your Choice of Macro Name
In code area add Your custom comment code in " your code "; Like,
Blockquote
"/*
|
| function abc(){
| var a, b = 50;
| }
|
*/"
Assign a Short Cut Key to your Custom Macro.
That's It
Though I couldn't find macro for the same. But I found alternative. Use Ctrl+Shift+R toggle, for multiple line action at same time & add pipeline sign. But it take extra effort for starting and ending comment.

What is ! and : used for in REXX

What does the ! and : do in REXX.
For instance in this piece of code
!all:!!=!;!=space(!);upper !;call !fid;!nt=right(!var('OS'),2)=='NT';!cls=word('CLS VMFCLEAR CLRSCREEN',1+!cms+!tso*2);if arg(1)\==1 then return 0;if wordpos(!,'? ?SAMPLES ?AUTHOR ?FLOW')==0 then return 0;!call=']$H';call '$H' !fn !;!call=;return 1
!cal:if symbol('!CALL')\=="VAR" then !call=;return !call
!env:!env='ENVIRONMENT';if !sys=='MSDOS'|!brexx|!r4|!roo then !env='SYSTEM';if !os2 then !env='OS2'!env;!ebcdic=1=='f0'x;return
!fid:parse upper source !sys !fun !fid . 1 . . !fn !ft !fm .;call !sys;if !dos then do;_=lastpos('\',!fn);!fm=left(!fn,_);!fn=substr(!fn,_+1);parse var !fn !fn '.' !ft;end;return word(0 !fn !ft !fm,1+('0'arg(1)))
!rex:parse upper version !ver !vernum !verdate .;!brexx='BY'==!vernum;!kexx='KEXX'==!ver;!pcrexx='REXX/PERSONAL'==!ver|'REXX/PC'==!ver;!r4='REXX-R4'==!ver;!regina='REXX-REGINA'==left(!ver,11);!roo='REXX-ROO'==!ver;call !env;return
!sys:!cms=!sys=='CMS';!os2=!sys=='OS2';!tso=!sys=='TSO'|!sys=='MVS';!vse=!sys=='VSE';!dos=pos('DOS',!sys)\==0|pos('WIN',!sys)\==0|!sys=='CMD';call !rex;return
!var:call !fid;if !kexx then return space(dosenv(arg(1)));return space(value(arg(1),,!env))
What is the !all:!!=! doing?
I actually have a lot of questions looking at this piece of code but I figured we would start there and see if that sheds some light on the rest.
The original code sample is located here http://rosettacode.org/wiki/Terminal_control/Coloured_text#REXX
As answered in the comments by Ryan Vincent:
The ! character is just another character you can use in 'variable names. So, instead of i in for loops you could use !. See the documentation and search for symbols.
The : is used at the end of a 'name' it indicate it is a 'label'. see: 12. Subroutines and functions. Trying to make sense of the 'optimized code that is shown will be 'interesting' but is possible. – Ryan Vincent Apr 18 at 19:55

Handling multiple return values in ANTLR

I have a simple rule in ANTLR:
title returns [ElementVector<Element> v]
#init{
$v = new ElementVector<Element>() ;
}
: '[]'
| '[' title_args {$v.add($title_args.ele);} (',' title_args {$v = $title_args.ele ;})* ']'
;
with title_args being:
title_args returns [Element ele]
: author {$ele = new Element("author", $author.text); }
| location {$ele = new Element("location", $location.text); }
;
Trying to compile that I get confronted with a 127 error in the title rule: title_args is a non-unique reference.
I've followed the solution given to another similar question in this website (How to deal with list return values in ANTLR) however it only seems to work with lexical rules.
Is there a specific way to go around it ?
Thank you,
Christos
You have 2 title_args in your expression, you need to alias them. Try this:
| '[' t1=title_args {$v.add($t1.ele);} (',' t2=title_args {$v = $t2.ele ;})* ']'
t1 and t2 are arbitrary aliases you can choose anything you want as long as they match up.
I think the problem is your reusing the title_args var. Try changing one of those variable names.
Yeah, I had the same problem.
You need to change one of the variable names; for example, do like the following:
title_args
title_args1
in your code instead of using title_args twice.
If title_args is a parser rule, then just create the same rule with the name title_args1.
So, basically there would be two rules with the same functionality.