[Pharo-users] Xtreams: Debugging Grammars

2016-06-22 Thread Sean P. DeNigris
I converted parts of rfc 5322 to the following:
grammarEmailAddress

^'addrspec   <-   localpart "@" domain
localpart  <-   dotatom / quotedstring /* obs-local-part */
domain  <-   dotatom / domainliteral /* obs-domain */
domainliteral  <-   [CFWS] "[" *([FWS] dtext) [FWS] "]" [CFWS]
dtext   <- [\x21-\x50] //* Printable US-ASCII */

[\x54-\x7E]  /* characters not including */

/* / obs-dtext  ;  "[", "]", or "\" */

/* rfc5234 B.1 */
ALPHA  <-  [\x41-\x5A] / [\x61-\x7A]
DIGIT  <-  [\x30-\x39]
HTAB   <-  [\x09] /* horizontal tab */
SP <-  [\x20]
WSP<-  SP / HTAB

/* 3.2.2. Folding White Space and Comments */
FWS <-   ([*WSP CRLF] 1*WSP) 
/* obs-FWS */
   ctext   <-   [\x21-\x27] /
   [\x2A-\x5B] /
   [\x5D-\x7E]

   ccontent<-   ctext / quotedpair / comment

   comment <-   "(" *([FWS] ccontent) [FWS] ")"

   CFWS<-   (1*([FWS] comment) [FWS]) / FWS
