Comments (12)
a block without a parameter is:
{\ ...block... }
from citrine.
Please go through and point out what needs to be changed, I intend to add this file to my cloned repo so that it would be easier for anyone to study the language.
I have changed messages ::-> [REF | CHAIN ] message messages | empty
to messages ::-> [ref | chain ] message messages | empty
chain ::-> ","
from citrine.
This issue relates to #60 .
from citrine.
I'll try but I find these grammars somewhat hard to read. Did you cover these cases:
- All messages of exactly symbol (+ - / but also 'a', implementation: 1 symbol == 1 unicode code point) are binary messages taking 2 arguments without the need for a colon (can a grammar capture a rule like this?)
- The comma, used to chain keyword messages (nothing else) for example: (a > b) ifTrue: {...}, else:
- The 'titled pipe' {\ used to denote a block without parameters
- The 'me' reference, same as 'my' but for messages instead of properties
- the backtick ` though this not part of the lexer, prefixing a message to yourself with a backtick causes invocation of the overridden parent method
from citrine.
bin message is not limited to
bin ::-> "+"|"-"|"/"|"*"|"<"|">"|"="
see point 1, this is where Citrine differs from Smalltalk, you can any 'symbol' as a binary message.
from citrine.
empty?
messages ::-> [REF | CHAIN ] message messages | empty
from citrine.
var is only needed if NOT in global scope, it's mandatory in non-global scope. In global scope, it's optional.
var_ref ::-> "var"
from citrine.
This is not true:
name ::-> [A-Za-z][A-Za-z]*
a name may use any character you want, there are no restrictions except tokens and the 'special' binary messages: < > = + / * - >= <= this has been done to allow cases like (3-a), see no space, however Citrine offers more freedom for names, you may literally use any symbol except for tokens and this limited set of characters. A binary message may be an emojicon like a pile of poo.
from citrine.
Thanks for comments, I am still studying this great language. I have not really read the language syntax beyond what I gleaned from C lang code base. I will be spend a couple of days to dive into this language.
I used the below to infer that popen is a receiver ... Looks like I am pretty wrong.
ctr_tnode* ctr_cparse_receiver() {
int t;
if (ctr_mode_debug) printf("Parsing receiver.\n");
t = ctr_clex_tok();
ctr_clex_putback();
switch(t){
case CTR_TOKEN_NIL:
return ctr_cparse_nil();
case CTR_TOKEN_BOOLEANYES:
return ctr_cparse_true();
case CTR_TOKEN_BOOLEANNO:
return ctr_cparse_false();
case CTR_TOKEN_NUMBER:
return ctr_cparse_number();
case CTR_TOKEN_QUOTE:
return ctr_cparse_string();
case CTR_TOKEN_REF:
return ctr_cparse_ref();
case CTR_TOKEN_BLOCKOPEN:
return ctr_cparse_block();
case CTR_TOKEN_PAROPEN:
return ctr_cparse_popen();
from citrine.
I will update grammar with the comments.
from citrine.
I could not figure out "titled pipe" from the below code, it looks like it is no more part of the code
The 'titled pipe' {\ used to denote a block without parameters
ctr_tnode* ctr_cparse_block() {
ctr_tnode* r;
ctr_tlistitem* codeBlockPart1;
ctr_tlistitem* codeBlockPart2;
ctr_tnode* paramList;
ctr_tnode* codeList;
ctr_tlistitem* previousListItem;
ctr_tlistitem* previousCodeListItem;
int t;
int first;
if (ctr_mode_debug) printf("Parsing code block.\n");
ctr_clex_tok();
r = CTR_PARSER_CREATE_NODE();
r->type = CTR_AST_NODE_CODEBLOCK;
codeBlockPart1 = CTR_PARSER_CREATE_LISTITEM();
r->nodes = codeBlockPart1;
codeBlockPart2 = CTR_PARSER_CREATE_LISTITEM();
r->nodes->next = codeBlockPart2;
paramList = CTR_PARSER_CREATE_NODE();
codeList = CTR_PARSER_CREATE_NODE();
codeBlockPart1->node = paramList;
codeBlockPart2->node = codeList;
paramList->type = CTR_AST_NODE_PARAMLIST;
codeList->type = CTR_AST_NODE_INSTRLIST;
t = ctr_clex_tok();
first = 1;
while(t == CTR_TOKEN_REF) {
ctr_tlistitem* paramListItem = CTR_PARSER_CREATE_LISTITEM();
ctr_tnode* paramItem = CTR_PARSER_CREATE_NODE();
long l = ctr_clex_tok_value_length();
paramItem->value = ctr_malloc(sizeof(char) * l, 0);
memcpy(paramItem->value, ctr_clex_tok_value(), l);
paramItem->vlen = l;
paramListItem->node = paramItem;
if (first) {
paramList->nodes = paramListItem;
previousListItem = paramListItem;
first = 0;
} else {
previousListItem->next = paramListItem;
previousListItem = paramListItem;
}
t = ctr_clex_tok();
}
if (t != CTR_TOKEN_BLOCKPIPE) {
printf("Error expected blockpipe.");
exit(1);
}
t = ctr_clex_tok();
first = 1;
while((first || t == CTR_TOKEN_DOT)) {
ctr_tlistitem* codeListItem;
ctr_tnode* codeNode;
if (first) {
if (ctr_mode_debug) printf("First, so put back\n");
ctr_clex_putback();
}
t = ctr_clex_tok();
if (t == CTR_TOKEN_BLOCKCLOSE) break;
ctr_clex_putback();
codeListItem = CTR_PARSER_CREATE_LISTITEM();
codeNode = CTR_PARSER_CREATE_NODE();
if (ctr_mode_debug) printf("--------> %d %s \n", t, ctr_clex_tok_value());
if (t == CTR_TOKEN_RET) {
codeNode = ctr_cparse_ret();
} else {
codeNode = ctr_cparse_expr(0);
}
codeListItem->node = codeNode;
if (first) {
codeList->nodes = codeListItem;
previousCodeListItem = codeListItem;
first = 0;
} else {
previousCodeListItem->next = codeListItem;
previousCodeListItem = codeListItem;
}
t = ctr_clex_tok();
if (t != CTR_TOKEN_DOT) {
printf("Expected . but got: %d.\n", t);
exit(1);
}
}
return r;
}
from citrine.
Tilted pipe is actually not enforced, you're currently allowed to use them both, the convention for now is to use \ for no params only.
if (c == '|' || c == '\\') { ctr_code++; return CTR_TOKEN_BLOCKPIPE; }
This will change at some point however, the pipe rules will be enforced eventually.
Also not that I am still tweaking some parts of the language, there are no more || and &&, you'll have to use or: and and: instead, this has been done to reduce the number of 'special' tokens and increase readability for non-programmers.
from citrine.
Related Issues (20)
- Scrolling screens
- Multiplayer support
- 3D game support
- Automatic resize images and window
- Hover event
- Scientific Plugin
- On-screen controls (for Android/iOS)
- Optional line numbers in edit fields
- Optional code highlighting in edit fields
- Single line edit fields
- Browser
- Integrated payment options
- Support for mesh networks
- FFI
- SQLite Plugin
- Export to MacOS
- Deep integration with speech synthesizer HOT 1
- Hi-end Video Support
- Basic HTTP Request
- Replacing text from clipboard gives error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from citrine.