More than 3 options are not working while declaring Xtext grammar - antlr

Particularly when I use more than 3 OR symbols.
datatype:
Integer | Float | Char | Blah | Blah
entity:
Class | Struct | Enumeration | Union
the complete grammar can be found here: https://gist.github.com/Mrprofessor/7b8df3f00c75ef2ac67bffd0a20e983c

The problem is that your grammar is ambigous
consider this model
Bla;
Blubb;
Pling;
are these Bits | Pointers | Labels | Entrys | Logicals | HwordLogicals | Bytes

Related

Translation database schema for software (exemplified)

I have a device with a GUI (menus etc) that I need translated. The translations are managed using a database.
I have looked at different answers to same issue:
Best practice for multi-language
Schema for a multilanguage database
As most of the examples explain mostly schemas, I have tried to make a small example, using SQLite:
Database shemas:
-- language table to hold individual languages
--
CREATE TABLE "languages" (
"languageID" TEXT NOT NULL,
"langNativeName" TEXT,
"langISOCode" TEXT
PRIMARY KEY("languageID")
)
-- words table to hold the strings to be translated
-- each string has an identifier used in software, such as "mainMenu", "label123" etc
CREATE TABLE "words" (
"wordID" INTEGER NOT NULL,
"wordKey" TEXT,
"wordDefault" TEXT,
PRIMARY KEY("wordID")
)
-- translations
-- combining languages and words
CREATE TABLE "translations" (
"keyID" INTEGER NOT NULL,
"langID" INTEGER NOT NULL,
"translation" TEXT,
PRIMARY KEY("keyID","langID")
)
With some sample data:
Languages:
+------------+----------------+-------------+-------------+
| languageID | langNativeName | langEnglish | langISOCode |
+------------+----------------+-------------+-------------+
| 1 | English | English | en |
| 2 | Francois | French | fr |
| 3 | Deutsch | German | de |
+------------+----------------+-------------+-------------+
Words: (strings to translate). The wordKey will always be unique.
+--------+----------------+-------------+
| wordID | wordKey | wordDefault |
+--------+----------------+-------------+
| 1 | tileProduction | Start |
| 2 | tileJobs | Job |
| 3 | tileGoto | Go To |
+--------+----------------+-------------+
Translations:
word (1) is not translated for English
word (3) is not translated at all
+-------+--------+--------------------+
| keyID | langID | translation |
+-------+--------+--------------------+
| 1 | 2 | Produccion |
| 1 | 3 | Produktion |
| 2 | 2 | Seleccion de tarea |
| 2 | 3 | Jobauswahl |
+-------+--------+--------------------+
My proposed SQL to get a translation
As I have understood from examples, the following SQL should be used to get a translation. An extra field has been added to get a star on untranslated items.
select
wordKey,
coalesce( translation, wordDefault) displaytext,
case coalesce( translation, wordDefault)
when translation then ""
else "*"
end remark
from
words
left join translations
on words.wordid = translations.keyID
AND
translations.langid = 3
left join languages on
languages.languageid = translations.langID
AND
translations.langID = 3
Which will give me:
+----------+-------------+--------+
| wordKey | displaytext | remark |
+----------+-------------+--------+
| tileProd | Produktion | |
| tileJob | Jobauswahl | |
| tileGoto | Go To | * |
+----------+-------------+--------+
This works.. but what I am in doubt about before I start inserting larger amounts of real data:
is this model correct, and if not, what may I have missed ? There will be some metadata for each language, which I have left out for clarity.
is the query to get a translation correct, or can it be done better ?

Not able to provide deicmal fields less than that is defined in fraction-digits

