/blocks.c (94b5e7c838d93dfef8b491ee6a56af99e16913a8) (1421 bytes) (mode 100644) (type blob)
#include <stdint.h>
#include <stdio.h>
#include "blocks.h"
#include "misc.h"
static struct block_start {
int lineno;
enum block_type type;
};
static struct block_start *blocks = NULL;
static size_t size = 0;
static size_t capacity;
static char* names[] = { "function", "loop", "if" };
void block_push(int lineno, enum block_type type){
if(! blocks){
capacity = 7;
blocks = malloc(sizeof(struct block_start) * capacity);
}else if(size >= capacity){
capacity *= 2;
realloc(blocks, capacity * sizeof(struct block_start));
}
blocks[size].type = type;
blocks[size].lineno = lineno;
size++;
}
bool block_pop(enum block_type type, char *buf, size_t len){
if(size == 0){
// Standalone end* found
snprintf(buf, len, "Standalone %s (no corresponding opening block)", names[type]);
return false;
}
if(blocks[size-1].type != type){
// Missing end* for blocks[size-1].type
snprintf(buf, len, "Missing end%s for block openend in line %d", names[blocks[size-1].type], blocks[size-1].lineno);
return false;
}
size--;
return true;
}
void block_missing_error(int x, char *msg, size_t len){
if(size == 0){
return;
}
snprintf(msg, len, "Missing end%s for block opened in line %d.", names[blocks[size-1].type], blocks[size-1].lineno);
size--;
}
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
168 |
c1ca22975fdbd25aedc5c81f51b87f059bbc4140 |
.gitignore |
100644 |
blob |
48 |
3bfb16e6c32903fb8e4db429b412ee6e8ef23a14 |
AUTHORS |
100644 |
blob |
1313 |
4dc80d23e5c4804173171f9e03724a7d9fff66a1 |
LICENSE |
100644 |
blob |
3401 |
5fae73fcd20e216da60d0b0e54675a9940b32f47 |
Makefile |
100644 |
blob |
1421 |
94b5e7c838d93dfef8b491ee6a56af99e16913a8 |
blocks.c |
100644 |
blob |
289 |
3cfddca6eff9d8c40c1ea4f76f0e7e8b4947ad75 |
blocks.h |
100755 |
blob |
391 |
1f49d20bfca22ddee132b62a37c103610d08e211 |
check.sh |
100755 |
blob |
219 |
debf6a860da565f1e9e8d5a8c8a58daba0757ac4 |
fail.sh |
100644 |
blob |
215 |
e2d0c0f230e4387accdf5037eca5ee512c90a8a0 |
funcdecl.c |
100644 |
blob |
236 |
99ca506caaa5e457089f7391b005351fe8a0f2de |
funcdecl.h |
100644 |
blob |
21430 |
e47aacf3988f6c5869eb4d364ea82c09247eb39b |
grammar.y |
100644 |
blob |
2628 |
42cca350d155bcf65468482fb4c9a19c09e777e6 |
hashtable.c |
100644 |
blob |
501 |
2185dc1cb949f6fa3a1b0985b4caaf7769456156 |
hashtable.h |
100644 |
blob |
5936 |
f97aadd7e1ecef78fb7a2bbf8a5fc5ed97c31793 |
main.c |
100644 |
blob |
22707 |
59725fc4aaf8973ef8cf3594adcda707fd3978d1 |
misc.c |
100644 |
blob |
3730 |
9e4f9dd70ee282e3e6972e91f922d33e455f8127 |
misc.h |
100644 |
blob |
330 |
92a4597d6df5097c58649391541d54f06b3bda1b |
paramlist.c |
100644 |
blob |
256 |
bb253362ef26a0ea881856aebeb8503fb82646fb |
paramlist.h |
100644 |
blob |
1442 |
13257c0e670ee1208e24eba34fcaf87fb55b0fae |
readme.md |
040000 |
tree |
- |
fd8e11aa693c4db42bd4d1e68ce8054d7fea9193 |
tests |
100644 |
blob |
6115 |
a4763c19dd0a9d8ba9435d0144b4d7b453603459 |
token.l |
100644 |
blob |
2187 |
973210c307fc9f81122e72fff412139b57461ec3 |
typeandname.c |
100644 |
blob |
914 |
c7c2ecbf5459c7cb80bd2661e6ca78c32a780e10 |
typeandname.h |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/vrtc/pjass
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/vrtc/pjass
Clone this repository using git:
git clone git://git.rocketgit.com/user/vrtc/pjass
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main