/* 3.2.1.  Quoted characters */
   quotedpair <-   ("\" (VCHAR / WSP)) /* / obs-qp */
/* 3.2.3.  Atom */
atext   <-   ALPHA / DIGIT /
   "!" / "#" /
   "$" / "%" /
   "&" / "''" /
   "*" / "+" /
   "-" / "/" /
   "=" / "?" /
   "^" / "_" /
   "`" / "{" /
   "|" / "}" /
   "~"

   atom<-   [CFWS] 1*atext [CFWS]

   dotatomtext   <-   1*atext *("." 1*atext)

   dotatom<-   [CFWS] dotatomtext [CFWS]

/* 3.2.4.  Quoted Strings */
qtext   <-   [\x21] /   
/* Printable US-ASCII */
 [\x23-\x5B] /  /* characters not including */
 [\x5D-\x7E]/* "\" or the quote 
character */
   /* obs-qtext */
qcontent<-   qtext / quotedpair
quotedstring   <-   [CFWS] DQUOTE *([FWS] qcontent) [FWS] DQUOTE [CFWS]'

When I evaluate: 
parser := PEGParser parserPEG parse: 'Grammar' stream: PEGParser
grammarEmailAddress actor: PEGParserParser new.

I get: KeyNotFound: key 'quotedstring' not found in Dictionary

How am I supposed to debug that to find the typo in my giant string above?!



-
Cheers,
Sean
--
View this message in context: 
http://forum.world.st/Xtreams-Debugging-Grammars-tp4902581.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.



[Pharo-users] Xtreams: Extending Bootstrap

2016-06-22 Thread Sean P. DeNigris
I copy-pasted the addr-spec grammar from rfc5322 and was converting it to
Xtreams format. One PITA was converting all the decimal values to hex e.g.
"%d97" -> "\x61". I wanted to extend the Xtream grammar to handle
"/d97". I extended PEGParserGenerator and PEGParserParser with the
following:
Escape: backslash character: character hexes: hexes
...
character = $d ifTrue: [^(String withAll: hexes) asNumber 
asCharacter]

But I couldn't figure out how to put this extension into action.
PEGParser>>parserBootstrap has a comment "This method was generated with the
following code: PEGParser parserPEG parse: 'Grammar' stream: PEGParser
grammarPEG actor: PEGParserGenerator new", but evaluating that after
extending produced the same output as the original. What am I missing?
Thanks.



-
Cheers,
Sean
--
View this message in context: 
http://forum.world.st/Xtreams-Extending-Bootstrap-tp4902579.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.



Re: [Pharo-users] How can an image know it is running headless?

2016-06-22 Thread Sven Van Caekenberghe
SmalltalkImage>>#isHeadless ?

> On 22 Jun 2016, at 23:57, Johan Fabry  wrote:
> 
> Hi all,
> 
> I would like to know how to know if the image is running in headless mode. Is 
> there an expression I can run in my code to establish that?
> 
> TIA,
> 
> --
> Does this mail seem too brief? Sorry for that, I don’t mean to be rude! 
> Please see http://emailcharter.org .
> 
> Johan Fabry   -   http://pleiad.cl/~jfabry
> PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of 
> Chile
> 
> 




Re: [Pharo-users] How can an image know it is running headless?

2016-06-22 Thread Henrik Nergaard
MessageBrowser browse: (
(Symbol selectorTable 
select: [ :s | s includesSubstring: #headless caseSensitive: 
false ]
) flatCollect: [ :s | s implementors ] as: OrderedCollection
).


Best regards,
Henrik

-Original Message-
From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf Of 
Johan Fabry
Sent: Wednesday, June 22, 2016 11:57 PM
To: Pharo is welcome 
Subject: [Pharo-users] How can an image know it is running headless?

Hi all,

I would like to know how to know if the image is running in headless mode. Is 
there an expression I can run in my code to establish that?

TIA,

--
Does this mail seem too brief? Sorry for that, I don’t mean to be rude! Please 
see http://emailcharter.org .

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of 
Chile




[Pharo-users] How can an image know it is running headless?

2016-06-22 Thread Johan Fabry
Hi all,

I would like to know how to know if the image is running in headless mode. Is 
there an expression I can run in my code to establish that?

TIA,

--
Does this mail seem too brief? Sorry for that, I don’t mean to be rude! Please 
see http://emailcharter.org .

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of 
Chile




Re: [Pharo-users] Styling a Pharo UI application

2016-06-22 Thread Dimitris Chloupis
Documentation is always a problem.

I dont use Spec because I dont like it , but I use Morphic for my project
ChronosManager. I do some "styling" for example use different fonts for
different labels , different sizes , I format strings to time stamps and
even offer easy ways for user to change them without modifying the whole
string.

You can do a lot with Morphic, though I have not played with layout stuff
since this GUI is static and image (PNGs) based but yeah Morphic can do
that as well. My project is on Catalog browser and it has class comments ,
dont know if this exactly what you want but it may be a good start.

Obviously there are a ton of things you can do with a web page that Morphic
will not offer you out of the box.

You can use Html as the front end / GUI and keep Pharo as the backend,
thats how most web apps made with Pharo work. This you get the full power
of Html/JS and Pharo. Seaside has classes that map html to pharo methods so
you dont have to write html and js, and also I remember a pharo library
dealing with CSS.

Another option is to use a GUI API like QT , I have tried this with my
python bridge and it works at least on a very basic level, again similar
recipe to the above solution.

But yeah if you are not too demanding I think Morphic will serve you well.
Personally I only like Morphic , its the only GUI API that does not kill my
inner child.

On Wed, Jun 22, 2016 at 5:44 PM Tommaso Dal Sasso <
tommaso.dalsa...@gmail.com> wrote:

> Hello everybody,
>
> I have a question about the UI toolkits available for Pharo. I already
> asked something about this on Slack, but since I saw that there was a
> recent discussion about UI in the mailing list, I think this is a better
> place to discuss the matter.
>
> I am writing an application for Pharo where I am displaying some
> structured text. The structure is similar to the one of a web page: A
> main title with a list of paragraphs, where each paragraph has a title
> and a description.
>
> What I would like to do is to format the text to present the contents in
> a meaningful way: For example, I would like a bigger font for the title,
> and change the background of the text, to give a better separation
> between the paragraphs. Basically I would like to manipulate and display
> my contents as I would do in a web page.
>
> To write UI widgets I usually use Spec, but I found that going beyond
> easy formatting (e.g. bold text and emphasis) is harder than I thought.
> I saw there were discussion about the styling text and the role of the
> theme class, using TextStyle but that part is not really documented.
>
> So far, the easiest way to solve my problem seems to be to use Morphic
> to display the contents as I want it, and then include my widget in my
> spec application.
>
> Do you have any suggestions about how to do that? I think that styling
> the UI widgets is an important part of the application development, but
> it is really hard to find documentation about this.
>
> Thanks, have a nice day!
> Tommaso
>
>
>


[Pharo-users] Styling a Pharo UI application

2016-06-22 Thread Tommaso Dal Sasso

Hello everybody,

I have a question about the UI toolkits available for Pharo. I already 
asked something about this on Slack, but since I saw that there was a 
recent discussion about UI in the mailing list, I think this is a better 
place to discuss the matter.


I am writing an application for Pharo where I am displaying some 
structured text. The structure is similar to the one of a web page: A 
main title with a list of paragraphs, where each paragraph has a title 
and a description.


What I would like to do is to format the text to present the contents in 
a meaningful way: For example, I would like a bigger font for the title, 
and change the background of the text, to give a better separation 
between the paragraphs. Basically I would like to manipulate and display 
my contents as I would do in a web page.


To write UI widgets I usually use Spec, but I found that going beyond 
easy formatting (e.g. bold text and emphasis) is harder than I thought. 
I saw there were discussion about the styling text and the role of the 
theme class, using TextStyle but that part is not really documented.


So far, the easiest way to solve my problem seems to be to use Morphic 
to display the contents as I want it, and then include my widget in my 
spec application.


Do you have any suggestions about how to do that? I think that styling 
the UI widgets is an important part of the application development, but 
it is really hard to find documentation about this.


Thanks, have a nice day!
Tommaso




Re: [Pharo-users] File Policy

2016-06-22 Thread Christophe Demarey

> Le 22 juin 2016 à 14:05, Valentin Ryckewaert  
> a écrit :
> 
> Hello everyone,
> 
> i'm currently working on making Pharo able to manage if it writes on his 
> files.I created a class which can define it, then  I'm already able, for 
> example, to define if Pharo writes on pharo.changes or not.
> 
> The meaning of this is to make Pharo able to execute a script but without 
> being modified by it, a script shouldn't let any trace of its execution on 
> the image or on Pharo files.
> 
> My problem concern PharoDebug.log, I would like to know what you prefer Pharo 
> to do with it in the case we configured it to not write on his files 
> (changes, source,image).
> Should Pharo writes the logs in the terminal ? in a tmp file ? or just in 
> PharoDebug.log ?

If you want to use Pharo as a script interpreter, then just do like other 
interpreter: report results and errors on stdout / stderr.
Then, you can redirect the output to also have it in a file if you want. I 
would not use PharoDebug.log or any other file.

Christophe




[Pharo-users] File Policy

2016-06-22 Thread Valentin Ryckewaert
Hello everyone,

i'm currently working on making Pharo able to manage if it writes on his
files.I created a class which can define it, then  I'm already able, for
example, to define if Pharo writes on pharo.changes or not.

The meaning of this is to make Pharo able to execute a script but without
being modified by it, a script shouldn't let any trace of its execution on
the image or on Pharo files.

My problem concern PharoDebug.log, I would like to know what you prefer
Pharo to do with it in the case we configured it to not write on his files
(changes, source,image).
Should Pharo writes the logs in the terminal ? in a tmp file ? or just in
PharoDebug.log ?

Valentin