I am working with yang (RFC 6020). I have a leaf node 'Frequency' in yang. Frequency field is of type decimal64 and fraction-digits are defined as 6 and range from -90.000000 to 90.000000.
While trying to validate and save, following happens:
Number with 6 decimals gets saved eg. 34.000001
Number with no decimals gets saved eg. 34
But when I try to save number with decimal value less then 6 digits,
it doesn't get saved. It gives following error:
eg.
34.1:
"wrong fraction-digits 1 for type decimal64"
34.001 :
"wrong fraction-digits 3 for type decimal64"
34.00001 :
"wrong fraction-digits 5 for type decimal64"
Tried to search on net. Not much document is available on this.
Tried playing around with range parameter but it does not work.
leaf Frequency {
description "Frequency";
type decimal64 {
fraction-digits 6;
range "-90.000000..90.000000";
}
default 0;
}
I expect to be able to save values with/without decimal values where no of decimal values can vary from 0 to 6 digits. eg. 34, 34.1, 34.0004, 34.000001 etc
The value space for a decimal64 YANG type value with fraction-digits set to 6 are real numbers in the following range: -9223372036854.775808..9223372036854.775807. 34, 34.1, 34.001, 34.004, 34.00001 are all within this range and therefore valid values.
This is what the RFC says about decimal64 built-in type (RFC6020, Section 9.3, p1):
The decimal64 type represents a subset of the real numbers, which can
be represented by decimal numerals. The value space of decimal64 is
the set of numbers that can be obtained by multiplying a 64-bit
signed integer by a negative power of ten, i.e., expressible as
"i x 10^-n" where i is an integer64 and n is an integer between 1 and
18, inclusively.
So basically, d x 10^f, where d is a decimal64 value and f is fraction-digits, must result in a valid int64 value, which ranges from -9223372036854775808 to 9223372036854775807, inclusively.
Here is how fraction-digits is defined (RFC6020, Section 9.3.4, p1):
The "fraction-digits" statement, which is a substatement to the
"type" statement, MUST be present if the type is "decimal64". It
takes as an argument an integer between 1 and 18, inclusively. It
controls the size of the minimum difference between values of a
decimal64 type, by restricting the value space to numbers that are
expressible as "i x 10^-n" where n is the fraction-digits argument.
The following table lists the minimum and maximum value for each
fraction-digit value:
+----------------+-----------------------+----------------------+
| fraction-digit | min | max |
+----------------+-----------------------+----------------------+
| 1 | -922337203685477580.8 | 922337203685477580.7 |
| 2 | -92233720368547758.08 | 92233720368547758.07 |
| 3 | -9223372036854775.808 | 9223372036854775.807 |
| 4 | -922337203685477.5808 | 922337203685477.5807 |
| 5 | -92233720368547.75808 | 92233720368547.75807 |
| 6 | -9223372036854.775808 | 9223372036854.775807 |
| 7 | -922337203685.4775808 | 922337203685.4775807 |
| 8 | -92233720368.54775808 | 92233720368.54775807 |
| 9 | -9223372036.854775808 | 9223372036.854775807 |
| 10 | -922337203.6854775808 | 922337203.6854775807 |
| 11 | -92233720.36854775808 | 92233720.36854775807 |
| 12 | -9223372.036854775808 | 9223372.036854775807 |
| 13 | -922337.2036854775808 | 922337.2036854775807 |
| 14 | -92233.72036854775808 | 92233.72036854775807 |
| 15 | -9223.372036854775808 | 9223.372036854775807 |
| 16 | -922.3372036854775808 | 922.3372036854775807 |
| 17 | -92.23372036854775808 | 92.23372036854775807 |
| 18 | -9.223372036854775808 | 9.223372036854775807 |
+----------------+-----------------------+----------------------+
The tool you are using is wrong. The following is valid YANG:
typedef foobar {
type decimal64 {
fraction-digits 6;
range "-90.000000..90.000000";
}
default 34.00001;
}
YANG 1.1 (RFC7950) did not change this aspect of the language (the same applies).

Wso2 Scim extentinon datatype error

So i am extending Scim Api for Wso2. When i create an extension using a datatype string all the extensions work correctly. However in my Ldap i have a lot of other custom attributes and attributes that just use other datatype than string like operational or Telephone Number.
I tried to change the datatype value for one of the extended attributes but when requesting that attribute through Scim Api, it just leads me to a 500 error.
This is an example of the scim extension configuration
[{
"attributeURI":"urn:scim:schemas:extension:enterprise:1.0:enterprise.homePhone",
"attributeName":"homePhone",
"dataType":"Telephone Number",
"multiValued":"false",
"multiValuedAttributeChildName":"null",
"description":"The User's phone",
"schemaURI":"urn:scim:schemas:extension:enterprise:1.0",
"readOnly":"false",
"required":"false",
"caseExact":"false",
"subAttributes":"null"
},
{
"attributeURI":"urn:scim:schemas:extension:enterprise:1.0:enterprise.shareDirectory",
"attributeName":"shareDirectory",
"dataType":"string",
"multiValued":"false",
"multiValuedAttributeChildName":"null",
"description":"The User's share dir",
"schemaURI":"urn:scim:schemas:extension:enterprise:1.0",
"readOnly":"false",
"required":"false",
"caseExact":"false",
"subAttributes":"null"
},
{
"attributeURI":"urn:scim:schemas:extension:enterprise:1.0",
"attributeName":"enterprise",
"dataType":"null",
"multiValued":"false",
"multiValuedAttributeChildName":"null",
"description":"SCIM wso2 User Schema Extension",
"schemaURI":"urn:scim:schemas:extension:enterprise:1.0",
"readOnly":"false",
"required":"false",
"caseExact":"false",
"subAttributes":"homePhone shareDirectory"
}]
How can i use these attributes in my Scim Api? Do i need some special configuration?
There a set of data types which are supported by SCIM. So you have to map data types in your userstore for these.
+-----------+-------------+-----------------------------------------+
| SCIM Data | SCIM Schema | JSON Type |
| Type | "type" | |
+-----------+-------------+-----------------------------------------+
| String | "string" | String per Section 7 of [RFC7159] |
| | | |
| Boolean | "boolean" | Value per Section 3 of [RFC7159] |
| | | |
| Decimal | "decimal" | Number per Section 6 of [RFC7159] |
| | | |
| Integer | "integer" | Number per Section 6 of [RFC7159] |
| | | |
| DateTime | "dateTime" | String per Section 7 of [RFC7159] |
| | | |
| Binary | "binary" | Binary value base64 encoded per Section |
| | | 4 of [RFC4648], or with URL and |
| | | filename safe alphabet URL per Section |
| | | 5 of [RFC4648] that is passed as a JSON |
| | | string per Section 7 of [RFC7159] |
| | | |
| Reference | "reference" | String per Section 7 of [RFC7159] |
| | | |
| Complex | "complex" | Object per Section 4 of [RFC7159] |
+-----------+-------------+-----------------------------------------+
Reference: https://www.rfc-editor.org/rfc/rfc7643#section-2.3

sqlite3: Create tables with many rows or one table with more columns

I'm asking for a best practive when creating some tables for localization of an Web Interface in sqlite3
In my first intetion I wanted to create a table with the different languages, and another on for the Messeage Code and Entries.
tblLanguage
+------------+-------------+---------+
| idLangCode | txtLangName | txtCode |
+------------+-------------+---------+
| 1 | English | en |
| 2 | German | de |
| 3 | French | fr |
| 4 | Spanish | es |
| 5 | Chinese | zh |
+------------+-------------+---------+
tblMessageText
+----+-------+--------------------------+------------+
| Id | Code | Message | LanguageID |
+----+-------+--------------------------+------------+
| 1 | 20500 | Set Point changed | 1 |
| 2 | 20500 | Sollwert geändert | 2 |
| 3 | 20500 | Punto de ajuste cambiado | 5 |
+----+-------+--------------------------+------------+
So in the second table I would have several rows with the same Message Code but whith an different language text.
The other possibility would be to have just one table with just one row for each Message Code but an Column for each language.
tblMessageTextMulti
+----+-------+-------------------+-------------------+--------------------------+
| id | Code | txtMessageText_EN | txtMessageText_DE | txtMessageText_ES |
+----+-------+-------------------+-------------------+--------------------------+
| 1 | 20500 | Set Point changed | Sollwert geändert | Punto de ajuste cambiado |
+----+-------+-------------------+-------------------+--------------------------+
My team likes the second solution with just one table more, because it just has one entry for each Message Code, and you see all Language text side by side.
What I like on the first solution is, that I could dynmically Query the langugage with just on line in php:
$query = 'SELECT * FROM qryInfoMessage WHERE idLangCode=' .$Language;
For the second solution with one table I can not store the query itself in the database, because I have to change the Column name in my query dynmically. So I have to put this together in php.
$query = 'SELECT Code, txtMessageText_EN FROM tblMessageTextMulti;
What I dont show here is that my query is much more complex, whith string substitution and date time conversion.
Beside that, what are the advantages or disadvantages of this solutions. Which one should be more perfomant and what is the best practice?

Using Scenario Outline and Examples with Strings

I'm facing the following "issue" when trying out cucumber-jvm with an Arabic to Roman Numeral converter - the "then" piece gets converted into several step defs instead of one.
here's my scenario outline:
Scenario Outline:
Given a romanizer
When I romanize <arabic number>
Then I get the <roman numeral>
Examples:
| arabic number | roman numeral |
| 1 | I |
| 2 | II |
| 3 | III |
| 4 | IV |
| 5 | V |
| 6 | VI |
| 7 | VII |
| 8 | VIII |
| 9 | IX |
| 10 | X |
For this, i was expecting the then stepdef to simply be:
I_get_the(String value)
but instead it turns it into one stepdef for each example:
I_get_the_I()
I_get_the_II()
etc.
what am i doing wrong?
Thanks,
Nilesh
use (note the double quotes)
Scenario Outline:
Given a romanizer
When I romanize "<arabic number>"
Then I get the "<roman numeral>"